From c89c575e0db1a393cb5be1c403aebb9d2c06648f Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 2 Jul 2023 15:58:43 +0100 Subject: [PATCH] This should hopefully fix redirect issue (Url normalization was the cause) --- twitfix.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/twitfix.py b/twitfix.py index 2e2c9fb..7607329 100644 --- a/twitfix.py +++ b/twitfix.py @@ -111,7 +111,11 @@ def twitfix(sub_path): if match.start() == 0: twitter_url = "https://twitter.com/" + sub_path else: - twitter_url = "https://" + sub_path + # URL normalization messes up the URL, so we have to fix it + if sub_path.startswith("https:/"): + twitter_url = sub_path.replace("https:/", "https://", 1) + elif sub_path.startswith("http:/"): + twitter_url = sub_path.replace("http:/", "http://", 1) if isValidUserAgent(user_agent): res = embedCombined(twitter_url)