From c177d889a2e17f846c181f3431478e83a3817a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Wed, 8 Jul 2015 15:08:17 -0700 Subject: [PATCH] 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 --- modules/angular2/src/router/hash_location_strategy.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/router/hash_location_strategy.ts b/modules/angular2/src/router/hash_location_strategy.ts index 9d3540448b..ffa4da7276 100644 --- a/modules/angular2/src/router/hash_location_strategy.ts +++ b/modules/angular2/src/router/hash_location_strategy.ts @@ -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);