Fix regex for parsing memory numbers

It now allows a trailing `b`, as the docker-compose docs specify.

In addition the regex now specifies a case-insensitive flag, to catch
both upper and lower case memory numbers (the rest of the function
supported these already).

Change-type: patch
Closes: #603
Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
Cameron Diver 2018-04-04 11:24:21 +01:00
parent 026501a553
commit 7d233ea111
No known key found for this signature in database
GPG Key ID: E76D7ACBEE436E12

View File

@ -14,7 +14,7 @@ validRestartPolicies = [ 'no', 'always', 'on-failure', 'unless-stopped' ]
PORTS_REGEX = /^(?:(?:([a-fA-F\d.:]+):)?([\d]*)(?:-([\d]+))?:)?([\d]+)(?:-([\d]+))?(?:\/(udp|tcp))?$/
parseMemoryNumber = (numAsString, defaultVal) ->
m = numAsString?.toString().match(/^([0-9]+)([bkmg]?)$/)
m = numAsString?.toString().match(/^([0-9]+)([bkmg])?b?$/i)
if !m? and defaultVal?
return parseMemoryNumber(defaultVal)
num = m[1]