diff --git a/src/cli/commands/deploy.js b/src/cli/commands/deploy.js index 1f10099..6400cd7 100644 --- a/src/cli/commands/deploy.js +++ b/src/cli/commands/deploy.js @@ -179,8 +179,8 @@ function calculateTimeout (timeout) { } if (typeof timeout === 'string') { - let matches; - if (matches = timeout.match(/^(\d+)s$/)) { // eslint-disable-line + let matches = timeout.match(/^(\d+)s$/); + if (matches && matches[1] && typeof matches[1] === 'string') { const timeout = parseFloat(matches[1]); if (!isNaN(timeout)) { if (timeout > MAX.seconds) { @@ -189,7 +189,10 @@ function calculateTimeout (timeout) { } return { seconds: timeout }; } - } else if (matches = timeout.match(/^(\d+)ms$/)) { // eslint-disable-line + } + + matches = timeout.match(/^(\d+)ms$/); + if (matches && matches[1] && typeof matches[1] === 'string') { const timeout = parseFloat(matches[1]) / 1000; if (!isNaN(timeout)) { if (timeout > MAX.seconds) { diff --git a/src/model/cloudfunction.js b/src/model/cloudfunction.js index 12c6d24..47a629e 100644 --- a/src/model/cloudfunction.js +++ b/src/model/cloudfunction.js @@ -215,8 +215,8 @@ class CloudFunction { static parseLocation (location = '') { const matches = location.match(CloudFunction.LOCATION_REG_EXP); return { - project: matches[1], - location: matches[2] + project: matches ? matches[1] : null, + location: matches ? matches[2] : null }; } @@ -230,9 +230,9 @@ class CloudFunction { static parseName (name = '') { const matches = name.match(CloudFunction.NAME_REG_EXP); return { - project: matches[1], - location: matches[2], - name: matches[3] + project: matches ? matches[1] : null, + location: matches ? matches[2] : null, + name: matches ? matches[3] : null }; } diff --git a/src/model/operation.js b/src/model/operation.js index d72b041..a15ee11 100644 --- a/src/model/operation.js +++ b/src/model/operation.js @@ -161,7 +161,7 @@ class Operation { static parseName (name = '') { const matches = name.match(Operation.NAME_REG_EXP); return { - operation: matches[1] + operation: matches ? matches[1] : null }; }