Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuy Adorno <ruyadorno@hotmail.com>2020-09-30 20:26:31 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2020-09-30 20:26:31 +0300
commita27e8d00664e5d4c3e81d664253a10176adb39c8 (patch)
treea028261d73d4e99b649edea99b85306b08b3d07b /node_modules/ip-regex
parent2aa9a1f8a5773b9a960b14b51c8111fb964bc9ae (diff)
is-cidr@4.0.2
Diffstat (limited to 'node_modules/ip-regex')
-rw-r--r--node_modules/ip-regex/index.d.ts70
-rw-r--r--node_modules/ip-regex/index.js26
-rw-r--r--node_modules/ip-regex/license20
-rw-r--r--node_modules/ip-regex/package.json85
-rw-r--r--node_modules/ip-regex/readme.md27
5 files changed, 160 insertions, 68 deletions
diff --git a/node_modules/ip-regex/index.d.ts b/node_modules/ip-regex/index.d.ts
new file mode 100644
index 000000000..0999ed287
--- /dev/null
+++ b/node_modules/ip-regex/index.d.ts
@@ -0,0 +1,70 @@
+declare namespace ip {
+ interface Options {
+ /**
+ Only match an exact string. Useful with `RegExp#test()` to check if a string is an IP address. *(`false` matches any IP address in a string)*
+
+ @default false
+ */
+ readonly exact?: boolean;
+
+ /**
+ Include boundaries in the regex. When `true`, `192.168.0.2000000000` will report as an invalid IPv4 address. If this option is not set, the mentioned IPv4 address would report as valid (ignoring the trailing zeros).
+
+ @default false
+ */
+ readonly includeBoundaries?: boolean;
+ }
+}
+
+declare const ip: {
+ /**
+ Regular expression for matching IP addresses.
+
+ @returns A regex for matching both IPv4 and IPv6.
+
+ @example
+ ```
+ import ipRegex = require('ip-regex');
+
+ // Contains an IP address?
+ ipRegex().test('unicorn 192.168.0.1');
+ //=> true
+
+ // Is an IP address?
+ ipRegex({exact: true}).test('unicorn 192.168.0.1');
+ //=> false
+
+ 'unicorn 192.168.0.1 cake 1:2:3:4:5:6:7:8 rainbow'.match(ipRegex());
+ //=> ['192.168.0.1', '1:2:3:4:5:6:7:8']
+
+ // Contains an IP address?
+ ipRegex({includeBoundaries: true}).test('192.168.0.2000000000');
+ //=> false
+
+ // Matches an IP address?
+ '192.168.0.2000000000'.match(ipRegex({includeBoundaries: true}));
+ //=> null
+ ```
+ */
+ (options?: ip.Options): RegExp;
+
+ /**
+ @returns A regex for matching IPv4.
+ */
+ v4(options?: ip.Options): RegExp;
+
+ /**
+ @returns A regex for matching IPv6.
+
+ @example
+ ```
+ import ipRegex = require('ip-regex');
+
+ ipRegex.v6({exact: true}).test('1:2:3:4:5:6:7:8');
+ //=> true
+ ```
+ */
+ v6(options?: ip.Options): RegExp;
+};
+
+export = ip;
diff --git a/node_modules/ip-regex/index.js b/node_modules/ip-regex/index.js
index 973e5f41c..1ac39f6a9 100644
--- a/node_modules/ip-regex/index.js
+++ b/node_modules/ip-regex/index.js
@@ -1,8 +1,13 @@
'use strict';
-const v4 = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}';
+const word = '[a-fA-F\\d:]';
+const b = options => options && options.includeBoundaries ?
+ `(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))` :
+ '';
-const v6seg = '[0-9a-fA-F]{1,4}';
+const v4 = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';
+
+const v6seg = '[a-fA-F\\d]{1,4}';
const v6 = `
(
(?:${v6seg}:){7}(?:${v6seg}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
@@ -16,9 +21,16 @@ const v6 = `
)(%[0-9a-zA-Z]{1,})? // %eth0 %1
`.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();
-const ip = module.exports = opts => opts && opts.exact ?
- new RegExp(`(?:^${v4}$)|(?:^${v6}$)`) :
- new RegExp(`(?:${v4})|(?:${v6})`, 'g');
+// Pre-compile only the exact regexes because adding a global flag make regexes stateful
+const v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`);
+const v4exact = new RegExp(`^${v4}$`);
+const v6exact = new RegExp(`^${v6}$`);
+
+const ip = options => options && options.exact ?
+ v46Exact :
+ new RegExp(`(?:${b(options)}${v4}${b(options)})|(?:${b(options)}${v6}${b(options)})`, 'g');
+
+ip.v4 = options => options && options.exact ? v4exact : new RegExp(`${b(options)}${v4}${b(options)}`, 'g');
+ip.v6 = options => options && options.exact ? v6exact : new RegExp(`${b(options)}${v6}${b(options)}`, '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');
+module.exports = ip;
diff --git a/node_modules/ip-regex/license b/node_modules/ip-regex/license
index 654d0bfe9..e7af2f771 100644
--- a/node_modules/ip-regex/license
+++ b/node_modules/ip-regex/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/ip-regex/package.json b/node_modules/ip-regex/package.json
index aa5147928..b67a413b6 100644
--- a/node_modules/ip-regex/package.json
+++ b/node_modules/ip-regex/package.json
@@ -1,45 +1,44 @@
{
- "name": "ip-regex",
- "version": "2.1.0",
- "description": "Regular expression for matching IP addresses (IPv4 & IPv6)",
- "license": "MIT",
- "repository": "sindresorhus/ip-regex",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=4"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "ip",
- "ipv6",
- "ipv4",
- "regex",
- "regexp",
- "re",
- "match",
- "test",
- "find",
- "text",
- "pattern",
- "internet",
- "protocol",
- "address",
- "validate"
- ],
- "devDependencies": {
- "ava": "*",
- "xo": "*"
- },
- "xo": {
- "esnext": true
- }
+ "name": "ip-regex",
+ "version": "4.2.0",
+ "description": "Regular expression for matching IP addresses (IPv4 & IPv6)",
+ "license": "MIT",
+ "repository": "sindresorhus/ip-regex",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "ip",
+ "ipv6",
+ "ipv4",
+ "regex",
+ "regexp",
+ "re",
+ "match",
+ "test",
+ "find",
+ "text",
+ "pattern",
+ "internet",
+ "protocol",
+ "address",
+ "validate"
+ ],
+ "devDependencies": {
+ "ava": "^1.4.1",
+ "tsd": "^0.7.2",
+ "xo": "^0.24.0"
+ }
}
diff --git a/node_modules/ip-regex/readme.md b/node_modules/ip-regex/readme.md
index 66bc7f273..08632c054 100644
--- a/node_modules/ip-regex/readme.md
+++ b/node_modules/ip-regex/readme.md
@@ -6,9 +6,11 @@
## Install
```
-$ npm install --save ip-regex
+$ npm install ip-regex
```
+This module targets Node.js 8 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, use version 2.1.0: `npm install ip-regex@2.1.0`
+
## Usage
@@ -28,6 +30,14 @@ ipRegex.v6({exact: true}).test('1:2:3:4:5:6:7:8');
'unicorn 192.168.0.1 cake 1:2:3:4:5:6:7:8 rainbow'.match(ipRegex());
//=> ['192.168.0.1', '1:2:3:4:5:6:7:8']
+
+// Contains an IP address?
+ipRegex({includeBoundaries: true}).test('192.168.0.2000000000');
+//=> false
+
+// Matches an IP address?
+'192.168.0.2000000000'.match(ipRegex({includeBoundaries: true}));
+//=> null
```
@@ -45,17 +55,30 @@ Returns a regex for matching IPv4.
Returns a regex for matching IPv6.
-#### options.exact
+#### options
+
+Type: `Object`
+
+##### exact
Type: `boolean`<br>
Default: `false` *(Matches any IP address in a string)*
Only match an exact string. Useful with `RegExp#test()` to check if a string is an IP address.
+##### includeBoundaries
+
+Type: `boolean`<br>
+Default: `false`
+
+Include boundaries in the regex. When `true`, `192.168.0.2000000000` will report as an invalid IPv4 address. If this option is not set, the mentioned IPv4 address would report as valid (ignoring the trailing zeros).
+
## Related
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
+- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation
+- [cidr-regex](https://github.com/silverwind/cidr-regex) - Regular expression for matching IP addresses in CIDR notation
## License