Skip to content

Commit 188893c

Browse files
committed
fix(build): reset regex lastIndex before testing
1 parent a647cd3 commit 188893c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/node/plugins/dynamicRoutesPlugin.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ export async function resolvePages(srcDir: string, userConfig: UserConfig) {
2727
})
2828
).sort()
2929

30-
const pages = allMarkdownFiles.filter((p) => !dynamicRouteRE.test(p))
31-
const dynamicRouteFiles = allMarkdownFiles.filter((p) =>
32-
dynamicRouteRE.test(p)
33-
)
30+
const pages: string[] = []
31+
const dynamicRouteFiles: string[] = []
32+
33+
allMarkdownFiles.forEach((file) => {
34+
dynamicRouteRE.lastIndex = 0
35+
;(dynamicRouteRE.test(file) ? dynamicRouteFiles : pages).push(file)
36+
})
37+
3438
const dynamicRoutes = await resolveDynamicRoutes(srcDir, dynamicRouteFiles)
3539
pages.push(...dynamicRoutes.routes.map((r) => r.path))
3640

0 commit comments

Comments
 (0)