Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

new support to unshorten #1

Open
wants to merge 5 commits into
from

Conversation

Projects
None yet
2 participants

Hello,

I had a situation where I get URL shortened 2 times
then I adapted your code to handle with this

for example, I published one URL on Facebook, and this was republished on Twitter...

collecting this text on twitter and use your initial code I had:

source URL: http://www.giantflyingsaucer.com/blog/?p=3950

start URL: http://t.co/04ykj8pz

end URL: http://fb.me/1kpRTSQxO

Att,
Erko Bridee

Owner

mathiasbynens commented May 5, 2013

Thanks Erko. I appreciate the patch.

I don’t think using a regular expression to determine whether the given URL is a “short URL [that redirects elsewhere]” is the best way of doing this, though. It would be better to check the status code returned by the server when requesting the unshortened URL, and if it’s 301 or 302, go through another round of unshortening. However, that would introduce a lot of overhead because of the additional HTTP requests being sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment