Match twitter_url before checking user agent

This commit is contained in:
adryd 2021-07-13 02:32:25 -04:00
parent 4053f6373d
commit 63570ea84b
No known key found for this signature in database
GPG key ID: B5D2A33C5F203BC7

View file

@ -54,8 +54,6 @@ def oembedend():
@app.route('/<path:subpath>') @app.route('/<path:subpath>')
def twitfix(subpath): def twitfix(subpath):
user_agent = request.headers.get('user-agent') user_agent = request.headers.get('user-agent')
if user_agent in discord_user_agents:
match = pathregex.search(subpath) match = pathregex.search(subpath)
if match is not None: if match is not None:
twitter_url = subpath twitter_url = subpath
@ -63,10 +61,11 @@ def twitfix(subpath):
if match.start() == 0: if match.start() == 0:
twitter_url = "https://twitter.com/" + subpath twitter_url = "https://twitter.com/" + subpath
if user_agent in discord_user_agents:
res = embedVideo(twitter_url) res = embedVideo(twitter_url)
return res return res
else: 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: else:
return redirect("https://twitter.com/" + subpath, 301) return redirect("https://twitter.com/" + subpath, 301)