Skip to content

Commit d6dadc6

Browse files
committed
fix(router): fix broken HashLocationStrategy string issue for dart
1 parent 546a8f9 commit d6dadc6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/angular2/src/router/hash_location_strategy.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ export class HashLocationStrategy extends LocationStrategy {
2323
path(): string {
2424
// the hash value is always prefixed with a `#`
2525
// and if it is empty then it will stay empty
26-
return this._location.hash.substring(1);
26+
var path = this._location.hash;
27+
28+
// Dart will complain if a call to substring is
29+
// executed with a position value that extends the
30+
// length of string.
31+
return path.length > 0 ? path.substring(1) : path;
2732
}
2833

2934
pushState(state: any, title: string, url: string) {

0 commit comments

Comments
 (0)