@@ -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
@@ -632,18 +632,21 @@ function $LocationProvider(){
632
632
}
633
633
634
634
// Make relative links work in HTML5 mode for legacy browsers (or at least IE8 & 9)
635
- // The href should be a regular url e.g. /link/somewhere or link/somewhere or ../somewhere or somewhere#anchor or http://example.com/somewhere
635
+ // The href should be a regular url e.g. /link/somewhere or link/somewhere or ../somewhere or somewhere#anchor or http://example.com/somewhere
636
636
if ( LocationMode === LocationHashbangInHtml5Url ) {
637
637
// get the actual href attribute - see http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
638
638
// TODO check browser is in standards mode
639
639
var href = elm [ 0 ] . getAttribute ( 'href' ) ;
640
-
641
- if ( href . indexOf ( '://' == - 1 ) ) { // Ignore absolute URLs
640
+
641
+ if ( href . indexOf ( '://' == - 1 ) ) { // Ignore absolute URLs
642
642
if ( href [ 0 ] == '/' ) {
643
643
// absolute path - replace old path
644
644
absHref = serverBase ( absHref ) + href ;
645
+ } else if ( href [ 0 ] == '#' ) {
646
+ // local anchor
647
+ absHref = serverBase ( absHref ) + $location . path ( ) + href ;
645
648
} else {
646
- // relative path - join with current path
649
+ // relative path - join with current path
647
650
var stack = $location . path ( ) . split ( "/" ) ,
648
651
parts = href . split ( "/" ) ;
649
652
stack . pop ( ) ; // remove top file
@@ -657,7 +660,7 @@ function $LocationProvider(){
657
660
}
658
661
absHref = serverBase ( absHref ) + stack . join ( "/" ) ;
659
662
}
660
- }
663
+ }
661
664
}
662
665
663
666
var rewrittenUrl = $location . $$rewrite ( absHref ) ;
0 commit comments