mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): do not allow catchalls to have child routes (#6257)
This commit is contained in:
parent
5dc864d7bc
commit
96cfe01973
@ -74,7 +74,8 @@ export function generateRoutesFromFiles (files: string[], pagesDir: string): Nux
|
||||
route.name += (route.name && '-') + segmentName
|
||||
|
||||
// ex: parent.vue + parent/child.vue
|
||||
const child = parent.find(parentRoute => parentRoute.name === route.name)
|
||||
const child = parent.find(parentRoute => parentRoute.name === route.name && !parentRoute.path.endsWith('(.*)*'))
|
||||
|
||||
if (child) {
|
||||
parent = child.children
|
||||
route.path = ''
|
||||
|
@ -67,6 +67,48 @@ describe('pages:generateRoutesFromFiles', () => {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
description: 'should generate correct id for catchall (order 1)',
|
||||
files: [
|
||||
`${pagesDir}/[...stories].vue`,
|
||||
`${pagesDir}/stories/[id].vue`
|
||||
],
|
||||
output: [
|
||||
{
|
||||
name: 'stories',
|
||||
path: '/:stories(.*)*',
|
||||
file: `${pagesDir}/[...stories].vue`,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
name: 'stories-id',
|
||||
path: '/stories/:id',
|
||||
file: `${pagesDir}/stories/[id].vue`,
|
||||
children: []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
description: 'should generate correct id for catchall (order 2)',
|
||||
files: [
|
||||
`${pagesDir}/stories/[id].vue`,
|
||||
`${pagesDir}/[...stories].vue`
|
||||
],
|
||||
output: [
|
||||
{
|
||||
name: 'stories-id',
|
||||
path: '/stories/:id',
|
||||
file: `${pagesDir}/stories/[id].vue`,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
name: 'stories',
|
||||
path: '/:stories(.*)*',
|
||||
file: `${pagesDir}/[...stories].vue`,
|
||||
children: []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
description: 'should generate correct route for snake_case file',
|
||||
files: [
|
||||
|
Loading…
Reference in New Issue
Block a user