From 7b8f39946842130a5d911a31d14974a0a809ad17 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Wed, 26 Sep 2018 23:28:22 +0300 Subject: [PATCH] Add with_slash text utility Ensures the given text has a slash at the end. --- federation/utils/text.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/federation/utils/text.py b/federation/utils/text.py index f84e54a..44945b8 100644 --- a/federation/utils/text.py +++ b/federation/utils/text.py @@ -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}/"