fix(nuxt): end route param tokens manually (#19902)

This commit is contained in:
Daniel Roe 2023-04-03 10:56:44 +01:00 committed by GitHub
parent 8e9d7157a8
commit d190f743dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 11 deletions

View File

@ -101,7 +101,7 @@ function getRoutePath (tokens: SegmentToken[]): string {
(token.type === SegmentTokenType.optional
? `:${token.value}?`
: token.type === SegmentTokenType.dynamic
? `:${token.value}`
? `:${token.value}()`
: token.type === SegmentTokenType.catchall
? `:${token.value}(.*)*`
: encodePath(token.value))

View File

@ -64,13 +64,13 @@ describe('pages:generateRoutesFromFiles', () => {
output: [
{
name: 'parent-child',
path: '/parent/:child',
path: '/parent/:child()',
file: `${pagesDir}/parent/[child].vue`,
children: []
},
{
name: 'parent-child',
path: '/parent-:child',
path: '/parent-:child()',
file: `${pagesDir}/parent-[child].vue`,
children: []
}
@ -91,7 +91,7 @@ describe('pages:generateRoutesFromFiles', () => {
},
{
name: 'stories-id',
path: '/stories/:id',
path: '/stories/:id()',
file: `${pagesDir}/stories/[id].vue`,
children: []
}
@ -106,7 +106,7 @@ describe('pages:generateRoutesFromFiles', () => {
output: [
{
name: 'stories-id',
path: '/stories/:id',
path: '/stories/:id()',
file: `${pagesDir}/stories/[id].vue`,
children: []
},
@ -167,7 +167,7 @@ describe('pages:generateRoutesFromFiles', () => {
children: [],
name: 'slug',
file: 'pages/[slug].vue',
path: '/:slug'
path: '/:slug()'
},
{
children: [
@ -186,11 +186,11 @@ describe('pages:generateRoutesFromFiles', () => {
children: [],
name: 'bar',
file: 'pages/[bar]/index.vue',
path: '/:bar'
path: '/:bar()'
},
{
name: 'nonopt-slug',
path: '/nonopt/:slug',
path: '/nonopt/:slug()',
file: `${pagesDir}/nonopt/[slug].vue`,
children: []
},
@ -202,7 +202,7 @@ describe('pages:generateRoutesFromFiles', () => {
},
{
name: 'sub-route-slug',
path: '/:sub?/route-:slug',
path: '/:sub?/route-:slug()',
file: `${pagesDir}/[[sub]]/route-[slug].vue`,
children: []
}
@ -243,22 +243,29 @@ describe('pages:generateRoutesFromFiles', () => {
files: [
`${pagesDir}/[a1_1a].vue`,
`${pagesDir}/[b2.2b].vue`,
`${pagesDir}/[b2]_[2b].vue`,
`${pagesDir}/[[c3@3c]].vue`,
`${pagesDir}/[[d4-4d]].vue`
],
output: [
{
name: 'a1_1a',
path: '/:a1_1a',
path: '/:a1_1a()',
file: `${pagesDir}/[a1_1a].vue`,
children: []
},
{
name: 'b2.2b',
path: '/:b2.2b',
path: '/:b2.2b()',
file: `${pagesDir}/[b2.2b].vue`,
children: []
},
{
name: 'b2_2b',
path: '/:b2()_:2b()',
file: `${pagesDir}/[b2]_[2b].vue`,
children: []
},
{
name: 'c33c',
path: '/:c33c?',