From c4264dd7568d5d66bddcd87e6ea7d94e81d4edef Mon Sep 17 00:00:00 2001 From: Matthew Lemieux Date: Wed, 18 Dec 2024 14:27:01 -0600 Subject: [PATCH] Fixed NoMethod error when an IPAddr instance is an argument of Geocoder::Query.new fixes #1673 --- lib/geocoder/query.rb | 2 +- test/unit/query_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/geocoder/query.rb b/lib/geocoder/query.rb index c8d2a67a0..c509a7bfb 100644 --- a/lib/geocoder/query.rb +++ b/lib/geocoder/query.rb @@ -23,7 +23,7 @@ def sanitized_text text.split(/\s*,\s*/).join(',') end else - text.strip + text.to_s.strip end end diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index ac3a313a1..27a35172b 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -5,10 +5,14 @@ class QueryTest < GeocoderTestCase def test_detect_ipv4 assert Geocoder::Query.new("232.65.123.94").ip_address? + ip = IPAddr.new("232.65.123.94") + assert Geocoder::Query.new(ip).ip_address? end def test_detect_ipv6 assert Geocoder::Query.new("3ffe:0b00:0000:0000:0001:0000:0000:000a").ip_address? + ip = IPAddr.new("3ffe:0b00:0000:0000:0001:0000:0000:000a") + assert Geocoder::Query.new(ip).ip_address? end def test_detect_non_ip_address