Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Follow redirects with ease.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example initial commit February 10, 2012
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 vcr_cassettes
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Rakefile
Octocat-spinner-32 Readme.md
Octocat-spinner-32 unwind.gemspec
Readme.md

Description

Enables following a series of redirects (shortened urls)

Prerequisites

Tested on Ruby 1.9.3 & 2.0 (likely still works on 1.8.7, but you are on your own.)

Example Code

require 'unwind'

follower = Unwind::RedirectFollower.new('http://j.mp/xZVND1')
follower.resolve
assert_equal 'http://ow.ly/i/s1O0', follower.final_url 
assert_equal 'http://j.mp/xZVND1', follower.original_url
assert_equal 2, follower.redirects.count

Hat tip

Most of the code is based on John Nunemaker's blog post Following Redirects with Net/HTTP.

License

Provided under the Do Whatever You Want With This Code License.

Something went wrong with that request. Please try again.