mirror of
https://github.com/usebruno/bruno.git
synced 2025-08-14 08:18:29 +02:00
feat(#682): Add validation for request vars & dynamic vars
This commit is contained in:
@ -59,10 +59,24 @@ class Bru {
|
||||
throw new Error('Key is required');
|
||||
}
|
||||
|
||||
if (/^(?!\d)\w*$/.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.'
|
||||
);
|
||||
}
|
||||
|
||||
this.collectionVariables[key] = value;
|
||||
}
|
||||
|
||||
getVar(key) {
|
||||
if (/^(?!\d)\w*$/.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.'
|
||||
);
|
||||
}
|
||||
|
||||
return this.collectionVariables[key];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user