Skip to content

Commit ca64573

Browse files
committed
fix: callback with fully resolved route name (after adding a route)
1 parent dd72875 commit ca64573

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

modules/RouteNode.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ export default class RouteNode {
145145
}
146146
}
147147

148-
if (originalRoute) cb(originalRoute);
148+
if (originalRoute) {
149+
const fullName = route.getParentSegments([ route ]).map((_) => _.name).join('.');
150+
cb({
151+
...originalRoute,
152+
name: fullName
153+
});
154+
}
149155

150156
return this;
151157
}

test/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ describe('RouteNode', function () {
4242

4343
node.add(routes, function(route) {
4444
i = i + 1;
45-
if (i === 1) route.should.equal(routeA);
46-
if (i === 2) route.should.equal(routeB);
45+
if (i === 1) route.should.eql(routeA);
46+
if (i === 2) route.should.eql(routeB);
4747
});
4848

4949
i.should.not.equal(0);
@@ -52,8 +52,8 @@ describe('RouteNode', function () {
5252

5353
var node = new RouteNode('', '', routes, function(route) {
5454
i = i + 1;
55-
if (i === 1) route.should.equal(routeA);
56-
if (i === 2) route.should.equal(routeB);
55+
if (i === 1) route.should.eql(routeA);
56+
if (i === 2) route.should.eql(routeB);
5757
});
5858

5959
i.should.not.equal(0);

0 commit comments

Comments
 (0)