@@ -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,60 @@ 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 only adding a trailing slash after domain' , function ( ) {
694
+ // A domain without a trailing /
695
+ browser . url ( 'http://server' ) ;
696
+
697
+ pushState . calls . reset ( ) ;
698
+ replaceState . calls . reset ( ) ;
699
+ locationReplace . calls . reset ( ) ;
700
+
701
+ // A domain from something such as window.location.href with a trailing slash
702
+ browser . url ( 'http://server/' ) ;
703
+ expect ( pushState ) . not . toHaveBeenCalled ( ) ;
704
+ expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
705
+ expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
706
+ } ) ;
707
+
708
+ it ( 'should not do pushState with a URL only removing a trailing slash after domain' , function ( ) {
709
+ // A domain from something such as window.location.href with a trailing slash
710
+ browser . url ( 'http://server/' ) ;
711
+
712
+ pushState . calls . reset ( ) ;
713
+ replaceState . calls . reset ( ) ;
714
+ locationReplace . calls . reset ( ) ;
715
+
716
+ // A domain without a trailing /
717
+ browser . url ( 'http://server' ) ;
718
+ expect ( pushState ) . not . toHaveBeenCalled ( ) ;
719
+ expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
720
+ expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
721
+ } ) ;
722
+
723
+ it ( 'should do pushState with a URL only adding a trailing slash after the path' , function ( ) {
724
+ browser . url ( 'http://server/foo' ) ;
725
+
726
+ pushState . calls . reset ( ) ;
727
+ replaceState . calls . reset ( ) ;
728
+ locationReplace . calls . reset ( ) ;
729
+
730
+ browser . url ( 'http://server/foo/' ) ;
731
+ expect ( pushState ) . toHaveBeenCalledOnce ( ) ;
732
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/foo/' ) ;
733
+ } ) ;
734
+
735
+ it ( 'should do pushState with a URL only removing a trailing slash after the path' , function ( ) {
736
+ browser . url ( 'http://server/foo/' ) ;
737
+
738
+ pushState . calls . reset ( ) ;
739
+ replaceState . calls . reset ( ) ;
740
+ locationReplace . calls . reset ( ) ;
741
+
742
+ browser . url ( 'http://server/foo' ) ;
743
+ expect ( pushState ) . toHaveBeenCalledOnce ( ) ;
744
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/foo' ) ;
745
+ } ) ;
692
746
} ;
693
747
}
694
748
} ) ;
@@ -813,7 +867,7 @@ describe('browser', function() {
813
867
it ( 'should not fire urlChange if changed by browser.url method' , function ( ) {
814
868
sniffer . history = false ;
815
869
browser . onUrlChange ( callback ) ;
816
- browser . url ( 'http://new.com/ ' ) ;
870
+ browser . url ( 'http://new.com' ) ;
817
871
818
872
fakeWindow . fire ( 'hashchange' ) ;
819
873
expect ( callback ) . not . toHaveBeenCalled ( ) ;
@@ -1093,7 +1147,7 @@ describe('browser', function() {
1093
1147
it ( 'should not interfere with legacy browser url replace behavior' , function ( ) {
1094
1148
inject ( function ( $rootScope ) {
1095
1149
var current = fakeWindow . location . href ;
1096
- var newUrl = 'notyet' ;
1150
+ var newUrl = 'http:// notyet/ ' ;
1097
1151
sniffer . history = false ;
1098
1152
expect ( historyEntriesLength ) . toBe ( 1 ) ;
1099
1153
browser . url ( newUrl , true ) ;
0 commit comments