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
This commit is contained in:
Matias Niemelä 2015-07-08 15:08:17 -07:00
parent 3f7ebde037
commit c177d889a2
1 changed files with 5 additions and 1 deletions

View File

@ -20,7 +20,11 @@ export class HashLocationStrategy extends LocationStrategy {
getBaseHref(): string { return ''; }
path(): string { return this._location.hash; }
path(): string {
// the hash value is always prefixed with a `#`
// and if it is empty then it will stay empty
return this._location.hash.substr(1);
}
pushState(state: any, title: string, url: string) {
this._history.pushState(state, title, '#' + url);