From 2eb42876a28d009ccd0b673a9457ef19a3e68423 Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Tue, 4 Aug 2020 17:33:00 +0430 Subject: [PATCH] fix(utils): remove optional params in routes ending with `index` (#7845) --- packages/utils/src/route.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/utils/src/route.js b/packages/utils/src/route.js index f3de9ae83d..eaa31df804 100644 --- a/packages/utils/src/route.js +++ b/packages/utils/src/route.js @@ -54,6 +54,9 @@ function cleanChildrenRoutes (routes, isChild = false, routeNameSplitter = '-', routes.forEach((route) => { route.path = isChild ? route.path.replace('/', '') : route.path if (route.path.includes('?')) { + if (route.name.endsWith(`${routeNameSplitter}index`)) { + route.path = route.path.replace(/\?$/, '') + } const names = route.name.replace(regExpParentRouteName, '').split(routeNameSplitter) const paths = route.path.split('/') if (!isChild) {