If an URL shortener does not redirect using head method, call get with allow_redirects set to False instead when expanding. Fixes #179

This commit is contained in:
Jose Manuel Delicado 2017-12-11 21:07:57 +01:00
parent b184bed1a8
commit 6ba1fe9eac

View File

@ -27,6 +27,9 @@ class URLShortener (object):
return handle_dropbox(r.headers['location'])
else:
return r.headers['location']
else: # if the head method does not work, use get instead. Performance may decrease
r=requests.get(url, allow_redirects=False)
return r.headers['location']
except:
return url #we cannot expand