mirror of https://github.com/zulip/zulip.git
bugdown: Clean up rewrite_if_relative_link.
This implementation is more obviously correct, and may fix a corner case where a `/` is missing after the realm URI.
This commit is contained in:
parent
b58cd46e48
commit
6055a7bceb
|
@ -86,9 +86,10 @@ def rewrite_if_relative_link(link: str) -> str:
|
|||
instead of opening a new tab. """
|
||||
|
||||
if db_data:
|
||||
if link.startswith(db_data['realm_uri']):
|
||||
realm_uri_prefix = db_data['realm_uri'] + "/"
|
||||
if link.startswith(realm_uri_prefix):
|
||||
# +1 to skip the `/` before the hash link.
|
||||
return link[len(db_data['realm_uri']) + 1:]
|
||||
return link[len(realm_uri_prefix):]
|
||||
|
||||
return link
|
||||
|
||||
|
|
Loading…
Reference in New Issue