Scott Watermasysk

Still Learning to Code

Announcing: Unwind Gem

Unwind has a single goal. Take a url and figure out what it actually points to.

It is able to walk various redirect status codes, handles relative and absolute locations, and a couple of other gotchas.

Once completed you have the destination url and a list of the hops along the way.

require 'unwind'

follower = Unwind::RedirectFollower.resolve('')
assert_equal '', follower.final_url

Hat Tip: This gem started with code from John Nunemaker’s Following Redirects with Net/HTTP which provided the basic code to get this done.