Skip to content

Commit

Permalink
Allow url_handler to take in parsed URL as input
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Jan 2, 2025
1 parent 8cd3a8f commit 53f11f4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 53f11f4

Please sign in to comment.