X Tutup
Skip to content

Commit c177d88

Browse files
committed
fix(router): ensure that page refresh with hash URLs works
This patch fixes the `HashLocationStrategy` to always return a string path value without a hash symbol as the starting value. Closes #2920
1 parent 3f7ebde commit c177d88

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

modules/angular2/src/router/hash_location_strategy.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ export class HashLocationStrategy extends LocationStrategy {
2020

2121
getBaseHref(): string { return ''; }
2222

23-
path(): string { return this._location.hash; }
23+
path(): string {
24+
// the hash value is always prefixed with a `#`
25+
// and if it is empty then it will stay empty
26+
return this._location.hash.substr(1);
27+
}
2428

2529
pushState(state: any, title: string, url: string) {
2630
this._history.pushState(state, title, '#' + url);

0 commit comments

Comments
 (0)
X Tutup