mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
fix(generator): avoid duplicate slashes for routes ending with hash (#7776)
* fix: remove duplicate slashes from crawled routes * fixture: use trailing slash for hash * refactor: do trailing slash sanetization after hash removal * test: enable trailing slash for full-static fixture Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
parent
5f7d675807
commit
298c3e3ef7
@ -297,9 +297,9 @@ export default class Generator {
|
||||
parse(html).querySelectorAll('a').map((el) => {
|
||||
const sanitizedHref = (el.getAttribute('href') || '')
|
||||
.replace(this.options.router.base, '/')
|
||||
.replace(/\/+$/, '')
|
||||
.split('?')[0]
|
||||
.split('#')[0]
|
||||
.replace(/\/+$/, '')
|
||||
.trim()
|
||||
|
||||
const route = decodeURI(sanitizedHref + possibleTrailingSlash)
|
||||
|
@ -10,7 +10,7 @@
|
||||
<NLink to="/pagination/1">
|
||||
Pagination
|
||||
</NLink>
|
||||
<NLink to="/dynamic/foo bar#hash">
|
||||
<NLink to="/dynamic/foo bar/#hash">
|
||||
Dynamic route 1
|
||||
</NLink>
|
||||
<NLink to="/dynamic/foo%20bar">
|
||||
|
3
test/fixtures/full-static/nuxt.config.js
vendored
3
test/fixtures/full-static/nuxt.config.js
vendored
@ -6,7 +6,8 @@ export default {
|
||||
}
|
||||
},
|
||||
router: {
|
||||
// base: '/test'
|
||||
// base: '/test',
|
||||
trailingSlash: true
|
||||
},
|
||||
hooks: {
|
||||
export: {
|
||||
|
Loading…
Reference in New Issue
Block a user