Skip to content

Commit

Permalink
fix(router): getBaseUrl() to return correct URL for encodable chars
Browse files Browse the repository at this point in the history
decode fragment so path can be found and return encoded URL
  • Loading branch information
jagonalez committed May 4, 2017
1 parent ac6bf75 commit 0ef12f6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/navigation-instruction.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class NavigationInstruction {
* Gets the instruction's base URL, accounting for wildcard route parameters.
*/
getBaseUrl(): string {
let fragment = this.fragment;
let fragment = decodeURI(this.fragment);

if (fragment === '') {
let nonEmptyRoute = this.router.routes.find(route => {
Expand All @@ -175,7 +175,7 @@ export class NavigationInstruction {
}

if (!this.params) {
return fragment;
return encodeURI(fragment);
}

let wildcardName = this.getWildCardName();
Expand All @@ -185,8 +185,7 @@ export class NavigationInstruction {
return fragment;
}

path = encodeURI(path);
return fragment.substr(0, fragment.lastIndexOf(path));
return encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));
}

_commitChanges(waitToSwap: boolean) {
Expand Down

0 comments on commit 0ef12f6

Please sign in to comment.