fix(utils): error when router.trailingSlash is false (#6515)

This commit is contained in:
Yuki Terashima 2019-10-08 17:48:52 +09:00 committed by Pooya Parsa
parent f28d12c913
commit 2d27a4d2dc
2 changed files with 11 additions and 10 deletions

View File

@ -176,7 +176,7 @@ export const createRoutes = function createRoutes ({
})
if (trailingSlash !== undefined) {
route.pathToRegexpOptions = { ...route.pathToRegexpOptions, strict: true }
route.path = route.path.replace(/\/+$/, '') + (trailingSlash ? '/' : '')
route.path = route.path.replace(/\/+$/, '') + (trailingSlash ? '/' : '') || '/'
}
parent.push(route)

View File

@ -210,15 +210,6 @@ Array [
exports[`util: route util: route create createRoutes should remove trailing slashes when configured to 1`] = `
Array [
Object {
"chunkName": "pages/index",
"component": "/some/nuxt/app/pages/index.vue",
"name": "index",
"path": "",
"pathToRegexpOptions": Object {
"strict": true,
},
},
Object {
"chunkName": "pages/parent/index",
"component": "/some/nuxt/app/pages/parent/index.vue",
@ -269,6 +260,7 @@ Array [
],
"chunkName": "pages/another_route/_id",
"component": "/some/nuxt/app/pages/another_route/_id.vue",
"name": "another_route-id",
"path": "/another_route/:id?",
"pathToRegexpOptions": Object {
"strict": true,
@ -283,6 +275,15 @@ Array [
"strict": true,
},
},
Object {
"chunkName": "pages/index",
"component": "/some/nuxt/app/pages/index.vue",
"name": "index",
"path": "/",
"pathToRegexpOptions": Object {
"strict": true,
},
},
Object {
"chunkName": "pages/_param",
"component": "/some/nuxt/app/pages/_param.vue",