fix(router): fix broken `HashLocationStrategy` string issue for dart

This commit is contained in:
Matias Niemelä 2015-07-09 11:05:07 -07:00
parent 546a8f9218
commit d6dadc6efc
1 changed files with 6 additions and 1 deletions

View File

@ -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) {