Skip to content

Instantly share code, notes, and snippets.

@yatatsu
Created March 6, 2014 08:29
Show Gist options
  • Save yatatsu/9384881 to your computer and use it in GitHub Desktop.
Save yatatsu/9384881 to your computer and use it in GitHub Desktop.
memo
require 'net/https'
def restore_shorten_uri(uri)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |h|
res = h.head(uri.path)
loc = res['Location']
URI.regexp =~ loc ? URI.parse(loc) : uri
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment