We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cfb14aa commit dac0ae2Copy full SHA for dac0ae2
lib/geocoder/ip_address.rb
@@ -20,7 +20,8 @@ def private?
20
end
21
22
def valid?
23
- !!((self =~ Resolv::IPv4::Regex) || (self =~ Resolv::IPv6::Regex))
+ ip = self[/(?<=\[)(.*?)(?=\])/] || self
24
+ !!((ip =~ Resolv::IPv4::Regex) || (ip =~ Resolv::IPv6::Regex))
25
26
27
test/unit/ip_address_test.rb
@@ -13,6 +13,7 @@ def test_valid
13
assert !Geocoder::IpAddress.new("232.65.123").valid?
14
assert !Geocoder::IpAddress.new("::ffff:123.456.789").valid?
15
assert !Geocoder::IpAddress.new("Test\n232.65.123.94").valid?
16
+ assert Geocoder::IpAddress.new("[3ffe:0b00:000:0000:0001:0000:0000:000a]:80").valid?
17
18
19
def test_internal
0 commit comments