Repository URL to install this package:
|
Version:
7.0.0-alpha.3 ▾
|
/**
* @see https://github.com/ReactTraining/react-router/tree/master/packages/react-router
* ^ changes for import
*/
import { matchPath, Router } from 'react-router'
function matchRoutes(routes, pathname, /*not public API*/ branch = []) {
routes.some(route => {
const match = route.path
? matchPath(pathname, route)
: branch.length
// use parent match
? branch[branch.length - 1].match
/** @todo typing here */
// use default "root" match
: Router.computeRootMatch(pathname)
if (match) {
branch.push({ route, match })
if (route.routes) {
matchRoutes(route.routes, pathname, branch)
}
}
return match
})
return branch
}
export default matchRoutes