From b0f414f7f53fae5942d2aba6b9aec5b4863475ad Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Wed, 16 Mar 2022 16:42:25 +0200 Subject: [PATCH] DEV: Remove unused uri parameter (#16179) The parameter is not used and it did not work properly anyway because sometimes `@uri` is used instead of `uri`, which can be different. --- lib/final_destination.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/final_destination.rb b/lib/final_destination.rb index 11561f17f13..9bc5d4040ee 100644 --- a/lib/final_destination.rb +++ b/lib/final_destination.rb @@ -133,18 +133,18 @@ class FinalDestination # this is a new interface for simply getting # N bytes accounting for all internal logic - def get(uri = @uri, redirects = @limit, extra_headers: {}, &blk) + def get(redirects = @limit, extra_headers: {}, &blk) raise "Must specify block" unless block_given? - if uri && uri.port == 80 && FinalDestination.is_https_domain?(uri.hostname) - uri.scheme = "https" - uri = URI(uri.to_s) + if @uri && @uri.port == 80 && FinalDestination.is_https_domain?(@uri.hostname) + @uri.scheme = "https" + @uri = URI(@uri.to_s) end return if !validate_uri - return if @stop_at_blocked_pages && blocked_domain?(uri) + return if @stop_at_blocked_pages && blocked_domain?(@uri) - result, headers_subset = safe_get(uri, &blk) + result, headers_subset = safe_get(@uri, &blk) cookie = headers_subset.set_cookie location = headers_subset.location @@ -153,23 +153,23 @@ class FinalDestination end if result == :redirect - old_port = uri.port - location = "#{uri.scheme}://#{uri.host}#{location}" if location[0] == "/" - uri = uri(location) + old_port = @uri.port + location = "#{@uri.scheme}://#{@uri.host}#{location}" if location[0] == "/" + @uri = uri(location) # https redirect, so just cache that whole new domain is https - if old_port == 80 && uri&.port == 443 && (URI::HTTPS === uri) - FinalDestination.cache_https_domain(uri.hostname) + if old_port == 80 && @uri&.port == 443 && (URI::HTTPS === @uri) + FinalDestination.cache_https_domain(@uri.hostname) end - return nil if !uri + return nil if !@uri extra = nil extra = { 'Cookie' => cookie } if cookie - get(uri, redirects - 1, extra_headers: extra, &blk) + get(redirects - 1, extra_headers: extra, &blk) elsif result == :ok - uri.to_s + @uri.to_s else nil end