Skip to content

Commit f4072d2

Browse files
fix(runtime): reset lastIndex before reusing regexes (#564)
1 parent c742e7f commit f4072d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/runtime/src/components/Diagnostic.ce.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface Link {
1313
function calcLink(text: string) {
1414
let curIndex = 0
1515
let match
16+
fileRE.lastIndex = 0
1617
const links: Link[] = []
1718
while ((match = fileRE.exec(text))) {
1819
const { 0: file, index } = match
@@ -44,9 +45,9 @@ const checkerColorMap: Record<string, string> = {
4445
4546
const fileRE = /(?:[a-zA-Z]:\\|\/).*(:\d+:\d+)?/g
4647
const codeFrameRE = /^(?:>?\s+\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm
47-
codeFrameRE.lastIndex = 0
4848
4949
const hasFrame = computed(() => {
50+
codeFrameRE.lastIndex = 0
5051
return diagnostic.frame && codeFrameRE.test(diagnostic.frame)
5152
})
5253

0 commit comments

Comments
 (0)