bugdown: Fix extraction of titles for uploaded files.

The previous code was associated with a previous version of the upload
URL naming scheme, and thus never triggered in practice.
This commit is contained in:
Tim Abbott 2016-06-13 19:09:33 -07:00
parent b401ec0af7
commit 5b1cfbc977
1 changed files with 2 additions and 2 deletions

View File

@ -630,13 +630,13 @@ class ModalLink(markdown.inlinepatterns.Pattern):
return a_tag
upload_re = re.compile(ur"^(?:https://%s.s3.amazonaws.com|/user_uploads/\d+)/[^/]*/([^/]*)$" % (settings.S3_BUCKET,))
upload_re = re.compile(ur"^(https?://[^/]*)?(/user_uploads/\d+)(/[^/]*)?/[^/]*/(?P<filename>[^/]*)$")
def url_filename(url):
# type: (text_type) -> text_type
"""Extract the filename if a URL is an uploaded file, or return the original URL"""
match = upload_re.match(url)
if match:
return match.group(1)
return match.group('filename')
else:
return url