diff --git a/deno_dist/parse.ts b/deno_dist/parse.ts index 451fac0..83119ed 100644 --- a/deno_dist/parse.ts +++ b/deno_dist/parse.ts @@ -105,8 +105,7 @@ export default function parse( }, ""); const parseOpenReg = new RegExp( - "([^]*?)" + escapeRegExp(config.tags[0]) + "(-|_)?\\s*(" + prefixes + - ")?\\s*", + escapeRegExp(config.tags[0]) + "(-|_)?\\s*(" + prefixes + ")?\\s*", "g", ); @@ -119,11 +118,12 @@ export default function parse( let m; while ((m = parseOpenReg.exec(str))) { + const precedingString = str.slice(lastIndex, m.index); + lastIndex = m[0].length + m.index; - const precedingString = m[1]; - const wsLeft = m[2]; - const prefix = m[3] || ""; // by default either ~, =, or empty + const wsLeft = m[1]; + const prefix = m[2] || ""; // by default either ~, =, or empty pushString(precedingString, wsLeft); diff --git a/src/parse.ts b/src/parse.ts index 7a650b3..9cdbb85 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -98,7 +98,7 @@ export default function parse(str: string, config: EtaConfig): Array ""); const parseOpenReg = new RegExp( - "([^]*?)" + escapeRegExp(config.tags[0]) + "(-|_)?\\s*(" + prefixes + ")?\\s*", + escapeRegExp(config.tags[0]) + "(-|_)?\\s*(" + prefixes + ")?\\s*", "g" ); @@ -111,11 +111,12 @@ export default function parse(str: string, config: EtaConfig): Array let m; while ((m = parseOpenReg.exec(str))) { + const precedingString = str.slice(lastIndex, m.index); + lastIndex = m[0].length + m.index; - const precedingString = m[1]; - const wsLeft = m[2]; - const prefix = m[3] || ""; // by default either ~, =, or empty + const wsLeft = m[1]; + const prefix = m[2] || ""; // by default either ~, =, or empty pushString(precedingString, wsLeft);