fix(build): reset regex lastIndex before testing

pull/2314/head
Divyansh Singh 2 years ago
parent a647cd3843
commit 188893c2c1

@ -27,10 +27,14 @@ export async function resolvePages(srcDir: string, userConfig: UserConfig) {
})
).sort()
const pages = allMarkdownFiles.filter((p) => !dynamicRouteRE.test(p))
const dynamicRouteFiles = allMarkdownFiles.filter((p) =>
dynamicRouteRE.test(p)
)
const pages: string[] = []
const dynamicRouteFiles: string[] = []
allMarkdownFiles.forEach((file) => {
dynamicRouteRE.lastIndex = 0
;(dynamicRouteRE.test(file) ? dynamicRouteFiles : pages).push(file)
})
const dynamicRoutes = await resolveDynamicRoutes(srcDir, dynamicRouteFiles)
pages.push(...dynamicRoutes.routes.map((r) => r.path))

Loading…
Cancel
Save