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:
Tim Abbott 2018-04-02 10:29:32 -07:00
parent b58cd46e48
commit 6055a7bceb
1 changed files with 3 additions and 2 deletions

View File

@ -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