mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-19 01:45:53 +00:00
fix(nuxt): end route param tokens manually (#19902)
This commit is contained in:
parent
8e9d7157a8
commit
d190f743dc
@ -101,7 +101,7 @@ function getRoutePath (tokens: SegmentToken[]): string {
|
|||||||
(token.type === SegmentTokenType.optional
|
(token.type === SegmentTokenType.optional
|
||||||
? `:${token.value}?`
|
? `:${token.value}?`
|
||||||
: token.type === SegmentTokenType.dynamic
|
: token.type === SegmentTokenType.dynamic
|
||||||
? `:${token.value}`
|
? `:${token.value}()`
|
||||||
: token.type === SegmentTokenType.catchall
|
: token.type === SegmentTokenType.catchall
|
||||||
? `:${token.value}(.*)*`
|
? `:${token.value}(.*)*`
|
||||||
: encodePath(token.value))
|
: encodePath(token.value))
|
||||||
|
@ -64,13 +64,13 @@ describe('pages:generateRoutesFromFiles', () => {
|
|||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
name: 'parent-child',
|
name: 'parent-child',
|
||||||
path: '/parent/:child',
|
path: '/parent/:child()',
|
||||||
file: `${pagesDir}/parent/[child].vue`,
|
file: `${pagesDir}/parent/[child].vue`,
|
||||||
children: []
|
children: []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'parent-child',
|
name: 'parent-child',
|
||||||
path: '/parent-:child',
|
path: '/parent-:child()',
|
||||||
file: `${pagesDir}/parent-[child].vue`,
|
file: `${pagesDir}/parent-[child].vue`,
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ describe('pages:generateRoutesFromFiles', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'stories-id',
|
name: 'stories-id',
|
||||||
path: '/stories/:id',
|
path: '/stories/:id()',
|
||||||
file: `${pagesDir}/stories/[id].vue`,
|
file: `${pagesDir}/stories/[id].vue`,
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ describe('pages:generateRoutesFromFiles', () => {
|
|||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
name: 'stories-id',
|
name: 'stories-id',
|
||||||
path: '/stories/:id',
|
path: '/stories/:id()',
|
||||||
file: `${pagesDir}/stories/[id].vue`,
|
file: `${pagesDir}/stories/[id].vue`,
|
||||||
children: []
|
children: []
|
||||||
},
|
},
|
||||||
@ -167,7 +167,7 @@ describe('pages:generateRoutesFromFiles', () => {
|
|||||||
children: [],
|
children: [],
|
||||||
name: 'slug',
|
name: 'slug',
|
||||||
file: 'pages/[slug].vue',
|
file: 'pages/[slug].vue',
|
||||||
path: '/:slug'
|
path: '/:slug()'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: [
|
children: [
|
||||||
@ -186,11 +186,11 @@ describe('pages:generateRoutesFromFiles', () => {
|
|||||||
children: [],
|
children: [],
|
||||||
name: 'bar',
|
name: 'bar',
|
||||||
file: 'pages/[bar]/index.vue',
|
file: 'pages/[bar]/index.vue',
|
||||||
path: '/:bar'
|
path: '/:bar()'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'nonopt-slug',
|
name: 'nonopt-slug',
|
||||||
path: '/nonopt/:slug',
|
path: '/nonopt/:slug()',
|
||||||
file: `${pagesDir}/nonopt/[slug].vue`,
|
file: `${pagesDir}/nonopt/[slug].vue`,
|
||||||
children: []
|
children: []
|
||||||
},
|
},
|
||||||
@ -202,7 +202,7 @@ describe('pages:generateRoutesFromFiles', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'sub-route-slug',
|
name: 'sub-route-slug',
|
||||||
path: '/:sub?/route-:slug',
|
path: '/:sub?/route-:slug()',
|
||||||
file: `${pagesDir}/[[sub]]/route-[slug].vue`,
|
file: `${pagesDir}/[[sub]]/route-[slug].vue`,
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
@ -243,22 +243,29 @@ describe('pages:generateRoutesFromFiles', () => {
|
|||||||
files: [
|
files: [
|
||||||
`${pagesDir}/[a1_1a].vue`,
|
`${pagesDir}/[a1_1a].vue`,
|
||||||
`${pagesDir}/[b2.2b].vue`,
|
`${pagesDir}/[b2.2b].vue`,
|
||||||
|
`${pagesDir}/[b2]_[2b].vue`,
|
||||||
`${pagesDir}/[[c3@3c]].vue`,
|
`${pagesDir}/[[c3@3c]].vue`,
|
||||||
`${pagesDir}/[[d4-4d]].vue`
|
`${pagesDir}/[[d4-4d]].vue`
|
||||||
],
|
],
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
name: 'a1_1a',
|
name: 'a1_1a',
|
||||||
path: '/:a1_1a',
|
path: '/:a1_1a()',
|
||||||
file: `${pagesDir}/[a1_1a].vue`,
|
file: `${pagesDir}/[a1_1a].vue`,
|
||||||
children: []
|
children: []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'b2.2b',
|
name: 'b2.2b',
|
||||||
path: '/:b2.2b',
|
path: '/:b2.2b()',
|
||||||
file: `${pagesDir}/[b2.2b].vue`,
|
file: `${pagesDir}/[b2.2b].vue`,
|
||||||
children: []
|
children: []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'b2_2b',
|
||||||
|
path: '/:b2()_:2b()',
|
||||||
|
file: `${pagesDir}/[b2]_[2b].vue`,
|
||||||
|
children: []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'c33c',
|
name: 'c33c',
|
||||||
path: '/:c33c?',
|
path: '/:c33c?',
|
||||||
|
Loading…
Reference in New Issue
Block a user