mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 21:58:19 +00:00
fix(generator): respect options.router.trailingSlash
for crawler (#7431)
This commit is contained in:
parent
2e711c143b
commit
c14471681c
@ -299,8 +299,15 @@ export default class Generator {
|
||||
|
||||
// If crawler activated and called from generateRoutes()
|
||||
if (this.options.generate.crawler && this.options.render.ssr) {
|
||||
const possibleTrailingSlash = this.options.router.trailingSlash ? '/' : ''
|
||||
parse(html).querySelectorAll('a').map((el) => {
|
||||
const href = (el.getAttribute('href') || '').replace(/\/+$/, '').split('?')[0].split('#')[0].trim()
|
||||
const sanitizedHref = (el.getAttribute('href') || '')
|
||||
.replace(/\/+$/, '')
|
||||
.split('?')[0]
|
||||
.split('#')[0]
|
||||
.trim()
|
||||
|
||||
const href = sanitizedHref + possibleTrailingSlash
|
||||
|
||||
if (href.startsWith('/') && !path.extname(href) && this.shouldGenerateRoute(href) && !this.generatedRoutes.has(href)) {
|
||||
this.generatedRoutes.add(href) // add the route to the tracked list
|
||||
|
Loading…
Reference in New Issue
Block a user