Class: PhisherPhinder::HostResponsePolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/phisher_phinder/host_response_policy.rb

Instance Method Summary collapse

Instance Method Details

#next_url(url, response) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/phisher_phinder/host_response_policy.rb', line 5

def next_url(url, response)
  location_header = response.headers['Location']

  if [301, 302, 303, 307, 308].include?(response.status) && location_header && !location_header.empty?
    if response.headers['Location'] =~ %r{\A/}
      url.merge(response.headers['Location'])
    else
      URI.parse(response.headers['Location'])
    end
  end
end