Fixed issue where certain parameter were not converted to variables in conversion

This commit is contained in:
Vishal Shingala
2021-03-17 20:05:43 +05:30
parent 86627b952c
commit 2a23baf8ee
2 changed files with 10 additions and 4 deletions

View File

@@ -306,11 +306,15 @@ module.exports = {
// All complicated logic removed
// This simply replaces all instances of {text} with {{text}}
// text cannot have any of these 3 chars: /{}
// and {text} cannot be followed by a }
// {{text}} will not be converted
// https://regex101.com/r/9N1520/1
return url
.replace(/(\{[^\/\{\}]+\})(?!\})/g, '{$1}');
let replacer = function (match, p1, offset, string) {
if (string[offset - 1] === '{' && string[offset + match.length + 1] !== '}') {
return match;
}
return '{' + p1 + '}';
};
return url.replace(/(\{[^\/\{\}]+\})/g, replacer);
},
/**