@nuxt/utils
Advanced tools
Comparing version 2.14.0 to 2.14.1
/*! | ||
* @nuxt/utils v2.14.0 (c) 2016-2020 | ||
* @nuxt/utils v2.14.1 (c) 2016-2020 | ||
@@ -1558,12 +1558,9 @@ * - All the amazing contributors | ||
function cleanChildrenRoutes (routes, isChild = false, routeNameSplitter = '-', trailingSlash) { | ||
let start = -1; | ||
function cleanChildrenRoutes (routes, isChild = false, routeNameSplitter = '-', trailingSlash, parentRouteName) { | ||
const regExpIndex = new RegExp(`${routeNameSplitter}index$`); | ||
const regExpParentRouteName = new RegExp(`^${parentRouteName}${routeNameSplitter}`); | ||
const routesIndex = []; | ||
routes.forEach((route) => { | ||
if (regExpIndex.test(route.name) || route.name === 'index') { | ||
// Save indexOf 'index' key in name | ||
const res = route.name.split(routeNameSplitter); | ||
const s = res.indexOf('index'); | ||
start = start === -1 || s < start ? s : start; | ||
const res = route.name.replace(regExpParentRouteName, '').split(routeNameSplitter); | ||
routesIndex.push(res); | ||
@@ -1575,3 +1572,6 @@ } | ||
if (route.path.includes('?')) { | ||
const names = route.name.split(routeNameSplitter); | ||
if (route.name.endsWith(`${routeNameSplitter}index`)) { | ||
route.path = route.path.replace(/\?$/, ''); | ||
} | ||
const names = route.name.replace(regExpParentRouteName, '').split(routeNameSplitter); | ||
const paths = route.path.split('/'); | ||
@@ -1582,3 +1582,3 @@ if (!isChild) { | ||
routesIndex.forEach((r) => { | ||
const i = r.indexOf('index') - start; // children names | ||
const i = r.indexOf('index'); | ||
if (i < paths.length) { | ||
@@ -1601,2 +1601,3 @@ for (let a = 0; a <= i; a++) { | ||
const defaultChildRoute = route.children.find(child => child.path === indexRoutePath); | ||
const routeName = route.name; | ||
if (defaultChildRoute) { | ||
@@ -1608,3 +1609,3 @@ if (trailingSlash === false) { | ||
} | ||
route.children = cleanChildrenRoutes(route.children, true, routeNameSplitter, trailingSlash); | ||
route.children = cleanChildrenRoutes(route.children, true, routeNameSplitter, trailingSlash, routeName); | ||
} | ||
@@ -1611,0 +1612,0 @@ }); |
{ | ||
"name": "@nuxt/utils", | ||
"version": "2.14.0", | ||
"version": "2.14.1", | ||
"repository": "nuxt/nuxt.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54631
1835