mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
add optional param by default
This commit is contained in:
parent
4c3f7abb1d
commit
904c4e5793
@ -229,8 +229,15 @@ function createRoutes (files, srcDir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanChildrenRoutes (routes, isChild = false) {
|
function cleanChildrenRoutes (routes, isChild = false) {
|
||||||
|
let isOptional = true
|
||||||
routes.forEach((route) => {
|
routes.forEach((route) => {
|
||||||
route.path = (isChild) ? route.path.replace('/', '') : route.path
|
route.path = (isChild) ? route.path.replace('/', '') : route.path
|
||||||
|
if (route.path === '') {
|
||||||
|
isOptional = false
|
||||||
|
}
|
||||||
|
if (isChild && isOptional && route.path.includes(':')) {
|
||||||
|
route.path += '?'
|
||||||
|
}
|
||||||
if (route.children) {
|
if (route.children) {
|
||||||
delete route.name
|
delete route.name
|
||||||
route.children = cleanChildrenRoutes(route.children, true)
|
route.children = cleanChildrenRoutes(route.children, true)
|
||||||
|
Loading…
Reference in New Issue
Block a user