From 43bd2a2825941c2248b04fc4715bbd8b78c3c979 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Tue, 7 Mar 2023 11:20:39 +0000 Subject: [PATCH] Deal with 404 in get_redirect_url This should address #1 --- get_context.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/get_context.py b/get_context.py index ad94daf..fccad5b 100644 --- a/get_context.py +++ b/get_context.py @@ -255,6 +255,9 @@ def parse_pleroma_url(url): if match is not None: server = match.group("server") url = get_redirect_url(url) + if url is None: + return None + match = re.match(r"/notice/(?P.*)", url) if match is not None: return (server, match.group("toot_id")) @@ -271,7 +274,7 @@ def get_redirect_url(url): return None if resp.status_code == 200: - return None + return url elif resp.status_code == 302: redirect_url = resp.headers["Location"] print(f"Discovered redirect for URL {url}")