Socket
Socket
Sign inDemoInstall

@nuxt/utils

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxt/utils - npm Package Compare versions

Comparing version 2.13.3 to 2.14.0

44

dist/utils.js
/*!
* @nuxt/utils v2.13.3 (c) 2016-2020
* @nuxt/utils v2.14.0 (c) 2016-2020

@@ -1521,2 +1521,17 @@ * - All the amazing contributors

const routeChildren = function (route) {
const hasChildWithEmptyPath = route.children.some(child => child.path === '');
if (hasChildWithEmptyPath) {
return route.children
}
return [
// Add default child to render parent page
{
...route,
children: undefined
},
...route.children
]
};
const flatRoutes = function flatRoutes (router, fileName = '', routes = []) {

@@ -1527,10 +1542,6 @@ router.forEach((r) => {

}
const route = `${fileName}${r.path}/`.replace(/\/+/g, '/');
if (r.children) {
if (fileName === '' && r.path === '/') {
routes.push('/');
}
return flatRoutes(r.children, fileName + r.path + '/', routes)
return flatRoutes(routeChildren(r), route, routes)
}
fileName = fileName.replace(/\/+/g, '/');

@@ -1540,6 +1551,6 @@ // if child path is already absolute, do not make any concatenations

routes.push(r.path);
} else if (r.path === '' && fileName[fileName.length - 1] === '/') {
routes.push(fileName.slice(0, -1) + r.path);
} else if (route !== '/' && route[route.length - 1] === '/') {
routes.push(route.slice(0, -1));
} else {
routes.push(fileName + r.path);
routes.push(route);
}

@@ -1550,3 +1561,3 @@ });

function cleanChildrenRoutes (routes, isChild = false, routeNameSplitter = '-') {
function cleanChildrenRoutes (routes, isChild = false, routeNameSplitter = '-', trailingSlash) {
let start = -1;

@@ -1589,6 +1600,11 @@ const regExpIndex = new RegExp(`${routeNameSplitter}index$`);

if (route.children) {
if (route.children.find(child => child.path === '')) {
const indexRoutePath = trailingSlash === false ? '/' : '';
const defaultChildRoute = route.children.find(child => child.path === indexRoutePath);
if (defaultChildRoute) {
if (trailingSlash === false) {
defaultChildRoute.name = route.name;
}
delete route.name;
}
route.children = cleanChildrenRoutes(route.children, true, routeNameSplitter);
route.children = cleanChildrenRoutes(route.children, true, routeNameSplitter, trailingSlash);
}

@@ -1710,3 +1726,3 @@ });

sortRoutes(routes);
return cleanChildrenRoutes(routes, false, routeNameSplitter)
return cleanChildrenRoutes(routes, false, routeNameSplitter, trailingSlash)
};

@@ -1713,0 +1729,0 @@

{
"name": "@nuxt/utils",
"version": "2.13.3",
"version": "2.14.0",
"repository": "nuxt/nuxt.js",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc