ortexx / ip-cidr

Module for working with CIDR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IPCIDR may be not compatible with isValidAddress

tangent-q opened this issue · comments

Not sure if this is expected but IPCIDR.isValidAddress is not enough to ensure new IPCIDR will pass always.

IPCIDR.isValidAddress('50.165.190.0') // true
new IPCIDR('50.165.190.0')
// Thrown:
// Error: Invalid CIDR address.
//    at new IPCIDR (/private/tmp/node_modules/ip-cidr/index.js:9:13)

If isValidAddress is meant only for IP the address without the mask, then would be nice to have isValidCIDRAddress as well.

It is for both, either an ip or a cidr. The function is necessary to find out if the value is an address, not something else. IPCIDR constructor is not directly connected to that function. You just can't create an instance without bits specifying.

Got it @ortexx , thanks for the clarification. would be nice to have a isValidCIDR also then.