Describe the bug
Currently, the isIPRange() method only supports IPv4 addresses. It should be extended to support IPv6 addresses as well.
Examples
isIPRange("192.0.2.0/24") // IPv4 CIDR is `true`
isIPRange("2001:db8::/32") // IPv6 CIDR is `false`
Additional context
I suppose "isIPRange" check the string before '/' is valid IP or not. Maybe you should use valid ipv6 instead of "2001:db8::"
edit: sorry i've checked the code here the return statement of isIPRange
return isIP(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0;
so it validate only IPv4. It may be rewritten as
return (isIP(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0) ||
(isIP(parts[0],6) && parts[1] <= 64 && parts[1] >= 0);
You can open PR.
@AnandChowdhary I opened a PR. after they review, it can be merged
This PR should resolve this issue: https://github.com/validatorjs/validator.js/pull/1594
Most helpful comment
@AnandChowdhary I opened a PR. after they review, it can be merged