mirror of
https://github.com/cquest/tootbot.git
synced 2024-11-23 20:11:06 +00:00
handle local path redirects
This commit is contained in:
parent
e3292c74bd
commit
1165374824
|
@ -18,6 +18,10 @@ import requests
|
|||
def unredir(redir):
|
||||
r = requests.get(redir, allow_redirects=False)
|
||||
while r.status_code in {301, 302}:
|
||||
if 'http' not in r.headers.get('Location'):
|
||||
redir = re.sub(r'(https?://.*)/.*', r'\1', redir) + \
|
||||
r.headers.get('Location')
|
||||
else:
|
||||
redir = r.headers.get('Location')
|
||||
print('redir', redir)
|
||||
if '//ow.ly/' in redir or '//bit.ly/' in redir:
|
||||
|
|
Loading…
Reference in New Issue
Block a user