@@ -274,7 +274,7 @@ function LocationHashbangInHtml5Url(appBase, hashPrefix) {
274
274
hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
275
275
276
276
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 '#'
278
278
this . $$absUrl = appBase + hashPrefix + this . $$url ;
279
279
} ;
280
280
@@ -653,18 +653,21 @@ function $LocationProvider(){
653
653
}
654
654
655
655
// 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
657
657
if ( LocationMode === LocationHashbangInHtml5Url ) {
658
658
// get the actual href attribute - see http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
659
659
// TODO check browser is in standards mode
660
660
var href = elm [ 0 ] . getAttribute ( 'href' ) ;
661
-
662
- if ( href . indexOf ( '://' == - 1 ) ) { // Ignore absolute URLs
661
+
662
+ if ( href . indexOf ( '://' == - 1 ) ) { // Ignore absolute URLs
663
663
if ( href [ 0 ] == '/' ) {
664
664
// absolute path - replace old path
665
665
absHref = serverBase ( absHref ) + href ;
666
+ } else if ( href [ 0 ] == '#' ) {
667
+ // local anchor
668
+ absHref = serverBase ( absHref ) + $location . path ( ) + href ;
666
669
} else {
667
- // relative path - join with current path
670
+ // relative path - join with current path
668
671
var stack = $location . path ( ) . split ( "/" ) ,
669
672
parts = href . split ( "/" ) ;
670
673
stack . pop ( ) ; // remove top file
@@ -678,7 +681,7 @@ function $LocationProvider(){
678
681
}
679
682
absHref = serverBase ( absHref ) + stack . join ( "/" ) ;
680
683
}
681
- }
684
+ }
682
685
}
683
686
684
687
var rewrittenUrl = $location . $$rewrite ( absHref ) ;
0 commit comments