]> git.openstreetmap.org Git - rails.git/commitdiff
Fix hostip.info fallback
authorTom Hughes <tom@compton.nu>
Wed, 1 Jan 2020 22:28:08 +0000 (22:28 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 1 Jan 2020 22:28:08 +0000 (22:28 +0000)
lib/osm.rb

index bc3eb48c5bcaf71034ff670d36546fb27c67a353..26ebca09f9a7a235a820b533be5c8742b6d89e09 100644 (file)
@@ -513,7 +513,7 @@ module OSM
   def self.ip_to_country(ip_address)
     ipinfo = maxmind_database.lookup(ip_address) if Settings.key?(:maxmind_database)
 
   def self.ip_to_country(ip_address)
     ipinfo = maxmind_database.lookup(ip_address) if Settings.key?(:maxmind_database)
 
-    if ipinfo.found?
+    if ipinfo&.found?
       country = ipinfo.country.iso_code
     else
       country = http_client.get("https://api.hostip.info/country.php?ip=#{ip_address}").body
       country = ipinfo.country.iso_code
     else
       country = http_client.get("https://api.hostip.info/country.php?ip=#{ip_address}").body