@@ -875,10 +875,19 @@ describe('$location', function() {
875
875
} ) ;
876
876
}
877
877
878
- function initBrowser ( ) {
878
+ function initBrowser ( atRoot , noBase ) {
879
879
return function ( $browser ) {
880
- $browser . url ( 'http://host.com/base' ) ;
881
- $browser . $$baseHref = '/base/index.html' ;
880
+ if ( atRoot ) {
881
+ $browser . url ( 'http://host.com/' ) ;
882
+ if ( ! noBase ) {
883
+ $browser . $$baseHref = '/' ;
884
+ }
885
+ } else {
886
+ $browser . url ( 'http://host.com/base' ) ;
887
+ if ( ! noBase ) {
888
+ $browser . $$baseHref = '/base/index.html' ;
889
+ }
890
+ }
882
891
} ;
883
892
}
884
893
@@ -1234,6 +1243,34 @@ describe('$location', function() {
1234
1243
} ) ;
1235
1244
1236
1245
1246
+ it ( 'should replace path while on root when relative link begins with "/" and history enabled on old browser' , function ( ) {
1247
+ configureService ( '/link' , true , false , true ) ;
1248
+ inject (
1249
+ initBrowser ( true ) ,
1250
+ initLocation ( ) ,
1251
+ function ( $browser , $location ) {
1252
+ $location . path ( '/some' ) ;
1253
+ browserTrigger ( link , 'click' ) ;
1254
+ expectRewriteTo ( $browser , 'http://host.com/#!/link' ) ;
1255
+ }
1256
+ ) ;
1257
+ } ) ;
1258
+
1259
+
1260
+ it ( 'should not rewrite when relative link begins with "/" and there is no base tag and history enabled on old browser' , function ( ) {
1261
+ configureService ( '/link' , true , false , true ) ;
1262
+ inject (
1263
+ initBrowser ( false , true ) ,
1264
+ initLocation ( ) ,
1265
+ function ( $browser , $location ) {
1266
+ $location . path ( '/some' ) ;
1267
+ browserTrigger ( link , 'click' ) ;
1268
+ expectNoRewrite ( $browser ) ;
1269
+ }
1270
+ ) ;
1271
+ } ) ;
1272
+
1273
+
1237
1274
it ( 'should not rewrite when relative link begins with "/" and history enabled on old browser' , function ( ) {
1238
1275
configureService ( '/other_base/link' , true , false , true ) ;
1239
1276
inject (
0 commit comments