@@ -1588,7 +1588,7 @@ describe('$location', function() {
1588
1588
1589
1589
1590
1590
it ( 'should not rewrite links when rewriting links is disabled' , function ( ) {
1591
- configureTestLink ( { linkHref : 'link?a#b' , html5Mode : { enabled : true , rewriteLinks : false } , supportHist : true } ) ;
1591
+ configureTestLink ( { linkHref : 'link?a#b' } ) ;
1592
1592
initService ( { html5Mode :{ enabled : true , rewriteLinks :false } , supportHistory :true } ) ;
1593
1593
inject (
1594
1594
initBrowser ( { url : 'http://host.com/base/index.html' , basePath : '/base/index.html' } ) ,
@@ -1601,6 +1601,34 @@ describe('$location', function() {
1601
1601
} ) ;
1602
1602
1603
1603
1604
+ it ( 'should rewrite links when the specified rewriteLinks attr is detected' , function ( ) {
1605
+ configureTestLink ( { linkHref : 'link?a#b' , attrs : 'force-rewrite' } ) ;
1606
+ initService ( { html5Mode :{ enabled : true , rewriteLinks :'force-rewrite' } , supportHistory :true } ) ;
1607
+ inject (
1608
+ initBrowser ( { url : 'http://host.com/base/index.html' , basePath : '/base/index.html' } ) ,
1609
+ setupRewriteChecks ( ) ,
1610
+ function ( $browser ) {
1611
+ browserTrigger ( link , 'click' ) ;
1612
+ expectRewriteTo ( $browser , 'http://host.com/base/link?a#b' ) ;
1613
+ }
1614
+ ) ;
1615
+ } ) ;
1616
+
1617
+
1618
+ it ( 'should not rewrite links when the specified rewriteLinks attr is not detected' , function ( ) {
1619
+ configureTestLink ( { linkHref : 'link?a#b' } ) ;
1620
+ initService ( { html5Mode :{ enabled : true , rewriteLinks :'yes-rewrite' } , supportHistory :true } ) ;
1621
+ inject (
1622
+ initBrowser ( { url : 'http://host.com/base/index.html' , basePath : '/base/index.html' } ) ,
1623
+ setupRewriteChecks ( ) ,
1624
+ function ( $browser ) {
1625
+ browserTrigger ( link , 'click' ) ;
1626
+ expectNoRewrite ( $browser ) ;
1627
+ }
1628
+ ) ;
1629
+ } ) ;
1630
+
1631
+
1604
1632
it ( 'should rewrite full url links to same domain and base path' , function ( ) {
1605
1633
configureTestLink ( { linkHref : 'http://host.com/base/new' } ) ;
1606
1634
initService ( { html5Mode :true , supportHistory :false , hashPrefix :'!' } ) ;
@@ -1692,7 +1720,7 @@ describe('$location', function() {
1692
1720
1693
1721
it ( 'should not rewrite when full link to different base path when history enabled on old browser' ,
1694
1722
function ( ) {
1695
- configureTestLink ( { linkHref : 'http://host.com/other_base/link' , html5Mode : true , supportHist : false } ) ;
1723
+ configureTestLink ( { linkHref : 'http://host.com/other_base/link' } ) ;
1696
1724
inject (
1697
1725
initBrowser ( { url : 'http://host.com/base/index.html' , basePath : '/base/index.html' } ) ,
1698
1726
setupRewriteChecks ( ) ,
@@ -2357,12 +2385,12 @@ describe('$location', function() {
2357
2385
} ) ;
2358
2386
2359
2387
2360
- it ( 'should only overwrite existing properties if values are boolean ' , function ( ) {
2388
+ it ( 'should only overwrite existing properties if values are the correct type ' , function ( ) {
2361
2389
module ( function ( $locationProvider ) {
2362
2390
$locationProvider . html5Mode ( {
2363
2391
enabled : 'duh' ,
2364
2392
requireBase : 'probably' ,
2365
- rewriteLinks : 'nope'
2393
+ rewriteLinks : 500
2366
2394
} ) ;
2367
2395
2368
2396
expect ( $locationProvider . html5Mode ( ) ) . toEqual ( {
@@ -2376,6 +2404,19 @@ describe('$location', function() {
2376
2404
} ) ;
2377
2405
2378
2406
2407
+ it ( 'should allow rewriteLinks config to be set to a string' , function ( ) {
2408
+ module ( function ( $locationProvider ) {
2409
+ $locationProvider . html5Mode ( {
2410
+ rewriteLinks : 'yes-rewrite'
2411
+ } ) ;
2412
+
2413
+ expect ( $locationProvider . html5Mode ( ) . rewriteLinks ) . toEqual ( 'yes-rewrite' ) ;
2414
+ } ) ;
2415
+
2416
+ inject ( function ( ) { } ) ;
2417
+ } ) ;
2418
+
2419
+
2379
2420
it ( 'should not set unknown input properties to html5Mode object' , function ( ) {
2380
2421
module ( function ( $locationProvider ) {
2381
2422
$locationProvider . html5Mode ( {
0 commit comments