quark-zju / unshorten

Get original URLs from shortened ones.
BSD 2-Clause "Simplified" License
15 stars 9 forks source link

Provide option to not follow 302 redirects #7

Closed aaronpk closed 9 years ago

aaronpk commented 9 years ago

When un-shortening a URL like http://t.co/uQVbsZ4aL1, I actually want the end result to be the URL before the 302 is returned. 302 is a temporary redirect, so when un-shortening URLs to include the "final" URL in logs, the final archived URL should not be the result of the temporary redirect. I would be fine with this as an option rather than as the default behavior.

quark-zju commented 9 years ago

Hi, I added follow_codes option. You can set it by

Unshorten::DEFAULT_OPTIONS[:follow_codes] = [301]

Or per request:

Unshorten['http://t.co/uQVbsZ4aL1', :follow_codes => [301]]

Hope that helps :)

aaronpk commented 9 years ago

That's great, thanks!! What's the best way to use this before it's published on rubygems?

aaronpk commented 9 years ago

oh nevermind, it looks like you just published it. Thanks again!