From 6e34e8f57997adeed1591322d0e247f57ea2511c Mon Sep 17 00:00:00 2001 From: Ryan Welton Date: Mon, 23 Jan 2023 13:43:49 -0500 Subject: [PATCH] [utils] base_url: URL paths can contain & (yt-dlp#4841) --- test/test_utils.py | 1 + youtube_dl/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_utils.py b/test/test_utils.py index 9d364c863..70dd1f424 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -540,6 +540,7 @@ class TestUtil(unittest.TestCase): 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') diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index e3c3ccff9..fca7b2ad1 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -3678,7 +3678,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):