]> jfr.im git - yt-dlp.git/commitdiff
[utils] `base_url`: URL paths can contain `&` (#4841)
authorElyse <redacted>
Sun, 4 Sep 2022 03:09:45 +0000 (22:09 -0500)
committerGitHub <redacted>
Sun, 4 Sep 2022 03:09:45 +0000 (08:39 +0530)
Authored by: elyse0
Closes #4187

test/test_utils.py
yt_dlp/utils.py

index 67cd966d8eb449c5b6e09f7cb1aac966274212a2..96477c53fc85b54800f5db53e7579fd7b14c469f 100644 (file)
@@ -566,6 +566,7 @@ def test_base_url(self):
         self.assertEqual(base_url('http://foo.de/bar/'), 'http://foo.de/bar/')
         self.assertEqual(base_url('http://foo.de/bar/baz'), 'http://foo.de/bar/')
         self.assertEqual(base_url('http://foo.de/bar/baz?x=z/x/c'), 'http://foo.de/bar/')
+        self.assertEqual(base_url('http://foo.de/bar/baz&x=z&w=y/x/c'), 'http://foo.de/bar/baz&x=z&w=y/x/')
 
     def test_urljoin(self):
         self.assertEqual(urljoin('http://foo.de/', '/a/b/c.txt'), 'http://foo.de/a/b/c.txt')
index 90042aa8b99a0f334bafc3d97de9f4959feef686..53939f2902d55575f7faf184caa70486236d65f2 100644 (file)
@@ -2479,7 +2479,7 @@ def url_basename(url):
 
 
 def base_url(url):
-    return re.match(r'https?://[^?#&]+/', url).group()
+    return re.match(r'https?://[^?#]+/', url).group()
 
 
 def urljoin(base, path):