templating: fix queries contained regex with braces, fixes #432

This commit is contained in:
Alexander Zobnin
2017-07-25 12:06:37 +03:00
parent b1fafc23a7
commit 996bc9e1d1
7 changed files with 152 additions and 7 deletions

View File

@@ -93,7 +93,7 @@ function escapeMacro(macro) {
* {group}{host.com} -> [group, host.com]
*/
export function splitTemplateQuery(query) {
let splitPattern = /{[^{}]*}/g;
let splitPattern = /\{[^\{\}]*\}|\{\/.*\/\}/g;
let split;
if (isContainsBraces(query)) {
@@ -109,7 +109,8 @@ export function splitTemplateQuery(query) {
}
function isContainsBraces(query) {
return query.includes('{') && query.includes('}');
let bracesPattern = /^\{.+\}$/;
return bracesPattern.test(query);
}
// Pattern for testing regex