Comparing version 5.0.0 to 5.0.1
26
index.js
@@ -12,15 +12,33 @@ import ipRegex from 'ip-regex'; | ||
export function isIP(string) { | ||
return isMatch(ipRegex({exact: true}), string.slice(0, maxIPv6Length), options); | ||
if (string.length > maxIPv6Length) { | ||
return false; | ||
} | ||
return isMatch(ipRegex({exact: true}), string, options); | ||
} | ||
export function isIPv6(string) { | ||
return isMatch(ipRegex.v6({exact: true}), string.slice(0, maxIPv6Length), options); | ||
if (string.length > maxIPv6Length) { | ||
return false; | ||
} | ||
return isMatch(ipRegex.v6({exact: true}), string, options); | ||
} | ||
export function isIPv4(string) { | ||
return isMatch(ipRegex.v4({exact: true}), string.slice(0, maxIPv4Length), options); | ||
if (string.length > maxIPv4Length) { | ||
return false; | ||
} | ||
return isMatch(ipRegex.v4({exact: true}), string, options); | ||
} | ||
export function ipVersion(string) { | ||
return isIP(string) ? (isIPv6(string) ? 6 : 4) : undefined; | ||
if (isIPv6(string)) { | ||
return 6; | ||
} | ||
if (isIPv4(string)) { | ||
return 4; | ||
} | ||
} |
{ | ||
"name": "is-ip", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Check if a string is an IP address", | ||
@@ -53,4 +53,4 @@ "license": "MIT", | ||
"tsd": "^0.22.0", | ||
"xo": "^0.51.0" | ||
"xo": "^0.54.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5041
79