Browse Source

[utils] Fix url_basename

totalwebcasting
Philipp Hagemeister 11 years ago
parent
commit
d6c7a367e8
2 changed files with 4 additions and 1 deletions
  1. +3
    -0
      test/test_utils.py
  2. +1
    -1
      youtube_dl/utils.py

+ 3
- 0
test/test_utils.py View 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()

+ 1
- 1
youtube_dl/utils.py View 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)

Loading…
Cancel
Save