Skip to content

Commit

Permalink
Validation of command line variable is made by regex
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikValkovic committed Oct 25, 2021
1 parent c0bc769 commit ddf835e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ if (argv.c) {
}

function validateCmdVariable (param) {
const indexOfEqualSign = param.indexOf('=')
if (indexOfEqualSign === -1 || indexOfEqualSign === 0 || indexOfEqualSign === param.length - 1) {
if (!param.match(/^\w+=\w+$/)) {
console.error('Unexpected argument ' + param + '. Expected variable in format variable=value')
process.exit(1)
}

return param
}
var variables = []
Expand Down

0 comments on commit ddf835e

Please sign in to comment.