Class: Consummo::UrlResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/consummo/enrichers/url_resolver.rb

Instance Method Summary collapse

Instance Method Details

#resolve(url) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/consummo/enrichers/url_resolver.rb', line 5

def resolve(url)
  return url if url.blank?
  begin
    response = HTTParty.head(url, follow_redirects: true)
    response.request.last_uri
  rescue Errno::ECONNREFUSED, URI::InvalidURIError, HTTParty::RedirectionTooDeep
    url
  end
end