Skip to content

Commit

Permalink
fix: better filtering of file URLs
Browse files Browse the repository at this point in the history
Fixes #117
  • Loading branch information
harlan-zw committed Jul 21, 2024
1 parent d8d1fc0 commit 27a95be
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,13 @@ declare module 'vue-router' {
...prerenderUrls,
...((await nitroPromise)._prerenderedRoutes || [])
.filter((r) => {
const isExplicitFile = r.route.split('/').pop()!.includes('.')
return r.contentType?.includes('text/html') && !isExplicitFile
const lastSegment = r.route.split('/').pop()
// check for file in lastSegment using regex
const isExplicitFile = !!(lastSegment?.match(/\.[0-9a-z]+$/i)?.[0])
// avoid adding fallback pages to sitemap
if (r.error || ['/200.html', '/404.html', '/index.html'].includes(r.route))
return false
return (r.contentType?.includes('text/html') || !isExplicitFile)
})
.map(r => r._sitemap),
]
Expand Down

0 comments on commit 27a95be

Please sign in to comment.