mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 06:31:18 +01:00
refactor: improve regex patterns with comments to document
This commit is contained in:
parent
637b7090ed
commit
4189dbf134
@ -58,9 +58,14 @@ const addSuffixToDuplicateName = (item, index, allItems) => {
|
||||
return nameSuffix !== 0 ? `${item.name}_${nameSuffix}` : item.name;
|
||||
};
|
||||
|
||||
const regexVariable = new RegExp('{{.*?}}', 'g');
|
||||
const regexToRemove = new RegExp('(?:_\\.|[\\s\\]]+)', 'g');
|
||||
const regexToUnderscore = new RegExp('[.\\[]', 'g');
|
||||
// Matches any string that starts with '{{' and ends with '}}', capturing everything in between.
|
||||
const regexVariable = /{{.*?}}/g;
|
||||
|
||||
// Matches any sequence that starts with '_', followed by a dot '.', and then one or more whitespace characters or closing square brackets.
|
||||
const regexToRemove = /(?:_\.[\s\]]+)/g;
|
||||
|
||||
// Matches any dot '.' or opening square bracket '['.
|
||||
const regexToUnderscore = /[.\[]/g;
|
||||
|
||||
const normalizeVariables = (value = "") => {
|
||||
const variables = value.match(regexVariable) || [];
|
||||
|
Loading…
Reference in New Issue
Block a user