Add with_slash text utility

Ensures the given text has a slash at the end.
merge-requests/132/head
Jason Robinson 2018-09-26 23:28:22 +03:00
rodzic 837f463848
commit 7b8f399468
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -30,3 +30,9 @@ def validate_handle(handle):
https://diaspora.github.io/diaspora_federation/federation/types.html#diaspora-id
"""
return re.match(r"[a-z0-9\-_.]+@[^@/]+\.[^@/]+", handle, flags=re.IGNORECASE) is not None
def with_slash(url):
if url.endswith('/'):
return url
return f"{url}/"