From d6dadc6efcd8ea927c502377dc616474b6a24834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Thu, 9 Jul 2015 11:05:07 -0700 Subject: [PATCH] fix(router): fix broken `HashLocationStrategy` string issue for dart --- modules/angular2/src/router/hash_location_strategy.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/router/hash_location_strategy.ts b/modules/angular2/src/router/hash_location_strategy.ts index 09c58516c0..963f109f67 100644 --- a/modules/angular2/src/router/hash_location_strategy.ts +++ b/modules/angular2/src/router/hash_location_strategy.ts @@ -23,7 +23,12 @@ export class HashLocationStrategy extends LocationStrategy { path(): string { // the hash value is always prefixed with a `#` // and if it is empty then it will stay empty - return this._location.hash.substring(1); + var path = this._location.hash; + + // Dart will complain if a call to substring is + // executed with a position value that extends the + // length of string. + return path.length > 0 ? path.substring(1) : path; } pushState(state: any, title: string, url: string) {