Skip to content

Commit 712dcd0

Browse files
Richard Collinscaitp
Richard Collins
authored andcommitted
Parse anchors in IE9
1 parent e4e6176 commit 712dcd0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/ng/location.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function LocationHashbangInHtml5Url(appBase, hashPrefix) {
274274
hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
275275

276276
this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
277-
// include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#'
277+
// include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#'
278278
this.$$absUrl = appBase + hashPrefix + this.$$url;
279279
};
280280

@@ -653,18 +653,21 @@ function $LocationProvider(){
653653
}
654654

655655
// Make relative links work in HTML5 mode for legacy browsers (or at least IE8 & 9)
656-
// The href should be a regular url e.g. /link/somewhere or link/somewhere or ../somewhere or somewhere#anchor or http://example.com/somewhere
656+
// The href should be a regular url e.g. /link/somewhere or link/somewhere or ../somewhere or somewhere#anchor or http://example.com/somewhere
657657
if (LocationMode === LocationHashbangInHtml5Url) {
658658
// get the actual href attribute - see http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
659659
// TODO check browser is in standards mode
660660
var href = elm[0].getAttribute('href');
661-
662-
if (href.indexOf('://' == -1)) { // Ignore absolute URLs
661+
662+
if (href.indexOf('://' == -1)) { // Ignore absolute URLs
663663
if (href[0] == '/') {
664664
// absolute path - replace old path
665665
absHref = serverBase(absHref) + href;
666+
} else if (href[0] == '#') {
667+
// local anchor
668+
absHref = serverBase(absHref) + $location.path() + href;
666669
} else {
667-
// relative path - join with current path
670+
// relative path - join with current path
668671
var stack = $location.path().split("/"),
669672
parts = href.split("/");
670673
stack.pop(); // remove top file
@@ -678,7 +681,7 @@ function $LocationProvider(){
678681
}
679682
absHref = serverBase(absHref) + stack.join("/");
680683
}
681-
}
684+
}
682685
}
683686

684687
var rewrittenUrl = $location.$$rewrite(absHref);

0 commit comments

Comments
 (0)