fix(generator): remove trailingSlash for chunkId (#7336)

[release]
This commit is contained in:
Sébastien Chopin 2020-05-08 18:10:06 +02:00 committed by GitHub
parent 631be3a1dd
commit 8e2d9764e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -276,7 +276,7 @@ export default class Generator {
// If crawler activated and called from generateRoutes()
if (this.options.generate.crawler && this.options.render.ssr) {
parse(html).querySelectorAll('a').map((el) => {
const href = (el.getAttribute('href') || '').split('?')[0].split('#')[0].trim()
const href = (el.getAttribute('href') || '').replace(/\/+$/, '').split('?')[0].split('#')[0].trim()
if (href.startsWith('/') && !path.extname(href) && this.shouldGenerateRoute(href) && !this.generatedRoutes.has(href)) {
this.generatedRoutes.add(href) // add the route to the tracked list

View File

@ -303,7 +303,7 @@ export default {
this._payloadFetchIndex = 0
},
async fetchPayload(route) {
route = (route.replace(/\/$/, '') || '/').split('?')[0]
route = (route.replace(/\/+$/, '') || '/').split('?')[0]
try {
const src = urlJoin(window.__NUXT_STATIC__, route, 'payload.js')
const payload = await window.__NUXT_IMPORT__(route, src)

View File

@ -185,7 +185,8 @@ export default class SSRRenderer extends BaseRenderer {
// Page level payload.js (async loaded for CSR)
const payloadPath = urlJoin(url, 'payload.js')
const payloadUrl = urlJoin(staticAssetsBase, payloadPath)
const payloadScript = `__NUXT_JSONP__("${url}", ${devalue({ data, fetch })});`
const routePath = (url.replace(/\/+$/, '') || '/').split('?')[0] // remove trailing slah and query params
const payloadScript = `__NUXT_JSONP__("${routePath}", ${devalue({ data, fetch })});`
staticAssets.push({ path: payloadPath, src: payloadScript })
preloadScripts.push(payloadUrl)