Skip to content

Commit

Permalink
feat: add router data to each route in the filter function
Browse files Browse the repository at this point in the history
fix #69
  • Loading branch information
Snir Shechter authored and NicoPennec committed Nov 18, 2019
1 parent 77a28c9 commit 3f58560
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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('*'))
}

/**
Expand All @@ -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
Expand Down

0 comments on commit 3f58560

Please sign in to comment.