Skip to content
Snippets Groups Projects
Commit 54b6484a authored by toydi's avatar toydi
Browse files

Return valid result when searching for loopback address using ipinfo.io

parent 07aeeab9
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,14 @@ module Geocoder::Lookup ...@@ -42,7 +42,14 @@ module Geocoder::Lookup
end end
def reserved_result(ip) def reserved_result(ip)
{"message" => "Input string is not a valid IP address", "code" => 401} {
"ip" => ip,
"city" => "",
"region" => "",
"country" => "",
"loc" => "0,0",
"postal" => ""
}
end end
def query_url_params(query) def query_url_params(query)
......
...@@ -14,4 +14,12 @@ class IpinfoIoTest < GeocoderTestCase ...@@ -14,4 +14,12 @@ class IpinfoIoTest < GeocoderTestCase
query = Geocoder::Query.new("8.8.8.8") query = Geocoder::Query.new("8.8.8.8")
assert_match(/^https:/, query.url) assert_match(/^https:/, query.url)
end end
def test_ipinfo_io_lookup_loopback_address
Geocoder.configure(:ip_lookup => :ipinfo_io, :use_https => true)
result = Geocoder.search("127.0.0.1").first
assert_equal 0.0, result.longitude
assert_equal 0.0, result.latitude
assert_equal "127.0.0.1", result.ip
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment