mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-19 00:26:53 +00:00
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:
parent
026501a553
commit
7d233ea111
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user