Skip to content

Commit

Permalink
Merge pull request #480 from latis-sw/hotfix/recover-from-redirect-ex…
Browse files Browse the repository at this point in the history
…ceptions

Don't care if ip lookup fails -- continue anyway
  • Loading branch information
andersodt authored and GitHub Enterprise committed Aug 31, 2017
2 parents 8e618e7 + b4f854e commit 86664d2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/models/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ class Url < ApplicationRecord
end

def add_click!(client_ip)
uri = URI.parse("http://freegeoip.net/json/#{client_ip}")
begin
uri = URI.parse("http://freegeoip.net/json/#{client_ip}")

result = Net::HTTP.start(uri.host, uri.port) do |http|
request = Net::HTTP::Get.new uri
response = http.request request
response.body
result = Net::HTTP.start(uri.host, uri.port) do |http|
request = Net::HTTP::Get.new uri
response = http.request request
response.body
end
rescue
result = ''
end

country_code = if result.include?('country_code')
Expand Down

0 comments on commit 86664d2

Please sign in to comment.