Skip to content

Commit c4264dd

Browse files
author
Matthew Lemieux
committed
Fixed NoMethod error when an IPAddr instance is an argument of Geocoder::Query.new
fixes #1673
1 parent 134eacb commit c4264dd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/geocoder/query.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def sanitized_text
2323
text.split(/\s*,\s*/).join(',')
2424
end
2525
else
26-
text.strip
26+
text.to_s.strip
2727
end
2828
end
2929

test/unit/query_test.rb

+4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ class QueryTest < GeocoderTestCase
55

66
def test_detect_ipv4
77
assert Geocoder::Query.new("232.65.123.94").ip_address?
8+
ip = IPAddr.new("232.65.123.94")
9+
assert Geocoder::Query.new(ip).ip_address?
810
end
911

1012
def test_detect_ipv6
1113
assert Geocoder::Query.new("3ffe:0b00:0000:0000:0001:0000:0000:000a").ip_address?
14+
ip = IPAddr.new("3ffe:0b00:0000:0000:0001:0000:0000:000a")
15+
assert Geocoder::Query.new(ip).ip_address?
1216
end
1317

1418
def test_detect_non_ip_address

0 commit comments

Comments
 (0)