@@ -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 = '/index.html' ;
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
@@ -1206,8 +1215,36 @@ describe('$location', function() {
1206
1215
} ) ;
1207
1216
1208
1217
1209
- it ( 'should replace current path when link begins with "/" and history disabled ' , function ( ) {
1218
+ it ( 'should replace current path when link begins with "/" and app is on root and history enabled on old browser ' , function ( ) {
1210
1219
configureService ( '/link' , true , false , true ) ;
1220
+ inject (
1221
+ initBrowser ( true ) ,
1222
+ initLocation ( ) ,
1223
+ function ( $browser , $location ) {
1224
+ $location . path ( '/some' ) ;
1225
+ browserTrigger ( link , 'click' ) ;
1226
+ expectRewriteTo ( $browser , 'http://host.com/index.html#!/link' ) ;
1227
+ }
1228
+ ) ;
1229
+ } ) ;
1230
+
1231
+
1232
+ it ( 'should replace current path when relative link begins with "/base/" and history enabled on old browser' , function ( ) {
1233
+ configureService ( '/base/link' , true , false , true ) ;
1234
+ inject (
1235
+ initBrowser ( ) ,
1236
+ initLocation ( ) ,
1237
+ function ( $browser , $location ) {
1238
+ $location . path ( '/some' ) ;
1239
+ browserTrigger ( link , 'click' ) ;
1240
+ expectRewriteTo ( $browser , 'http://host.com/base/index.html#!/link' ) ;
1241
+ }
1242
+ ) ;
1243
+ } ) ;
1244
+
1245
+
1246
+ it ( 'should replace current path when link begins with "#!/" and history enabled on old browser' , function ( ) {
1247
+ configureService ( '#!/link' , true , false , true ) ;
1211
1248
inject (
1212
1249
initBrowser ( ) ,
1213
1250
initLocation ( ) ,
@@ -1220,6 +1257,33 @@ describe('$location', function() {
1220
1257
} ) ;
1221
1258
1222
1259
1260
+ it ( 'should rewrite when relative link begins with "/" and app is on the root and there is no base tag and history enabled on old browser' , function ( ) {
1261
+ configureService ( '/link' , true , false , true ) ;
1262
+ inject (
1263
+ initBrowser ( true , true ) ,
1264
+ initLocation ( ) ,
1265
+ function ( $browser , $location ) {
1266
+ browserTrigger ( link , 'click' ) ;
1267
+ expectRewriteTo ( $browser , 'http://host.com/#!/link' ) ;
1268
+ }
1269
+ ) ;
1270
+ } ) ;
1271
+
1272
+
1273
+ it ( 'should not rewrite when relative link begins with "/" and history enabled on old browser' , function ( ) {
1274
+ configureService ( '/other_base/link' , true , false , true ) ;
1275
+ inject (
1276
+ initBrowser ( ) ,
1277
+ initLocation ( ) ,
1278
+ function ( $browser , $location ) {
1279
+ $location . path ( '/some' ) ;
1280
+ browserTrigger ( link , 'click' ) ;
1281
+ expectNoRewrite ( $browser ) ;
1282
+ }
1283
+ ) ;
1284
+ } ) ;
1285
+
1286
+
1223
1287
it ( 'should replace current hash fragment when link begins with "#" history disabled' , function ( ) {
1224
1288
configureService ( '#link' , true , false , true ) ;
1225
1289
inject (
0 commit comments