Skip to content

Commit 27a95be

Browse files
committedJul 21, 2024·
fix: better filtering of file URLs
Fixes #117
1 parent d8d1fc0 commit 27a95be

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎src/module.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,13 @@ declare module 'vue-router' {
534534
...prerenderUrls,
535535
...((await nitroPromise)._prerenderedRoutes || [])
536536
.filter((r) => {
537-
const isExplicitFile = r.route.split('/').pop()!.includes('.')
538-
return r.contentType?.includes('text/html') && !isExplicitFile
537+
const lastSegment = r.route.split('/').pop()
538+
// check for file in lastSegment using regex
539+
const isExplicitFile = !!(lastSegment?.match(/\.[0-9a-z]+$/i)?.[0])
540+
// avoid adding fallback pages to sitemap
541+
if (r.error || ['/200.html', '/404.html', '/index.html'].includes(r.route))
542+
return false
543+
return (r.contentType?.includes('text/html') || !isExplicitFile)
539544
})
540545
.map(r => r._sitemap),
541546
]

0 commit comments

Comments
 (0)
Please sign in to comment.