Simplify url_basename

Use urlparse from the standard library.
This commit is contained in:
Jaime Marquínez Ferrándiz 2013-12-17 14:56:29 +01:00
parent 6086d121cb
commit 9b8aaeed85

View file

@ -1092,7 +1092,5 @@ def remove_start(s, start):
def url_basename(url): def url_basename(url):
m = re.match(r'(?:https?:|)//[^/]+/(?:[^?#]+/)?([^/?#]+)/?(?:[?#]|$)', url) path = compat_urlparse.urlparse(url).path
if not m: return path.strip(u'/').split(u'/')[-1]
return u''
return m.group(1)