@@ -418,7 +418,7 @@ describe('browser', function() {
418
418
browser . url ( 'http://new.org' ) ;
419
419
420
420
expect ( pushState ) . toHaveBeenCalledOnce ( ) ;
421
- expect ( pushState . calls . argsFor ( 0 ) [ 2 ] ) . toEqual ( 'http://new.org' ) ;
421
+ expect ( pushState . calls . argsFor ( 0 ) [ 2 ] ) . toEqual ( 'http://new.org/ ' ) ;
422
422
423
423
expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
424
424
expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
@@ -430,7 +430,7 @@ describe('browser', function() {
430
430
browser . url ( 'http://new.org' , true ) ;
431
431
432
432
expect ( replaceState ) . toHaveBeenCalledOnce ( ) ;
433
- expect ( replaceState . calls . argsFor ( 0 ) [ 2 ] ) . toEqual ( 'http://new.org' ) ;
433
+ expect ( replaceState . calls . argsFor ( 0 ) [ 2 ] ) . toEqual ( 'http://new.org/ ' ) ;
434
434
435
435
expect ( pushState ) . not . toHaveBeenCalled ( ) ;
436
436
expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
@@ -474,7 +474,7 @@ describe('browser', function() {
474
474
sniffer . history = false ;
475
475
browser . url ( 'http://new.org' , true ) ;
476
476
477
- expect ( locationReplace ) . toHaveBeenCalledWith ( 'http://new.org' ) ;
477
+ expect ( locationReplace ) . toHaveBeenCalledWith ( 'http://new.org/ ' ) ;
478
478
479
479
expect ( pushState ) . not . toHaveBeenCalled ( ) ;
480
480
expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
@@ -689,6 +689,73 @@ describe('browser', function() {
689
689
expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
690
690
expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
691
691
} ) ;
692
+
693
+ it ( 'should not do pushState with a URL using relative protocol' , function ( ) {
694
+ browser . url ( 'http://server/' ) ;
695
+
696
+ pushState . calls . reset ( ) ;
697
+ replaceState . calls . reset ( ) ;
698
+ locationReplace . calls . reset ( ) ;
699
+
700
+ browser . url ( '//server' ) ;
701
+ expect ( pushState ) . not . toHaveBeenCalled ( ) ;
702
+ expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
703
+ expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
704
+ } ) ;
705
+
706
+ it ( 'should not do pushState with a URL only adding a trailing slash after domain' , function ( ) {
707
+ // A domain without a trailing /
708
+ browser . url ( 'http://server' ) ;
709
+
710
+ pushState . calls . reset ( ) ;
711
+ replaceState . calls . reset ( ) ;
712
+ locationReplace . calls . reset ( ) ;
713
+
714
+ // A domain from something such as window.location.href with a trailing slash
715
+ browser . url ( 'http://server/' ) ;
716
+ expect ( pushState ) . not . toHaveBeenCalled ( ) ;
717
+ expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
718
+ expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
719
+ } ) ;
720
+
721
+ it ( 'should not do pushState with a URL only removing a trailing slash after domain' , function ( ) {
722
+ // A domain from something such as window.location.href with a trailing slash
723
+ browser . url ( 'http://server/' ) ;
724
+
725
+ pushState . calls . reset ( ) ;
726
+ replaceState . calls . reset ( ) ;
727
+ locationReplace . calls . reset ( ) ;
728
+
729
+ // A domain without a trailing /
730
+ browser . url ( 'http://server' ) ;
731
+ expect ( pushState ) . not . toHaveBeenCalled ( ) ;
732
+ expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
733
+ expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
734
+ } ) ;
735
+
736
+ it ( 'should do pushState with a URL only adding a trailing slash after the path' , function ( ) {
737
+ browser . url ( 'http://server/foo' ) ;
738
+
739
+ pushState . calls . reset ( ) ;
740
+ replaceState . calls . reset ( ) ;
741
+ locationReplace . calls . reset ( ) ;
742
+
743
+ browser . url ( 'http://server/foo/' ) ;
744
+ expect ( pushState ) . toHaveBeenCalledOnce ( ) ;
745
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/foo/' ) ;
746
+ } ) ;
747
+
748
+ it ( 'should do pushState with a URL only removing a trailing slash after the path' , function ( ) {
749
+ browser . url ( 'http://server/foo/' ) ;
750
+
751
+ pushState . calls . reset ( ) ;
752
+ replaceState . calls . reset ( ) ;
753
+ locationReplace . calls . reset ( ) ;
754
+
755
+ browser . url ( 'http://server/foo' ) ;
756
+ expect ( pushState ) . toHaveBeenCalledOnce ( ) ;
757
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/foo' ) ;
758
+ } ) ;
692
759
} ;
693
760
}
694
761
} ) ;
@@ -1093,7 +1160,7 @@ describe('browser', function() {
1093
1160
it ( 'should not interfere with legacy browser url replace behavior' , function ( ) {
1094
1161
inject ( function ( $rootScope ) {
1095
1162
var current = fakeWindow . location . href ;
1096
- var newUrl = 'notyet' ;
1163
+ var newUrl = 'http:// notyet/ ' ;
1097
1164
sniffer . history = false ;
1098
1165
expect ( historyEntriesLength ) . toBe ( 1 ) ;
1099
1166
browser . url ( newUrl , true ) ;
0 commit comments