From 7657ec7ed6318dd66dd72cc100ba7bc5b911366e Mon Sep 17 00:00:00 2001 From: Elyse <26639800+elyse0@users.noreply.github.com> Date: Sat, 3 Sep 2022 22:09:45 -0500 Subject: [PATCH] [utils] `base_url`: URL paths can contain `&` (#4841) Authored by: elyse0 Closes #4187 --- test/test_utils.py | 1 + yt_dlp/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_utils.py b/test/test_utils.py index 67cd966d8..96477c53f 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -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') diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 90042aa8b..53939f290 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -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):