def final_url
      return @final_url if !@final_url.nil?
      location = final_location(FaviconParty::HTTPClient.head(@query_url))
      if !location.nil?
        if location =~ /\Ahttp/
          @final_url = URI.encode location
        else
          uri = URI @query_url
          root = "#{uri.scheme}://#{uri.host}"
          @final_url = URI.encode URI.join(root, location).to_s
        end
      end
      if !@final_url.nil?
        if %w( 127.0.0.1 localhost ).any? {|host| @final_url.include? host }
          # TODO Exception for invalid final urls
          @final_url = @query_url
        end
        return @final_url
      end
      @final_url = @query_url
    end
def final_url
      return @final_url if !@final_url.nil?
      location = final_location(FaviconParty::HTTPClient.head(@query_url))
      if !location.nil?
        if location =~ /\Ahttp/
          @final_url = URI.encode location
        else
          uri = URI @query_url
          root = "#{uri.scheme}://#{uri.host}"
          @final_url = URI.encode URI.join(root, location).to_s
        end
      end
      if !@final_url.nil?
        if %w( 127.0.0.1 localhost ).any? {|host| @final_url.include? host }
          # TODO Exception for invalid final urls
          @final_url = @query_url
        end
        return @final_url
      end
      @final_url = @query_url
    end
def final_url return @final_url if ! @final_url . nil? location = final_location ( FaviconParty :: HTTPClient . head ( @query_url ) ) if ! location . nil? if location =~ / \A / @final_url = URI . encode location else uri = URI @query_url root = "#{uri.scheme}://#{uri.host}" @final_url = URI . encode URI . join ( root , location ) . to_s end end if ! @final_url . nil? if %w( 127.0.0.1 localhost ) . any? { | host | @final_url . include? host } # TODO Exception for invalid final urls @final_url = @query_url end return @final_url end @final_url = @query_url end
Follow redirects from the query url to get to the last url
Follow redirects from the query url to get to the last url