feat(#931): relax var name strictness

This commit is contained in:
Anoop M D
2023-12-02 01:27:18 +05:30
parent 2aa876e526
commit bacb70ea7e
5 changed files with 13 additions and 13 deletions

View File

@ -1,7 +1,7 @@
const Handlebars = require('handlebars');
const { cloneDeep } = require('lodash');
const envVariableNameRegex = /^(?!\d)[\w-.]*$/;
const variableNameRegex = /^[\w-.]*$/;
class Bru {
constructor(envVariables, collectionVariables, processEnvVars, collectionPath) {
@ -61,10 +61,10 @@ class Bru {
throw new Error('Creating a variable without specifying a name is not allowed.');
}
if (envVariableNameRegex.test(key) === false) {
if (variableNameRegex.test(key) === false) {
throw new Error(
`Variable name: "${key}" contains invalid characters!` +
' Names must only contain alpha-numeric characters, "-", "_", "." and cannot start with a digit.'
' Names must only contain alpha-numeric characters, "-", "_", "."'
);
}
@ -72,10 +72,10 @@ class Bru {
}
getVar(key) {
if (envVariableNameRegex.test(key) === false) {
if (variableNameRegex.test(key) === false) {
throw new Error(
`Variable name: "${key}" contains invalid characters!` +
' Names must only contain alpha-numeric characters, "-", "_", "." and cannot start with a digit.'
' Names must only contain alpha-numeric characters, "-", "_", "."'
);
}