From b9be2dca1a239ebc2e03662fb1e5a4bc41d28b5f Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Fri, 13 May 2016 12:36:16 -0500 Subject: [PATCH] fix(ng2.pushState): Properly match urls when base path set Closes #2745 --- src/ng2/location.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ng2/location.ts b/src/ng2/location.ts index 3f2c88647..2115f5628 100644 --- a/src/ng2/location.ts +++ b/src/ng2/location.ts @@ -27,15 +27,20 @@ export class UIRouterLocation { let locSt = this.locationStrategy; if (this.isHashBang) { + loc.path = () => + splitOnHash(splitOnQuestionMark(locSt.path())[0])[0]; loc.hash = () => splitOnHash(splitOnHash(this.platformLocation.hash)[1])[1]; } else { + let basepath = locSt.getBaseHref(); + let basepathRegExp = new RegExp("^" + basepath); + let replace = (basepath[basepath.length - 1] === '/') ? "/" : ""; + loc.path = () => + splitOnHash(splitOnQuestionMark(locSt.path())[0])[0].replace(basepathRegExp, replace); loc.hash = () => splitOnHash(this.platformLocation.hash)[1]; } - loc.path = () => - splitOnHash(splitOnQuestionMark(locSt.path())[0])[0]; loc.search = () => { let queryString = splitOnHash(splitOnQuestionMark(locSt.path())[1])[0];