fix(nuxt3): use path for uniqueness of routes when resolving (#3895)

This commit is contained in:
Kevin Marrec 2022-03-25 12:55:05 +01:00 committed by GitHub
parent e7b57fa34c
commit e34ed887f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 1 deletions

View File

@ -40,7 +40,7 @@ export async function resolvePagesRoutes (): Promise<NuxtPage[]> {
}) })
)).flat() )).flat()
return uniqueBy(allRoutes, 'name') return uniqueBy(allRoutes, 'path')
} }
export function generateRoutesFromFiles (files: string[], pagesDir: string): NuxtPage[] { export function generateRoutesFromFiles (files: string[], pagesDir: string): NuxtPage[] {

View File

@ -91,6 +91,16 @@ describe('pages', () => {
expect(html).toContain('foo: foobar') expect(html).toContain('foo: foobar')
expect(html).toContain('group: admin') expect(html).toContain('group: admin')
}) })
it('/parent', async () => {
const html = await $fetch('/parent')
expect(html).toContain('parent/index')
})
it('/another-parent', async () => {
const html = await $fetch('/another-parent')
expect(html).toContain('another-parent/index')
})
}) })
describe('navigate', () => { describe('navigate', () => {

View File

@ -0,0 +1,6 @@
<template>
<div>
another-parent
<NuxtPage />
</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div>
another-parent/index
</div>
</template>

6
test/fixtures/basic/pages/parent.vue vendored Normal file
View File

@ -0,0 +1,6 @@
<template>
<div>
parent
<NuxtPage />
</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div>
parent/index
</div>
</template>