[utils] Fix url_basename
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 17 Dec 2013 11:32:58 +0000 (12:32 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 17 Dec 2013 11:32:58 +0000 (12:32 +0100)
test/test_utils.py
youtube_dl/utils.py

index 5f4fdb771377cb30c8c1e4bd67c57d419e7cc645..e5778cd83ee9ea74e4786243f1e6279aed3697d3 100644 (file)
@@ -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()
index a249c7ec1348926d9d32220d78ca65740629eb90..2d12e2df93f6f1e885600e49f0eb6f587494e19f 100644 (file)
@@ -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)