mirror of https://github.com/zulip/zulip.git
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:
parent
b401ec0af7
commit
5b1cfbc977
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue