From 63570ea84beeaf363ed952f83c1a2b6e32c86ceb Mon Sep 17 00:00:00 2001 From: adryd Date: Tue, 13 Jul 2021 02:32:25 -0400 Subject: [PATCH] Match twitter_url before checking user agent --- twitfix.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/twitfix.py b/twitfix.py index 3c76181..fd9b368 100644 --- a/twitfix.py +++ b/twitfix.py @@ -54,19 +54,18 @@ def oembedend(): @app.route('/') def twitfix(subpath): user_agent = request.headers.get('user-agent') - if user_agent in discord_user_agents: + match = pathregex.search(subpath) + if match is not None: + twitter_url = subpath - match = pathregex.search(subpath) - if match is not None: - twitter_url = subpath - - if match.start() == 0: - twitter_url = "https://twitter.com/" + subpath + if match.start() == 0: + twitter_url = "https://twitter.com/" + subpath + if user_agent in discord_user_agents: res = embedVideo(twitter_url) return res else: - return render_template('default.html', message="This doesn't seem to be a twitter link, try /other/ to see if other kinds of video link works? (experimental)") + return redirect(twitter_url, 301) else: return redirect("https://twitter.com/" + subpath, 301)