Skip to content
Snippets Groups Projects
Commit 12ffe1a9 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge branch 'master' of git://github.com/brian-ewell/geocoder into brian-ewell-master

parents b418e0e4 9db067d3
No related branches found
No related tags found
No related merge requests found
......@@ -115,7 +115,7 @@ module Geocoder
# dot-delimited numbers.
#
def ip_address?(value)
!!value.to_s.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
!!value.to_s.match(/^(::ffff:)?(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
end
##
......
......@@ -6,8 +6,10 @@ class InputHandlingTest < Test::Unit::TestCase
def test_ip_address_detection
assert Geocoder.send(:ip_address?, "232.65.123.94")
assert Geocoder.send(:ip_address?, "666.65.123.94") # technically invalid
assert Geocoder.send(:ip_address?, "::ffff:12.34.56.78")
assert !Geocoder.send(:ip_address?, "232.65.123.94.43")
assert !Geocoder.send(:ip_address?, "232.65.123")
assert !Geocoder.send(:ip_address?, "::ffff:123.456.789")
end
def test_blank_query_detection
......
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