diff --git a/src/routing/Router.ts b/src/routing/Router.ts index 2cd4a4a8a..4e542af01 100644 --- a/src/routing/Router.ts +++ b/src/routing/Router.ts @@ -365,7 +365,7 @@ export class Router extends Evented<{ nav: NavEvent; route: RouteEvent; outlet: Object.keys(params).forEach((paramKey) => { redirect = redirect.replace(`{${paramKey}}`, params[paramKey]); }); - this.setPath(redirect); + this.replacePath(redirect); return; } if (matchedRoute.type === 'partial') { diff --git a/tests/routing/unit/Router.ts b/tests/routing/unit/Router.ts index 05b95d562..93c65b4c8 100644 --- a/tests/routing/unit/Router.ts +++ b/tests/routing/unit/Router.ts @@ -711,7 +711,6 @@ describe('Router', () => { defaultParams: { param: 'default-param' }, - defaultRoute: true, children: [ { path: 'bar', @@ -723,8 +722,14 @@ describe('Router', () => { ], { HistoryManager } ); + + const setPathSpy = sinon.spy(router, 'setPath'); + const replacePathSpy = sinon.spy(router, 'replacePath'); + router.setPath('foo/param'); + assert.isTrue(setPathSpy.calledOnce); const contextMap = router.getOutlet('bar'); assert.isOk(contextMap); + assert.isTrue(replacePathSpy.calledOnce); assert.strictEqual(contextMap!.size, 1); }); });