From 904c4e57935d22690a8c63c424fef8c0df08223a Mon Sep 17 00:00:00 2001 From: Alexandre Chopin Date: Tue, 20 Dec 2016 17:30:43 +0100 Subject: [PATCH] add optional param by default --- lib/build/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/build/index.js b/lib/build/index.js index e81f968a2e..80cb7c37d0 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -229,8 +229,15 @@ function createRoutes (files, srcDir) { } function cleanChildrenRoutes (routes, isChild = false) { + let isOptional = true routes.forEach((route) => { route.path = (isChild) ? route.path.replace('/', '') : route.path + if (route.path === '') { + isOptional = false + } + if (isChild && isOptional && route.path.includes(':')) { + route.path += '?' + } if (route.children) { delete route.name route.children = cleanChildrenRoutes(route.children, true)