Skip to content

Commit 4e4ccad

Browse files
committed
fix(router): don't try to find route with empty path
1 parent ce58827 commit 4e4ccad

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/modules/router/router-class.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ class Router extends Framework7Class {
649649
if (matchingRoute) return;
650650
const keys = [];
651651

652-
const pathsToMatch = [route.path];
652+
const pathsToMatch = [route.path || '/'];
653653
if (route.alias) {
654654
if (typeof route.alias === 'string') pathsToMatch.push(route.alias);
655655
else if (Array.isArray(route.alias)) {
@@ -662,7 +662,7 @@ class Router extends Framework7Class {
662662
let matched;
663663
pathsToMatch.forEach((pathToMatch) => {
664664
if (matched) return;
665-
matched = pathToRegexp(pathToMatch, keys).exec(path);
665+
matched = pathToRegexp(pathToMatch, keys).exec(path || '/');
666666
});
667667

668668
if (matched) {
@@ -678,7 +678,7 @@ class Router extends Framework7Class {
678678

679679
let parentPath;
680680
if (route.parentPath) {
681-
parentPath = path
681+
parentPath = (path || '/')
682682
.split('/')
683683
.slice(0, route.parentPath.split('/').length - 1)
684684
.join('/');
@@ -689,7 +689,7 @@ class Router extends Framework7Class {
689689
hash,
690690
params,
691691
url,
692-
path,
692+
path: path || '/',
693693
parentPath,
694694
route,
695695
name: route.name,

0 commit comments

Comments
 (0)