diff --git a/src/helpers/helpers.py b/src/helpers/helpers.py index d8c92a6..d531c0b 100644 --- a/src/helpers/helpers.py +++ b/src/helpers/helpers.py @@ -8,9 +8,14 @@ from ..cache import get_poll_results -def url_handler(raw_url): +def url_handler(url : str | urllib.parse.ParseResult): """Change URLs found in posts to privacy-friendly alternatives""" - url = urllib.parse.urlparse(raw_url) + if isinstance(url, str): + url = urllib.parse.urlparse(url) + elif isinstance(url, urllib.parse.ParseResult): + url = url + else: + raise ValueError hostname = url.hostname