cidr-regex
Advanced tools
Comparing version 2.0.10 to 3.0.0
@@ -5,4 +5,4 @@ "use strict"; | ||
const v4 = ipRegex.v4().source + "\\/(3[0-2]|[12]?[0-9])"; | ||
const v6 = ipRegex.v6().source + "\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])"; | ||
const v4 = `${ipRegex.v4().source}\\/(3[0-2]|[12]?[0-9])`; | ||
const v6 = `${ipRegex.v6().source}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`; | ||
@@ -9,0 +9,0 @@ const cidr = module.exports = opts => opts && opts.exact ? |
{ | ||
"name": "cidr-regex", | ||
"version": "2.0.10", | ||
"version": "3.0.0", | ||
"description": "Regular expression for matching IP addresses in CIDR notation", | ||
@@ -15,3 +15,3 @@ "author": "silverwind <me@silverwind.io>", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=10" | ||
}, | ||
@@ -32,10 +32,11 @@ "files": [ | ||
"dependencies": { | ||
"ip-regex": "^2.1.0" | ||
"ip-regex": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.6.0", | ||
"eslint-config-silverwind": "^2.0.9", | ||
"updates": "^4.3.0", | ||
"ver": "^2.0.1" | ||
"eslint": "7.0.0", | ||
"eslint-config-silverwind": "13.1.0", | ||
"jest": "26.0.1", | ||
"updates": "10.2.11", | ||
"versions": "8.2.9" | ||
} | ||
} |
# cidr-regex | ||
[![](https://img.shields.io/npm/v/cidr-regex.svg?style=flat)](https://www.npmjs.org/package/cidr-regex) [![](https://img.shields.io/npm/dm/cidr-regex.svg)](https://www.npmjs.org/package/cidr-regex) [![](https://api.travis-ci.org/silverwind/cidr-regex.svg?style=flat)](https://travis-ci.org/silverwind/cidr-regex) | ||
[![](https://img.shields.io/npm/v/cidr-regex.svg?style=flat)](https://www.npmjs.org/package/cidr-regex) [![](https://img.shields.io/npm/dm/cidr-regex.svg)](https://www.npmjs.org/package/cidr-regex) | ||
> Regular expression for matching IP addresses in CIDR notation | ||
## Install | ||
## Usage | ||
```sh | ||
$ npm install --save cidr-regex | ||
$ npm i cidr-regex | ||
``` | ||
## Usage | ||
```js | ||
const cidrRegex = require('cidr-regex'); | ||
const cidrRegex = require("cidr-regex"); | ||
// Contains a CIDR IP address? | ||
cidrRegex().test('foo 192.168.0.1/24'); | ||
cidrRegex().test("foo 192.168.0.1/24"); | ||
//=> true | ||
// Is a CIDR IP address? | ||
cidrRegex({exact: true}).test('foo 192.168.0.1/24'); | ||
cidrRegex({exact: true}).test("foo 192.168.0.1/24"); | ||
//=> false | ||
cidrRegex.v6({exact: true}).test('1:2:3:4:5:6:7:8/64'); | ||
cidrRegex.v6({exact: true}).test("1:2:3:4:5:6:7:8/64"); | ||
//=> true | ||
'foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz'.match(cidrRegex()); | ||
//=> ['192.168.0.1/24', '1:2:3:4:5:6:7:8/64'] | ||
// Extract CIDRs from string | ||
"foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz".match(cidrRegex()); | ||
//=> ["192.168.0.1/24", "1:2:3:4:5:6:7:8/64"] | ||
``` | ||
## API | ||
### cidrRegex([options]) | ||
@@ -53,3 +51,2 @@ | ||
## Related | ||
@@ -56,0 +53,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
4280
5
62
+ Addedip-regex@4.3.0(transitive)
- Removedip-regex@2.1.0(transitive)
Updatedip-regex@^4.1.0