`isInSubnet` not throwing on invalid subnets
spencerwilson-optimizely opened this issue · comments
Spencer Wilson commented
The isInSubnet
docs state
Will throw an Error if the address or subnet are not valid IP addresses
but some subnets with invalid IP address components do not cause the function to throw. Here are an examples with an IPv4-like thing and IPv6-like thing:
> isIP('1.352352352')
0
> isInSubnet('1.3.3.4', '1.352352352/32')
false
> isIP('11:22:33:44:55:66:77:88:99:1010')
0
> isInSubnet('1.3.3.4', '11:22:33:44:55:66:77:88:99:1010/32')
false
Notably, the specialized functions IPv4.isInSubnet
and IPv6.isInSubnet
don't exhibit issue:
> IPv4.isInSubnet('1.3.3.4', '1.352352352/32')
Thrown:
Error: not a valid IPv4 address: 1.352352352
> IPv6.isInSubnet('::ffff:1.2.3.4', '11:22:33:44:55:66:77:88:99:1010/32')
Thrown:
Error: not a valid IPv6 address: 11:22:33:44:55:66:77:88:99:1010
P.S. Thank you for writing such a well-documented and single-purpose package!