Fixing issue with escaping on multiple bindings that are the same in queries.
This commit is contained in:
parent
6a4067da52
commit
581c27d8b7
|
@ -139,8 +139,13 @@ module.exports.disableEscaping = string => {
|
||||||
if (matches == null) {
|
if (matches == null) {
|
||||||
return string
|
return string
|
||||||
}
|
}
|
||||||
for (let match of matches) {
|
|
||||||
string = string.replace(match, `{${match}}`)
|
// find the unique set
|
||||||
|
const unique = [...new Set(matches)]
|
||||||
|
for (let match of unique) {
|
||||||
|
// add a negative lookahead to exclude any already
|
||||||
|
const regex = new RegExp(`${match}(?!})`, "g")
|
||||||
|
string = string.replace(regex, `{${match}}`)
|
||||||
}
|
}
|
||||||
return string
|
return string
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,5 +194,9 @@ describe("check that disabling escaping function works", () => {
|
||||||
it("should work with a combination", () => {
|
it("should work with a combination", () => {
|
||||||
expect(disableEscaping("{{ name }} welcome to {{{ platform }}}")).toEqual("{{{ name }}} welcome to {{{ platform }}}")
|
expect(disableEscaping("{{ name }} welcome to {{{ platform }}}")).toEqual("{{{ name }}} welcome to {{{ platform }}}")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should work with multiple escaped", () => {
|
||||||
|
expect(disableEscaping("{{ name }} welcome to {{ name }}")).toEqual("{{{ name }}} welcome to {{{ name }}}")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue