Skip to content

Commit

Permalink
[ruby/ipaddr] Prefer String#start_with? over Regexp.match
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda authored and matzbot committed Feb 23, 2024
1 parent 6ad52e3 commit 73dd3ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ipaddr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def in_addr(addr)
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
Expand Down

0 comments on commit 73dd3ce

Please sign in to comment.