Skip to content

Commit 525b79e

Browse files
committed
fix: bug when matching path of node with children
1 parent 271739b commit 525b79e

4 files changed

Lines changed: 4 additions & 3 deletions

File tree

dist/commonjs/route-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ var RouteNode = (function () {
111111
// Remove consumed segment from path
112112
var remainingPath = pathSegment.replace(child.parser.build(match), '');
113113
// If fully matched
114-
if (!remainingPath.length && !child.children.length) {
114+
if (!remainingPath.length) {
115115
return {
116116
v: segments
117117
};

dist/umd/route-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
// Remove consumed segment from path
119119
var remainingPath = pathSegment.replace(child.parser.build(match), '');
120120
// If fully matched
121-
if (!remainingPath.length && !child.children.length) {
121+
if (!remainingPath.length) {
122122
return {
123123
v: segments
124124
};

modules/RouteNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class RouteNode {
7474
// Remove consumed segment from path
7575
let remainingPath = pathSegment.replace(child.parser.build(match), '')
7676
// If fully matched
77-
if (!remainingPath.length && !child.children.length) {
77+
if (!remainingPath.length) {
7878
return segments
7979
}
8080
// If no children to match against but unmatched path left

test/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ describe('RouteNode', function () {
107107
it('should find a nested route by matching a path', function () {
108108
var node = getRoutes();
109109
// Building paths
110+
node.matchPath('/users').should.eql({name: 'users', params: {}});
110111
node.matchPath('/users/view/1').should.eql({name: 'users.view', params: {id: '1'}});
111112
node.matchPath('/users/profile/1').should.be.false;
112113
node.matchPath('/users/view/profile/1').should.be.false;

0 commit comments

Comments
 (0)