Skip to content

Commit b9be2dc

Browse files
fix(ng2.pushState): Properly match urls when base path set
Closes #2745
1 parent 835f81c commit b9be2dc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ng2/location.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@ export class UIRouterLocation {
2727
let locSt = this.locationStrategy;
2828

2929
if (this.isHashBang) {
30+
loc.path = () =>
31+
splitOnHash(splitOnQuestionMark(locSt.path())[0])[0];
3032
loc.hash = () =>
3133
splitOnHash(splitOnHash(this.platformLocation.hash)[1])[1];
3234
} else {
35+
let basepath = locSt.getBaseHref();
36+
let basepathRegExp = new RegExp("^" + basepath);
37+
let replace = (basepath[basepath.length - 1] === '/') ? "/" : "";
38+
loc.path = () =>
39+
splitOnHash(splitOnQuestionMark(locSt.path())[0])[0].replace(basepathRegExp, replace);
3340
loc.hash = () =>
3441
splitOnHash(this.platformLocation.hash)[1];
3542
}
3643

37-
loc.path = () =>
38-
splitOnHash(splitOnQuestionMark(locSt.path())[0])[0];
3944

4045
loc.search = () => {
4146
let queryString = splitOnHash(splitOnQuestionMark(locSt.path())[1])[0];

0 commit comments

Comments
 (0)