mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 23:02:40 +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;
|
return nameSuffix !== 0 ? `${item.name}_${nameSuffix}` : item.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
const regexVariable = new RegExp('{{.*?}}', 'g');
|
// Matches any string that starts with '{{' and ends with '}}', capturing everything in between.
|
||||||
const regexToRemove = new RegExp('(?:_\\.|[\\s\\]]+)', 'g');
|
const regexVariable = /{{.*?}}/g;
|
||||||
const regexToUnderscore = new RegExp('[.\\[]', '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 normalizeVariables = (value = "") => {
|
||||||
const variables = value.match(regexVariable) || [];
|
const variables = value.match(regexVariable) || [];
|
||||||
|
Loading…
Reference in New Issue
Block a user