cidr-regex
Advanced tools
Comparing version 3.1.1 to 4.0.0
15
index.js
@@ -1,12 +0,8 @@ | ||
"use strict"; | ||
import ipRegex from "ip-regex"; | ||
const ipRegex = require("ip-regex"); | ||
const defaultOpts = {exact: false}; | ||
const v4str = `${ipRegex.v4().source}\\/(3[0-2]|[12]?[0-9])`; | ||
const v6str = `${ipRegex.v6().source}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`; | ||
// can not precompile the non-exact regexes because global flag makes the regex object stateful | ||
// which would require the user to reset .lastIndex on subsequent calls | ||
// pre-compile only the exact regexes as global flag makes regex objects stateful | ||
const v4exact = new RegExp(`^${v4str}$`); | ||
@@ -16,4 +12,5 @@ const v6exact = new RegExp(`^${v6str}$`); | ||
module.exports = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g"); | ||
module.exports.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g"); | ||
module.exports.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g"); | ||
const cidrRegex = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g"); | ||
export const v4 = cidrRegex.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g"); | ||
export const v6 = cidrRegex.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g"); | ||
export default cidrRegex; |
{ | ||
"name": "cidr-regex", | ||
"version": "3.1.1", | ||
"version": "4.0.0", | ||
"description": "Regular expression for matching IP addresses in CIDR notation", | ||
@@ -11,7 +11,6 @@ "author": "silverwind <me@silverwind.io>", | ||
"license": "BSD-2-Clause", | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"type": "module", | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=14" | ||
}, | ||
@@ -33,12 +32,12 @@ "files": [ | ||
"dependencies": { | ||
"ip-regex": "^4.1.0" | ||
"ip-regex": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "7.8.1", | ||
"eslint-config-silverwind": "18.0.8", | ||
"jest": "26.4.2", | ||
"tsd": "0.13.1", | ||
"updates": "10.3.6", | ||
"versions": "8.4.3" | ||
"eslint": "8.23.1", | ||
"eslint-config-silverwind": "54.0.2", | ||
"jest": "29.0.3", | ||
"tsd": "0.24.1", | ||
"updates": "13.1.5", | ||
"versions": "9.3.0" | ||
} | ||
} |
@@ -56,2 +56,3 @@ # cidr-regex | ||
- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses | ||
- [cidr-tools](https://github.com/silverwind/cidr-tools) - Tools to work with IPv4 and IPv6 CIDR network lists | ||
@@ -58,0 +59,0 @@ ## License |
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
5917
63
Yes
55
+ Addedip-regex@5.0.0(transitive)
- Removedip-regex@4.3.0(transitive)
Updatedip-regex@^5.0.0