Class: WebStat::FinalRedirectUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/web_stat/final_redirect_url.rb

Class Method Summary collapse

Class Method Details

.final_redirect_url(url, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/web_stat/final_redirect_url.rb', line 7

def final_redirect_url(url, options={})
  final_url = ''
  if is_valid_url?(url)
    begin
      redirect_lookup_depth = options[:depth].to_i > 0 ? options[:depth].to_i : 10
      response_uri = get_final_redirect_url(url, redirect_lookup_depth)
      final_url =  url_string_from_uri(response_uri)
    rescue => e
      # nothing
    end
  end
  final_url
end