diff options
Diffstat (limited to 'deps/npm/node_modules/cidr-regex')
-rw-r--r-- | deps/npm/node_modules/cidr-regex/LICENSE | 22 | ||||
-rw-r--r-- | deps/npm/node_modules/cidr-regex/README.md | 64 | ||||
-rw-r--r-- | deps/npm/node_modules/cidr-regex/index.js | 13 | ||||
-rw-r--r-- | deps/npm/node_modules/cidr-regex/package.json | 78 |
4 files changed, 177 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cidr-regex/LICENSE b/deps/npm/node_modules/cidr-regex/LICENSE new file mode 100644 index 0000000000..9669c20f85 --- /dev/null +++ b/deps/npm/node_modules/cidr-regex/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) silverwind +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/npm/node_modules/cidr-regex/README.md b/deps/npm/node_modules/cidr-regex/README.md new file mode 100644 index 0000000000..d24d7071ae --- /dev/null +++ b/deps/npm/node_modules/cidr-regex/README.md @@ -0,0 +1,64 @@ +# 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) + +> Regular expression for matching IP addresses in CIDR notation + +## Install + +```sh +$ npm install --save cidr-regex +``` + +## Usage + +```js +const cidrRegex = require('cidr-regex'); + +// Contains a CIDR IP address? +cidrRegex().test('foo 192.168.0.1/24'); +//=> true + +// Is a CIDR IP address? +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'); +//=> 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'] +``` + +## API + +### cidrRegex([options]) + +Returns a regex for matching both IPv4 and IPv6 CIDR IP addresses. + +### cidrRegex.v4([options]) + +Returns a regex for matching IPv4 CIDR IP addresses. + +### cidrRegex.v6([options]) + +Returns a regex for matching IPv6 CIDR IP addresses. + +#### options.exact + +Type: `boolean`<br> +Default: `false` *(Matches any CIDR IP address in a string)* + +Only match an exact string. Useful with `RegExp#test()` to check if a string is a CIDR IP address. + + +## Related + +- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation +- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address +- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses + +## License + +© [silverwind](https://github.com/silverwind), distributed under BSD licence + +Based on previous work by [Felipe Apostol](https://github.com/flipjs) diff --git a/deps/npm/node_modules/cidr-regex/index.js b/deps/npm/node_modules/cidr-regex/index.js new file mode 100644 index 0000000000..190cefa7bf --- /dev/null +++ b/deps/npm/node_modules/cidr-regex/index.js @@ -0,0 +1,13 @@ +"use strict"; + +const ipRegex = require("ip-regex"); + +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 ip = module.exports = opts => opts && opts.exact ? + new RegExp(`(?:^${v4}$)|(?:^${v6}$)`) : + new RegExp(`(?:${v4})|(?:${v6})`, "g"); + +ip.v4 = opts => opts && opts.exact ? new RegExp(`^${v4}$`) : new RegExp(v4, "g"); +ip.v6 = opts => opts && opts.exact ? new RegExp(`^${v6}$`) : new RegExp(v6, "g"); diff --git a/deps/npm/node_modules/cidr-regex/package.json b/deps/npm/node_modules/cidr-regex/package.json new file mode 100644 index 0000000000..2b84d9c194 --- /dev/null +++ b/deps/npm/node_modules/cidr-regex/package.json @@ -0,0 +1,78 @@ +{ + "_from": "cidr-regex@^2.0.8", + "_id": "cidr-regex@2.0.8", + "_inBundle": false, + "_integrity": "sha512-3r0E5P6Oeg4SCvEERX7W5fPkPz8nKWwGzU6RJ/VvROOsqiq5g6sf43c/g+sUpA29Htc7R0SG15P/Scr5lfap4g==", + "_location": "/cidr-regex", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "cidr-regex@^2.0.8", + "name": "cidr-regex", + "escapedName": "cidr-regex", + "rawSpec": "^2.0.8", + "saveSpec": null, + "fetchSpec": "^2.0.8" + }, + "_requiredBy": [ + "/is-cidr" + ], + "_resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-2.0.8.tgz", + "_shasum": "c79bae6223d241c0860d93bfde1fb1c1c4fdcab6", + "_spec": "cidr-regex@^2.0.8", + "_where": "/Users/rebecca/code/npm/node_modules/is-cidr", + "author": { + "name": "silverwind", + "email": "me@silverwind.io" + }, + "bugs": { + "url": "https://github.com/silverwind/cidr-regex/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Felipe Apostol", + "email": "flipjs.io@gmail.com", + "url": "http://flipjs.io/" + } + ], + "dependencies": { + "ip-regex": "^2.1.0" + }, + "deprecated": false, + "description": "Regular expression for matching IP addresses in CIDR notation", + "devDependencies": { + "ava": "^0.25.0", + "eslint": "^4.18.2", + "eslint-config-silverwind": "^1.0.37", + "updates": "^2.3.1" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/silverwind/cidr-regex#readme", + "keywords": [ + "cidr", + "regex", + "notation", + "cidr notation", + "prefix", + "prefixes", + "ip", + "ip address" + ], + "license": "BSD-2-Clause", + "name": "cidr-regex", + "repository": { + "type": "git", + "url": "git+https://github.com/silverwind/cidr-regex.git" + }, + "scripts": { + "test": "make test" + }, + "version": "2.0.8" +} |