Quick fix based on test case failure.

This commit is contained in:
mike12345567 2020-09-22 10:41:56 +01:00
parent fca788f424
commit 90027952ea
1 changed files with 5 additions and 1 deletions

View File

@ -10,7 +10,11 @@ function cleanMustache(string) {
"]": "", "]": "",
} }
let regex = new RegExp(/{{[^}}]*}}/g) let regex = new RegExp(/{{[^}}]*}}/g)
for (let match of string.match(regex)) { let matches = string.match(regex)
if (matches == null) {
return string
}
for (let match of matches) {
let baseIdx = string.indexOf(match) let baseIdx = string.indexOf(match)
for (let key of Object.keys(charToReplace)) { for (let key of Object.keys(charToReplace)) {
let idxChar = match.indexOf(key) let idxChar = match.indexOf(key)