Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Router, matchPath } from "inferno-router";
// ensure we're using the exact code for default root match
const { computeMatch } = Router.prototype;
const matchRoutes = (routes, pathname, /*not public API*/ branch = []) => {
routes.some(route => {
const match = route.path
? matchPath(pathname, route)
: branch.length
? branch[branch.length - 1].match // use parent match
: computeMatch(pathname); // use default "root" match
if (match) {
branch.push({ route, match });
if (route.routes) {
matchRoutes(route.routes, pathname, branch);
}
}
it("should have routeTo() method", () => {
expect(Router.prototype.routeTo).toBeDefined();
});