@@ -46,15 +46,15 @@ describe('$location', function() {
46
46
47
47
it ( 'should not include the drive name in path() on WIN' , function ( ) {
48
48
//See issue #4680 for details
49
- var locationUrl = new LocationHashbangUrl ( 'file:///base' , '#!' ) ;
49
+ var locationUrl = new LocationHashbangUrl ( 'file:///base' , 'file:///' , ' #!') ;
50
50
locationUrl . $$parse ( 'file:///base#!/foo?a=b&c#hash' ) ;
51
51
52
52
expect ( locationUrl . path ( ) ) . toBe ( '/foo' ) ;
53
53
} ) ;
54
54
55
55
56
56
it ( 'should include the drive name if it was provided in the input url' , function ( ) {
57
- var locationUrl = new LocationHashbangUrl ( 'file:///base' , '#!' ) ;
57
+ var locationUrl = new LocationHashbangUrl ( 'file:///base' , 'file:///' , ' #!') ;
58
58
locationUrl . $$parse ( 'file:///base#!/C:/foo?a=b&c#hash' ) ;
59
59
60
60
expect ( locationUrl . path ( ) ) . toBe ( '/C:/foo' ) ;
@@ -64,7 +64,7 @@ describe('$location', function() {
64
64
65
65
describe ( 'NewUrl' , function ( ) {
66
66
function createLocationHtml5Url ( ) {
67
- var locationUrl = new LocationHtml5Url ( 'http://www.domain.com:9877/' ) ;
67
+ var locationUrl = new LocationHtml5Url ( 'http://www.domain.com:9877/' , 'http://www.domain.com:9877/' ) ;
68
68
locationUrl . $$parse ( 'http://www.domain.com:9877/path/b?search=a&b=c&d#hash' ) ;
69
69
return locationUrl ;
70
70
}
@@ -299,18 +299,18 @@ describe('$location', function() {
299
299
300
300
301
301
it ( 'should parse new url' , function ( ) {
302
- var locationUrl = new LocationHtml5Url ( 'http://host.com/' ) ;
302
+ var locationUrl = new LocationHtml5Url ( 'http://host.com/' , 'http://host.com/' ) ;
303
303
locationUrl . $$parse ( 'http://host.com/base' ) ;
304
304
expect ( locationUrl . path ( ) ) . toBe ( '/base' ) ;
305
305
306
- locationUrl = new LocationHtml5Url ( 'http://host.com/' ) ;
306
+ locationUrl = new LocationHtml5Url ( 'http://host.com/' , 'http://host.com/' ) ;
307
307
locationUrl . $$parse ( 'http://host.com/base#' ) ;
308
308
expect ( locationUrl . path ( ) ) . toBe ( '/base' ) ;
309
309
} ) ;
310
310
311
311
312
312
it ( 'should prefix path with forward-slash' , function ( ) {
313
- var locationUrl = new LocationHtml5Url ( 'http://server/' ) ;
313
+ var locationUrl = new LocationHtml5Url ( 'http://server/' , 'http://server/' ) ;
314
314
locationUrl . path ( 'b' ) ;
315
315
316
316
expect ( locationUrl . path ( ) ) . toBe ( '/b' ) ;
@@ -319,7 +319,7 @@ describe('$location', function() {
319
319
320
320
321
321
it ( 'should set path to forward-slash when empty' , function ( ) {
322
- var locationUrl = new LocationHtml5Url ( 'http://server/' ) ;
322
+ var locationUrl = new LocationHtml5Url ( 'http://server/' , 'http://server/' ) ;
323
323
locationUrl . $$parse ( 'http://server/' ) ;
324
324
expect ( locationUrl . path ( ) ) . toBe ( '/' ) ;
325
325
expect ( locationUrl . absUrl ( ) ) . toBe ( 'http://server/' ) ;
@@ -356,7 +356,7 @@ describe('$location', function() {
356
356
} ) ;
357
357
358
358
it ( 'should prepend path with basePath' , function ( ) {
359
- var locationUrl = new LocationHtml5Url ( 'http://server/base/' ) ;
359
+ var locationUrl = new LocationHtml5Url ( 'http://server/base/' , 'http://server/base/' ) ;
360
360
locationUrl . $$parse ( 'http://server/base/abc?a' ) ;
361
361
expect ( locationUrl . path ( ) ) . toBe ( '/abc' ) ;
362
362
expect ( locationUrl . search ( ) ) . toEqual ( { a : true } ) ;
@@ -367,7 +367,7 @@ describe('$location', function() {
367
367
368
368
369
369
it ( 'should throw error when invalid server url given' , function ( ) {
370
- var locationUrl = new LocationHtml5Url ( 'http://server.org/base/abc' , '/base' ) ;
370
+ var locationUrl = new LocationHtml5Url ( 'http://server.org/base/abc' , 'http://server.org/base/' , ' /base') ;
371
371
372
372
expect ( function ( ) {
373
373
locationUrl . $$parse ( 'http://other.server.org/path#/path' ) ;
@@ -376,7 +376,7 @@ describe('$location', function() {
376
376
377
377
378
378
it ( 'should throw error when invalid base url given' , function ( ) {
379
- var locationUrl = new LocationHtml5Url ( 'http://server.org/base/abc' , '/base' ) ;
379
+ var locationUrl = new LocationHtml5Url ( 'http://server.org/base/abc' , 'http://server.org/base/' , ' /base') ;
380
380
381
381
expect ( function ( ) {
382
382
locationUrl . $$parse ( 'http://server.org/path#/path' ) ;
@@ -444,15 +444,15 @@ describe('$location', function() {
444
444
445
445
446
446
it ( 'should decode special characters' , function ( ) {
447
- var locationUrl = new LocationHtml5Url ( 'http://host.com/' ) ;
447
+ var locationUrl = new LocationHtml5Url ( 'http://host.com/' , 'http://host.com/' ) ;
448
448
locationUrl . $$parse ( 'http://host.com/a%20%3C%3E%23?i%20j=%3C%3E%23#x%20%3C%3E%23' ) ;
449
449
expect ( locationUrl . path ( ) ) . toBe ( '/a <>#' ) ;
450
450
expect ( locationUrl . search ( ) ) . toEqual ( { 'i j' : '<>#' } ) ;
451
451
expect ( locationUrl . hash ( ) ) . toBe ( 'x <>#' ) ;
452
452
} ) ;
453
453
454
454
it ( 'should decode pluses as spaces in urls' , function ( ) {
455
- var locationUrl = new LocationHtml5Url ( 'http://host.com/' ) ;
455
+ var locationUrl = new LocationHtml5Url ( 'http://host.com/' , 'http://host.com/' ) ;
456
456
locationUrl . $$parse ( 'http://host.com/?a+b=c+d' ) ;
457
457
expect ( locationUrl . search ( ) ) . toEqual ( { 'a b' :'c d' } ) ;
458
458
} ) ;
@@ -470,7 +470,7 @@ describe('$location', function() {
470
470
describe ( 'HashbangUrl' , function ( ) {
471
471
472
472
function createHashbangUrl ( ) {
473
- var locationUrl = new LocationHashbangUrl ( 'http://www.server.org:1234/base' , '#!' ) ;
473
+ var locationUrl = new LocationHashbangUrl ( 'http://www.server.org:1234/base' , 'http://www.server.org:1234/' , ' #!') ;
474
474
locationUrl . $$parse ( 'http://www.server.org:1234/base#!/path?a=b&c#hash' ) ;
475
475
return locationUrl ;
476
476
}
@@ -499,7 +499,7 @@ describe('$location', function() {
499
499
500
500
501
501
it ( 'should preserve query params in base' , function ( ) {
502
- var locationUrl = new LocationHashbangUrl ( 'http://www.server.org:1234/base?base=param' , '#' ) ;
502
+ var locationUrl = new LocationHashbangUrl ( 'http://www.server.org:1234/base?base=param' , 'http://www.server.org:1234/' , ' #') ;
503
503
locationUrl . $$parse ( 'http://www.server.org:1234/base?base=param#/path?a=b&c#hash' ) ;
504
504
expect ( locationUrl . absUrl ( ) ) . toBe ( 'http://www.server.org:1234/base?base=param#/path?a=b&c#hash' ) ;
505
505
@@ -511,7 +511,7 @@ describe('$location', function() {
511
511
512
512
513
513
it ( 'should prefix path with forward-slash' , function ( ) {
514
- var locationUrl = new LocationHashbangUrl ( 'http://host.com/base' , '#' ) ;
514
+ var locationUrl = new LocationHashbangUrl ( 'http://host.com/base' , 'http://host.com/' , ' #') ;
515
515
locationUrl . $$parse ( 'http://host.com/base#path' ) ;
516
516
expect ( locationUrl . path ( ) ) . toBe ( '/path' ) ;
517
517
expect ( locationUrl . absUrl ( ) ) . toBe ( 'http://host.com/base#/path' ) ;
@@ -523,7 +523,7 @@ describe('$location', function() {
523
523
524
524
525
525
it ( 'should set path to forward-slash when empty' , function ( ) {
526
- var locationUrl = new LocationHashbangUrl ( 'http://server/base' , '#!' ) ;
526
+ var locationUrl = new LocationHashbangUrl ( 'http://server/base' , 'http://server/' , ' #!') ;
527
527
locationUrl . $$parse ( 'http://server/base' ) ;
528
528
locationUrl . path ( 'aaa' ) ;
529
529
@@ -592,7 +592,7 @@ describe('$location', function() {
592
592
593
593
594
594
it ( 'should decode special characters' , function ( ) {
595
- var locationUrl = new LocationHashbangUrl ( 'http://host.com/a' , '#' ) ;
595
+ var locationUrl = new LocationHashbangUrl ( 'http://host.com/a' , 'http://host.com/' , ' #') ;
596
596
locationUrl . $$parse ( 'http://host.com/a#/%20%3C%3E%23?i%20j=%3C%3E%23#x%20%3C%3E%23' ) ;
597
597
expect ( locationUrl . path ( ) ) . toBe ( '/ <>#' ) ;
598
598
expect ( locationUrl . search ( ) ) . toEqual ( { 'i j' : '<>#' } ) ;
@@ -601,35 +601,35 @@ describe('$location', function() {
601
601
602
602
603
603
it ( 'should return decoded characters for search specified in URL' , function ( ) {
604
- var locationUrl = new LocationHtml5Url ( 'http://host.com/' ) ;
604
+ var locationUrl = new LocationHtml5Url ( 'http://host.com/' , 'http://host.com/' ) ;
605
605
locationUrl . $$parse ( 'http://host.com/?q=1%2F2%203' ) ;
606
606
expect ( locationUrl . search ( ) ) . toEqual ( { 'q' : '1/2 3' } ) ;
607
607
} ) ;
608
608
609
609
610
610
it ( 'should return decoded characters for search specified with setter' , function ( ) {
611
- var locationUrl = new LocationHtml5Url ( 'http://host.com/' ) ;
611
+ var locationUrl = new LocationHtml5Url ( 'http://host.com/' , 'http://host.com/' ) ;
612
612
locationUrl . $$parse ( 'http://host.com/' ) ;
613
613
locationUrl . search ( 'q' , '1/2 3' ) ;
614
614
expect ( locationUrl . search ( ) ) . toEqual ( { 'q' : '1/2 3' } ) ;
615
615
} ) ;
616
616
617
617
it ( 'should return an array for duplicate params' , function ( ) {
618
- var locationUrl = new LocationHtml5Url ( 'http://host.com' ) ;
618
+ var locationUrl = new LocationHtml5Url ( 'http://host.com' , 'http://host.com' ) ;
619
619
locationUrl . $$parse ( 'http://host.com' ) ;
620
620
locationUrl . search ( 'q' , [ '1/2 3' , '4/5 6' ] ) ;
621
621
expect ( locationUrl . search ( ) ) . toEqual ( { 'q' : [ '1/2 3' , '4/5 6' ] } ) ;
622
622
} ) ;
623
623
624
624
it ( 'should encode an array correctly from search and add to url' , function ( ) {
625
- var locationUrl = new LocationHtml5Url ( 'http://host.com' ) ;
625
+ var locationUrl = new LocationHtml5Url ( 'http://host.com' , 'http://host.com' ) ;
626
626
locationUrl . $$parse ( 'http://host.com' ) ;
627
627
locationUrl . search ( { 'q' : [ '1/2 3' , '4/5 6' ] } ) ;
628
628
expect ( locationUrl . absUrl ( ) ) . toEqual ( 'http://host.com?q=1%2F2%203&q=4%2F5%206' ) ;
629
629
} ) ;
630
630
631
631
it ( 'should rewrite params when specifing a single param in search' , function ( ) {
632
- var locationUrl = new LocationHtml5Url ( 'http://host.com' ) ;
632
+ var locationUrl = new LocationHtml5Url ( 'http://host.com' , 'http://host.com' ) ;
633
633
locationUrl . $$parse ( 'http://host.com' ) ;
634
634
locationUrl . search ( { 'q' : '1/2 3' } ) ;
635
635
expect ( locationUrl . absUrl ( ) ) . toEqual ( 'http://host.com?q=1%2F2%203' ) ;
@@ -2353,8 +2353,8 @@ describe('$location', function() {
2353
2353
var locationUrl , locationIndexUrl ;
2354
2354
2355
2355
beforeEach ( function ( ) {
2356
- locationUrl = new LocationHtml5Url ( 'http://server/pre/' , 'http://server/pre/path' ) ;
2357
- locationIndexUrl = new LocationHtml5Url ( 'http://server/pre/index.html' , 'http://server/pre/path' ) ;
2356
+ locationUrl = new LocationHtml5Url ( 'http://server/pre/' , 'http://server/pre/' , 'http://server/pre/ path') ;
2357
+ locationIndexUrl = new LocationHtml5Url ( 'http://server/pre/index.html' , 'http://server/pre/' , 'http://server/pre/ path') ;
2358
2358
} ) ;
2359
2359
2360
2360
it ( 'should rewrite URL' , function ( ) {
@@ -2416,7 +2416,7 @@ describe('$location', function() {
2416
2416
2417
2417
it ( 'should rewrite URL' , function ( ) {
2418
2418
/* jshint scripturl: true */
2419
- locationUrl = new LocationHashbangUrl ( 'http://server/pre/' , '#' ) ;
2419
+ locationUrl = new LocationHashbangUrl ( 'http://server/pre/' , 'http://server/pre/' , ' #') ;
2420
2420
2421
2421
expect ( parseLinkAndReturn ( locationUrl , 'http://other' ) ) . toEqual ( undefined ) ;
2422
2422
expect ( parseLinkAndReturn ( locationUrl , 'http://server/pre/' ) ) . toEqual ( 'http://server/pre/' ) ;
@@ -2425,15 +2425,15 @@ describe('$location', function() {
2425
2425
} ) ;
2426
2426
2427
2427
it ( "should not set hash if one was not originally specified" , function ( ) {
2428
- locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , '#' ) ;
2428
+ locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , 'http://server/pre/' , ' #') ;
2429
2429
2430
2430
locationUrl . $$parse ( 'http://server/pre/index.html' ) ;
2431
2431
expect ( locationUrl . url ( ) ) . toBe ( '' ) ;
2432
2432
expect ( locationUrl . absUrl ( ) ) . toBe ( 'http://server/pre/index.html' ) ;
2433
2433
} ) ;
2434
2434
2435
2435
it ( "should parse hash if one was specified" , function ( ) {
2436
- locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , '#' ) ;
2436
+ locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , 'http://server/pre/' , ' #') ;
2437
2437
2438
2438
locationUrl . $$parse ( 'http://server/pre/index.html#/foo/bar' ) ;
2439
2439
expect ( locationUrl . url ( ) ) . toBe ( '/foo/bar' ) ;
@@ -2442,7 +2442,7 @@ describe('$location', function() {
2442
2442
2443
2443
2444
2444
it ( "should prefix hash url with / if one was originally missing" , function ( ) {
2445
- locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , '#' ) ;
2445
+ locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , 'http://server/pre/' , ' #') ;
2446
2446
2447
2447
locationUrl . $$parse ( 'http://server/pre/index.html#not-starting-with-slash' ) ;
2448
2448
expect ( locationUrl . url ( ) ) . toBe ( '/not-starting-with-slash' ) ;
@@ -2452,7 +2452,7 @@ describe('$location', function() {
2452
2452
2453
2453
it ( 'should not strip stuff from path just because it looks like Windows drive when it\'s not' ,
2454
2454
function ( ) {
2455
- locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , '#' ) ;
2455
+ locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , 'http://server/pre/' , ' #') ;
2456
2456
2457
2457
locationUrl . $$parse ( 'http://server/pre/index.html#http%3A%2F%2Fexample.com%2F' ) ;
2458
2458
expect ( locationUrl . url ( ) ) . toBe ( '/http://example.com/' ) ;
@@ -2464,7 +2464,7 @@ describe('$location', function() {
2464
2464
} ) ;
2465
2465
2466
2466
it ( 'should allow navigating outside the original base URL' , function ( ) {
2467
- locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , '#' ) ;
2467
+ locationUrl = new LocationHashbangUrl ( 'http://server/pre/index.html' , 'http://server/pre/' , ' #') ;
2468
2468
2469
2469
locationUrl . $$parse ( 'http://server/next/index.html' ) ;
2470
2470
expect ( locationUrl . url ( ) ) . toBe ( '' ) ;
@@ -2478,8 +2478,8 @@ describe('$location', function() {
2478
2478
var locationUrl , locationIndexUrl ;
2479
2479
2480
2480
beforeEach ( function ( ) {
2481
- locationUrl = new LocationHashbangInHtml5Url ( 'http://server/pre/' , '#!' ) ;
2482
- locationIndexUrl = new LocationHashbangInHtml5Url ( 'http://server/pre/index.html' , '#!' ) ;
2481
+ locationUrl = new LocationHashbangInHtml5Url ( 'http://server/pre/' , 'http://server/pre/' , ' #!') ;
2482
+ locationIndexUrl = new LocationHashbangInHtml5Url ( 'http://server/pre/index.html' , 'http://server/pre/' , ' #!') ;
2483
2483
} ) ;
2484
2484
2485
2485
it ( 'should rewrite URL' , function ( ) {
0 commit comments