mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): remove undefined keys in route object (#25667)
This commit is contained in:
parent
e317349688
commit
4f3391fc0a
@ -414,6 +414,12 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
||||
redirect: serializeRouteValue(page.redirect),
|
||||
}
|
||||
|
||||
for (const key of ['path', 'name', 'meta', 'alias', 'redirect'] satisfies NormalizedRouteKeys) {
|
||||
if (route[key] === undefined) {
|
||||
delete route[key]
|
||||
}
|
||||
}
|
||||
|
||||
if (page.children?.length) {
|
||||
route.children = normalizeRoutes(page.children, metaImports, overrideMeta).routes
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
"meta": "{"hello":"world"}",
|
||||
"name": ""home"",
|
||||
"path": ""/"",
|
||||
"redirect": undefined,
|
||||
},
|
||||
],
|
||||
"should allow pages with `:` in their path": [
|
||||
|
@ -14,7 +14,6 @@
|
||||
"meta": "{"hello":"world"}",
|
||||
"name": ""home"",
|
||||
"path": ""/"",
|
||||
"redirect": undefined,
|
||||
},
|
||||
],
|
||||
"should allow pages with `:` in their path": [
|
||||
|
8
test/fixtures/basic/nuxt.config.ts
vendored
8
test/fixtures/basic/nuxt.config.ts
vendored
@ -100,6 +100,14 @@ export default defineNuxtConfig({
|
||||
}))
|
||||
addBuildPlugin(plugin)
|
||||
},
|
||||
function (_options, nuxt) {
|
||||
nuxt.hook('pages:extend', pages => {
|
||||
pages.push({
|
||||
path: '/manual-redirect',
|
||||
redirect: '/',
|
||||
})
|
||||
})
|
||||
},
|
||||
function (_options, nuxt) {
|
||||
const routesToDuplicate = ['/async-parent', '/fixed-keyed-child-parent', '/keyed-child-parent', '/with-layout', '/with-layout2']
|
||||
const stripLayout = (page: NuxtPage): NuxtPage => ({
|
||||
|
Loading…
Reference in New Issue
Block a user