id_to_username cleanup

This commit is contained in:
Hugh Rundle 2023-09-26 07:45:45 +10:00
parent b05f2e99e8
commit 3e38fecd55
No known key found for this signature in database
GPG key ID: A7E35779918253F9

View file

@ -116,12 +116,12 @@ def get_isni(existing, author, autoescape=True):
@register.simple_tag(takes_context=False)
def id_to_username(user_id):
"""given an arbitrary user id, return the username"""
"""given an arbitrary remote id, return the username"""
if user_id:
url = urlparse(user_id)
domain = url.netloc
parts = url.path.split("/")
name = parts[-1]
return f"{name}@{domain}"
else:
return None
value = f"{name}@{domain}"
return value