FIX: preserve github fragment URL

This commit is contained in:
Arpit Jalan
2018-12-19 11:57:07 +05:30
parent cae5ba7356
commit 1ab91f0474
3 changed files with 22 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ class FinalDestination
@opts = opts || {}
@force_get_hosts = @opts[:force_get_hosts] || []
@preserve_fragment_url_hosts = @opts[:preserve_fragment_url_hosts] || []
@opts[:max_redirects] ||= 5
@opts[:lookup_ip] ||= lambda { |host| FinalDestination.lookup_ip(host) }
@@ -59,6 +60,7 @@ class FinalDestination
@limited_ips = []
@verbose = @opts[:verbose] || false
@timeout = @opts[:timeout] || nil
@preserve_fragment_url = @preserve_fragment_url_hosts.any? { |host| hostname_matches?(host) }
end
def self.connection_timeout
@@ -210,6 +212,7 @@ class FinalDestination
if location
old_port = @uri.port
location = "#{location}##{@uri.fragment}" if @preserve_fragment_url && @uri.fragment.present?
location = "#{@uri.scheme}://#{@uri.host}#{location}" if location[0] == "/"
@uri = uri(location)
@limit -= 1