projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
[utils] Fix url_basename
[youtube-dl]
/
youtube_dl
/
utils.py
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index dbfac0f43ed282142ec2dda68ddf4b3ce85bd12c..2d12e2df93f6f1e885600e49f0eb6f587494e19f 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-1084,3
+1084,10
@@
def remove_start(s, start):
if s.startswith(start):
return s[len(start):]
return s
+
+
+def url_basename(url):
+ m = re.match(r'(?:https?:|)//[^/]+/(?:[^?#]+/)?([^/?#]+)/?(?:[?#]|$)', url)
+ if not m:
+ return u''
+ return m.group(1)