Closed asergeyev closed 3 years ago
yes, isCorrect does not mean “is it valid”, it should probably be renamed to reflect what it actually means which is something closer to “is it the most compact representation it can be” :)
so in this case the behavior is correct, the leading zero can be omitted for a more compact address
On Tue, Apr 6 2021 at 10:40, Alex Sergeyev @.***> wrote:
the isCorrect() on Address6 currently will return false if the address includes leading 0 in segment of the IP. I did not check v4 as it's not popular to keep zeroes around in it.
Quick test: [image: image] https://user-images.githubusercontent.com/715656/113754762-8ea44080-96dd-11eb-9a17-1b6680906077.png
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/beaugunderson/ip-address/issues/130, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAPCX66HJ2YDYFT57ROLC3THNBPRANCNFSM42PF2TNQ .
Gotcha, so in case of an invalid address it's guaranteed to throw an exception?
ps. isCompacted() might be better for sure but then you need to write compactForm() or something like it :)
Ah, silly me it's already isCorrect/correctForm pair. Thanks for your lib, your work, and answering me!
the isCorrect() on Address6 currently will return false if the address includes leading 0 in segment of the IP. I did not check v4 as it's not popular to keep zeroes around in it.
Quick test:
P.s. Also this prevents positive isCorrect on canonicalForm returned IP address; seems silly