Skip to content

Commit 0f566d1

Browse files
committed
Use 'lastIndex' in the closeTag regex
1 parent f28373b commit 0f566d1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

packages/theme/src/cli/utilities/theme-environment/liquid-tag-content.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,19 @@ export function getLiquidTagContent(liquid: string, tag: 'javascript' | 'stylesh
3232
const closeTagRE = new RegExp(`{%-?\\s*end${tag}\\s*-?%}`)
3333

3434
const openMatch = openTagRE.exec(liquid)
35-
3635
if (!openMatch) {
3736
return
3837
}
3938

4039
const startIndex = openMatch.index + openMatch[0].length
41-
const closeMatch = closeTagRE.exec(liquid)
40+
closeTagRE.lastIndex = startIndex
4241

42+
const closeMatch = closeTagRE.exec(liquid)
4343
if (!closeMatch) {
4444
return
4545
}
4646

4747
const endIndex = closeMatch.index
4848

49-
if (startIndex > endIndex) {
50-
return
51-
}
52-
5349
return liquid.slice(startIndex, endIndex)
5450
}

0 commit comments

Comments
 (0)