From d6c7a367e88096bb17e323954002c084477fe908 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Tue, 17 Dec 2013 12:32:58 +0100 Subject: [PATCH] [utils] Fix url_basename --- test/test_utils.py | 3 +++ youtube_dl/utils.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_utils.py b/test/test_utils.py index 5f4fdb771..e5778cd83 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -188,6 +188,9 @@ class TestUtil(unittest.TestCase): self.assertEqual(url_basename(u'http://foo.de/bar/baz?x=y'), u'baz') self.assertEqual(url_basename(u'http://foo.de/bar/baz#x=y'), u'baz') self.assertEqual(url_basename(u'http://foo.de/bar/baz/'), u'baz') + self.assertEqual( + url_basename(u'http://media.w3.org/2010/05/sintel/trailer.mp4'), + u'trailer.mp4') if __name__ == '__main__': unittest.main() diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index a249c7ec1..2d12e2df9 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1087,7 +1087,7 @@ def remove_start(s, start): def url_basename(url): - m = re.match(r'(?:https?:|)//[^/]+/(?:[^/?#]+/)?([^/?#]+)/?(?:[?#]|$)', url) + m = re.match(r'(?:https?:|)//[^/]+/(?:[^?#]+/)?([^/?#]+)/?(?:[?#]|$)', url) if not m: return u'' return m.group(1)