How to Decode TinyURLs with Ruby


def reverse_tinyurl(tinyurl)
  require 'open-uri'
  require 'net/http'


  url = Net::HTTP.get_response(URI.parse(tinyurl)).to_hash['location'].to_s
end

This should also work for any url that is a known redirect whether it be a tinyurl.com, urltea.com, rubyurl.com, or what have you.

Leave a Reply

Your email address will not be published. Required fields are marked *