@@ -362,6 +362,11 @@ def checkJoin(self, base, relurl, expected, *, relroundtrip=True):
362
362
self .assertEqual (urllib .parse .urljoin (base , relurl ), expected )
363
363
relurlb = urllib .parse .urlunsplit (urllib .parse .urlsplit (relurlb ))
364
364
self .assertEqual (urllib .parse .urljoin (baseb , relurlb ), expectedb )
365
+ else :
366
+ relurl = urllib .parse .urlunsplit (urllib .parse .urlsplit (relurl ))
367
+ self .assertNotEqual (urllib .parse .urljoin (base , relurl ), expected )
368
+ relurlb = urllib .parse .urlunsplit (urllib .parse .urlsplit (relurlb ))
369
+ self .assertNotEqual (urllib .parse .urljoin (baseb , relurlb ), expectedb )
365
370
366
371
def test_unparse_parse (self ):
367
372
str_cases = ['Python' , './Python' ,'x-newscheme://foo.com/stuff' ,'x://y' ,'x:/y' ,'x:/' ,'/' ,]
@@ -568,6 +573,9 @@ def test_urljoins(self):
568
573
# slashes
569
574
self .checkJoin ('http://a/b/c/d/e/' , '../../f/g/' , 'http://a/b/c/f/g/' )
570
575
self .checkJoin ('http://a/b/c/d/e' , '../../f/g/' , 'http://a/b/f/g/' )
576
+ self .checkJoin ('http://a/b/c/d/e//' , '../../f/g/' , 'http://a/b/c/d/f/g/' )
577
+ self .checkJoin ('http://a/b/c/d/e///' , '../../f/g/' , 'http://a/b/c/d/e/f/g/' )
578
+ self .checkJoin ('http://a/b/c/d/e////' , '../../f/g/' , 'http://a/b/c/d/e//f/g/' )
571
579
self .checkJoin ('http://a/b/c/d/e/' , '/../../f/g/' , 'http://a/f/g/' )
572
580
self .checkJoin ('http://a/b/c/d/e' , '/../../f/g/' , 'http://a/f/g/' )
573
581
self .checkJoin ('http://a/b/c/d/e/' , '../../f/g' , 'http://a/b/c/f/g' )
@@ -645,6 +653,16 @@ def test_urljoins_relative_base(self):
645
653
self .checkJoin ('//' , '/w' , '///w' )
646
654
self .checkJoin ('//' , '///w' , '///w' )
647
655
self .checkJoin ('//' , 'w' , '///w' )
656
+ self .checkJoin ('//' , '../w' , '///w' )
657
+ self .checkJoin ('//' , './w' , '///w' )
658
+ self .checkJoin ('//' , '..//w' , '///w' )
659
+ self .checkJoin ('//' , './/w' , '///w' )
660
+ self .checkJoin ('//' , '..' , '//' )
661
+ self .checkJoin ('//' , '.' , '//' )
662
+ self .checkJoin ('//' , '../' , '//' )
663
+ self .checkJoin ('//' , './' , '//' )
664
+ self .checkJoin ('//' , '..//' , '///' )
665
+ self .checkJoin ('//' , './/' , '///' )
648
666
649
667
self .checkJoin ('//a' , '' , '//a' )
650
668
self .checkJoin ('//a' , '//' , '//a' )
@@ -653,6 +671,16 @@ def test_urljoins_relative_base(self):
653
671
self .checkJoin ('//a' , '/w' , '//a/w' )
654
672
self .checkJoin ('//a' , '///w' , '//a/w' )
655
673
self .checkJoin ('//a' , 'w' , '//a/w' )
674
+ self .checkJoin ('//a' , '../w' , '//a/w' )
675
+ self .checkJoin ('//a' , './w' , '//a/w' )
676
+ self .checkJoin ('//a' , '..//w' , '//a/w' )
677
+ self .checkJoin ('//a' , './/w' , '//a/w' )
678
+ self .checkJoin ('//a' , '..' , '//a' )
679
+ self .checkJoin ('//a' , '.' , '//a' )
680
+ self .checkJoin ('//a' , '../' , '//a' )
681
+ self .checkJoin ('//a' , './' , '//a' )
682
+ self .checkJoin ('//a' , '..//' , '//a/' )
683
+ self .checkJoin ('//a' , './/' , '//a/' )
656
684
657
685
for scheme in '' , 'http:' :
658
686
self .checkJoin ('http:' , scheme + '' , 'http:' )
@@ -661,7 +689,21 @@ def test_urljoins_relative_base(self):
661
689
self .checkJoin ('http:' , scheme + '//v/w' , 'http://v/w' )
662
690
self .checkJoin ('http:' , scheme + '/w' , 'http:/w' )
663
691
self .checkJoin ('http:' , scheme + '///w' , 'http:/w' )
664
- self .checkJoin ('http:' , scheme + 'w' , 'http:/w' )
692
+ self .checkJoin ('http:' , scheme + 'w' , 'http:w' )
693
+ self .checkJoin ('http:' , scheme + '../w' , 'http:w' )
694
+ self .checkJoin ('http:' , scheme + './w' , 'http:w' )
695
+ self .checkJoin ('http:' , scheme + '..//w' , 'http:/w' )
696
+ self .checkJoin ('http:' , scheme + './/w' , 'http:/w' )
697
+ self .checkJoin ('http:' , scheme + '..///w' , 'http:////w' )
698
+ self .checkJoin ('http:' , scheme + './//w' , 'http:////w' )
699
+ self .checkJoin ('http:' , scheme + '..' , 'http:' )
700
+ self .checkJoin ('http:' , scheme + '.' , 'http:' )
701
+ self .checkJoin ('http:' , scheme + '../' , 'http:' )
702
+ self .checkJoin ('http:' , scheme + './' , 'http:' )
703
+ self .checkJoin ('http:' , scheme + '..//' , 'http:/' )
704
+ self .checkJoin ('http:' , scheme + './/' , 'http:/' )
705
+ self .checkJoin ('http:' , scheme + '..///' , 'http:////' )
706
+ self .checkJoin ('http:' , scheme + './//' , 'http:////' )
665
707
666
708
self .checkJoin ('http://' , scheme + '' , 'http://' )
667
709
self .checkJoin ('http://' , scheme + '//' , 'http://' )
@@ -670,6 +712,20 @@ def test_urljoins_relative_base(self):
670
712
self .checkJoin ('http://' , scheme + '/w' , 'http:///w' )
671
713
self .checkJoin ('http://' , scheme + '///w' , 'http:///w' )
672
714
self .checkJoin ('http://' , scheme + 'w' , 'http:///w' )
715
+ self .checkJoin ('http://' , scheme + '../w' , 'http:///w' )
716
+ self .checkJoin ('http://' , scheme + './w' , 'http:///w' )
717
+ self .checkJoin ('http://' , scheme + '..//w' , 'http:///w' )
718
+ self .checkJoin ('http://' , scheme + './/w' , 'http:///w' )
719
+ self .checkJoin ('http://' , scheme + '..///w' , 'http:////w' )
720
+ self .checkJoin ('http://' , scheme + './//w' , 'http:////w' )
721
+ self .checkJoin ('http://' , scheme + '..' , 'http://' )
722
+ self .checkJoin ('http://' , scheme + '.' , 'http://' )
723
+ self .checkJoin ('http://' , scheme + '../' , 'http://' )
724
+ self .checkJoin ('http://' , scheme + './' , 'http://' )
725
+ self .checkJoin ('http://' , scheme + '..//' , 'http:///' )
726
+ self .checkJoin ('http://' , scheme + './/' , 'http:///' )
727
+ self .checkJoin ('http://' , scheme + '..///' , 'http:////' )
728
+ self .checkJoin ('http://' , scheme + './//' , 'http:////' )
673
729
674
730
self .checkJoin ('http://a' , scheme + '' , 'http://a' )
675
731
self .checkJoin ('http://a' , scheme + '//' , 'http://a' )
@@ -678,6 +734,38 @@ def test_urljoins_relative_base(self):
678
734
self .checkJoin ('http://a' , scheme + '/w' , 'http://a/w' )
679
735
self .checkJoin ('http://a' , scheme + '///w' , 'http://a/w' )
680
736
self .checkJoin ('http://a' , scheme + 'w' , 'http://a/w' )
737
+ self .checkJoin ('http://a' , scheme + '../w' , 'http://a/w' )
738
+ self .checkJoin ('http://a' , scheme + './w' , 'http://a/w' )
739
+ self .checkJoin ('http://a' , scheme + '..//w' , 'http://a/w' )
740
+ self .checkJoin ('http://a' , scheme + './/w' , 'http://a/w' )
741
+ self .checkJoin ('http://a' , scheme + '..///w' , 'http://a//w' )
742
+ self .checkJoin ('http://a' , scheme + './//w' , 'http://a//w' )
743
+ self .checkJoin ('http://a' , scheme + '..' , 'http://a' )
744
+ self .checkJoin ('http://a' , scheme + '.' , 'http://a' )
745
+ self .checkJoin ('http://a' , scheme + '../' , 'http://a' )
746
+ self .checkJoin ('http://a' , scheme + './' , 'http://a' )
747
+ self .checkJoin ('http://a' , scheme + '..//' , 'http://a/' )
748
+ self .checkJoin ('http://a' , scheme + './/' , 'http://a/' )
749
+ self .checkJoin ('http://a' , scheme + '..///' , 'http://a//' )
750
+ self .checkJoin ('http://a' , scheme + './//' , 'http://a//' )
751
+
752
+ self .checkJoin ('b/c' , '' , 'b/c' )
753
+ self .checkJoin ('b/c' , '//' , 'b/c' )
754
+ self .checkJoin ('b/c' , '//v' , '//v' )
755
+ self .checkJoin ('b/c' , '//v/w' , '//v/w' )
756
+ self .checkJoin ('b/c' , '/w' , '/w' )
757
+ self .checkJoin ('b/c' , '///w' , '/w' )
758
+ self .checkJoin ('b/c' , 'w' , 'b/w' )
759
+ self .checkJoin ('b/c' , '../w' , 'w' )
760
+ self .checkJoin ('b/c' , '../../w' , 'w' )
761
+ self .checkJoin ('b/c' , '../../../w' , 'w' )
762
+ self .checkJoin ('b/c' , 'w/.' , 'b/w/' )
763
+ self .checkJoin ('b/c' , '../w/.' , 'w/' )
764
+ self .checkJoin ('b/c' , '../../w/.' , 'w/' )
765
+ self .checkJoin ('b/c' , '../../../w/.' , 'w/' )
766
+ self .checkJoin ('b/c' , '..' , '' )
767
+ self .checkJoin ('b/c' , '../..' , '' )
768
+ self .checkJoin ('b/c' , '../../..' , '' )
681
769
682
770
self .checkJoin ('/b/c' , '' , '/b/c' )
683
771
self .checkJoin ('/b/c' , '//' , '/b/c' )
@@ -686,6 +774,16 @@ def test_urljoins_relative_base(self):
686
774
self .checkJoin ('/b/c' , '/w' , '/w' )
687
775
self .checkJoin ('/b/c' , '///w' , '/w' )
688
776
self .checkJoin ('/b/c' , 'w' , '/b/w' )
777
+ self .checkJoin ('/b/c' , '../w' , '/w' )
778
+ self .checkJoin ('/b/c' , '../../w' , '/w' )
779
+ self .checkJoin ('/b/c' , '../../../w' , '/w' )
780
+ self .checkJoin ('/b/c' , 'w/.' , '/b/w/' )
781
+ self .checkJoin ('/b/c' , '../w/.' , '/w/' )
782
+ self .checkJoin ('/b/c' , '../../w/.' , '/w/' )
783
+ self .checkJoin ('/b/c' , '../../../w/.' , '/w/' )
784
+ self .checkJoin ('/b/c' , '..' , '/' )
785
+ self .checkJoin ('/b/c' , '../..' , '/' )
786
+ self .checkJoin ('/b/c' , '../../..' , '/' )
689
787
690
788
self .checkJoin ('///b/c' , '' , '///b/c' )
691
789
self .checkJoin ('///b/c' , '//' , '///b/c' )
0 commit comments