From 3f58560eea2a8cf075d3265dabcf3621e02f76e6 Mon Sep 17 00:00:00 2001 From: Snir Shechter Date: Sun, 16 Jun 2019 20:07:44 +0300 Subject: [PATCH] feat: add router data to each route in the filter function fix #69 --- lib/routes.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/routes.js b/lib/routes.js index aec5426..aa5bd51 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -11,7 +11,7 @@ function excludeRoutes(patterns, routes) { patterns.forEach(pattern => { const minimatch = new Minimatch(pattern) minimatch.negate = true - routes = routes.filter(route => minimatch.match(route)) + routes = routes.filter(route => minimatch.match(route.url)) }) return routes } @@ -24,7 +24,7 @@ function excludeRoutes(patterns, routes) { */ function getStaticRoutes(router) { // Get all static routes and ignore dynamic routes - return flattenRoutes(router).filter(route => !route.includes(':') && !route.includes('*')) + return flattenRoutes(router).filter(route => !route.url.includes(':') && !route.url.includes('*')) } /** @@ -41,7 +41,10 @@ function flattenRoutes(router, path = '', routes = []) { flattenRoutes(route.children, path + route.path + '/', routes) } if (route.path !== '') { - routes.push(path + route.path) + routes.push({ + ...route, + url: path + route.path + }) } }) return routes