diff options
author | Akira Matsuda <[email protected]> | 2023-01-07 04:10:12 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-02-23 17:56:08 +0000 |
commit | 73dd3ce03e3a0a58a157607385418d7a3724752c (patch) | |
tree | 1a1de05790a834fc834cf451a7107320f6f9a115 | |
parent | 6ad52e336d1733a0740186b7ee4df60c6e79030a (diff) |
[ruby/ipaddr] Prefer String#start_with? over Regexp.match
https://github.com/ruby/ipaddr/commit/054fe12ec4
-rw-r--r-- | lib/ipaddr.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb index 35e2848939..a673445532 100644 --- a/lib/ipaddr.rb +++ b/lib/ipaddr.rb @@ -674,7 +674,7 @@ class IPAddr end octets.inject(0) { |i, s| (n = s.to_i) < 256 or raise InvalidAddressError, "invalid address: #{@addr}" - s.match(/\A0./) and raise InvalidAddressError, "zero-filled number in IPv4 address is ambiguous: #{@addr}" + (s != '0') && s.start_with?('0') and raise InvalidAddressError, "zero-filled number in IPv4 address is ambiguous: #{@addr}" i << 8 | n } end |