Skip to content

Commit

Permalink
Merge pull request #1447 from gdomingu/add-support-ip-search-with-port
Browse files Browse the repository at this point in the history
Support IP search with port
  • Loading branch information
alexreisner committed Apr 14, 2020
2 parents cfb14aa + dac0ae2 commit 5ce27f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/geocoder/ip_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def private?
end

def valid?
!!((self =~ Resolv::IPv4::Regex) || (self =~ Resolv::IPv6::Regex))
ip = self[/(?<=\[)(.*?)(?=\])/] || self
!!((ip =~ Resolv::IPv4::Regex) || (ip =~ Resolv::IPv6::Regex))
end
end
end
1 change: 1 addition & 0 deletions test/unit/ip_address_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_valid
assert !Geocoder::IpAddress.new("232.65.123").valid?
assert !Geocoder::IpAddress.new("::ffff:123.456.789").valid?
assert !Geocoder::IpAddress.new("Test\n232.65.123.94").valid?
assert Geocoder::IpAddress.new("[3ffe:0b00:000:0000:0001:0000:0000:000a]:80").valid?
end

def test_internal
Expand Down

0 comments on commit 5ce27f0

Please sign in to comment.