is-localhost-ip 1.4.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,7 +43,7 @@ const isLocalhost = require('is-localhost-ip');
43
43
  const punycode = require('punycode');
44
44
 
45
45
  (async () => {
46
- await isLocalhost(punycode.toASCII('кремль.рф')); // false
46
+ await isLocalhost(punycode.toASCII('свобода.рф')); // false
47
47
  await isLocalhost(punycode.toASCII('私の.家')); // true
48
48
  })();
49
49
  ```
package/index.js CHANGED
@@ -3,19 +3,7 @@
3
3
  const { isIP, isIPv4 } = require('net');
4
4
  const { createSocket } = require('dgram');
5
5
  const { ADDRCONFIG } = require('dns');
6
-
7
- /*
8
- DNS.promises were experimental until Node 11.4 and we don't want experimental warning
9
- https://nodejs.org/en/blog/release/v11.14.0/
10
- */
11
- const lookup =
12
- process.versions.node
13
- .split('.', 2)
14
- .map((n) => n.padStart(2, '0'))
15
- .join('.') >= '11.14'
16
- ? // eslint-disable-next-line node/no-unsupported-features/node-builtins
17
- require('dns').promises.lookup
18
- : require('util').promisify(require('dns').lookup);
6
+ const { lookup } = require('dns').promises;
19
7
 
20
8
  /**
21
9
  * Addresses reserved for private networks
@@ -49,7 +37,9 @@ const IP_TESTER_RE = new RegExp(
49
37
  * Maximum total length 253 symbols, maximum segment length 63 symbols
50
38
  * @see {@link https://en.wikipedia.org/wiki/Hostname}
51
39
  */
52
- const VALID_HOSTNAME = /(?![\w-]{64,})((^(?=[\w-.]{1,253}\.?$)((\w{1,63}|(\w[\w-]{0,61}\w))\.?)+$)(?<!\.{2,}))/i;
40
+ const VALID_HOSTNAME =
41
+ // eslint-disable-next-line regexp/no-dupe-disjunctions
42
+ /(?![\w-]{64})((^(?=[-\w.]{1,253}\.?$)((\w{1,63}|(\w[-\w]{0,61}\w))\.?)+$)(?<!\.{2}))/;
53
43
 
54
44
  /**
55
45
  *
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "is-localhost-ip",
3
- "version": "1.4.0",
3
+ "version": "2.0.0",
4
4
  "description": "Checks whether given DNS name or IPv4/IPv6 address belongs to a local machine",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "index.js",
8
- "index.d.ts",
9
- "index.js.flow"
8
+ "index.d.ts"
10
9
  ],
11
10
  "types": "index.d.ts",
12
11
  "engines": {
13
- "node": ">=10"
12
+ "node": ">=12"
14
13
  },
15
14
  "scripts": {
16
15
  "test": "jest --coverage --verbose",
@@ -30,22 +29,21 @@
30
29
  "dns"
31
30
  ],
32
31
  "author": "Konstantin Vyatkin <tino@vtkn.io>",
33
- "license": "GPL-3.0",
32
+ "license": "MIT",
34
33
  "bugs": {
35
34
  "url": "https://github.com/tinovyatkin/is-localhost-ip/issues"
36
35
  },
37
36
  "homepage": "https://github.com/tinovyatkin/is-localhost-ip#readme",
38
37
  "devDependencies": {
39
- "@types/jest": "25.2.1",
40
- "@types/node": "12.12.31",
41
- "eslint": "6.8.0",
42
- "eslint-config-prettier": "^6.10.1",
38
+ "@types/jest": "28.1.6",
39
+ "@types/node": "~12",
40
+ "eslint": "8.21.0",
41
+ "eslint-config-prettier": "8.5.0",
43
42
  "eslint-plugin-node": "11.1.0",
44
- "eslint-plugin-optimize-regex": "1.1.7",
45
- "eslint-plugin-prettier": "^3.1.2",
46
- "jest": "25.2.7",
47
- "prettier": "2.0.4",
48
- "weak-napi": "^1.0.3"
43
+ "eslint-plugin-prettier": "4.2.1",
44
+ "eslint-plugin-regexp": "^1.8.0",
45
+ "jest": "28.1.3",
46
+ "prettier": "2.7.1"
49
47
  },
50
48
  "jest": {
51
49
  "coverageReporters": [
@@ -54,8 +52,8 @@
54
52
  "cobertura",
55
53
  "lcov"
56
54
  ],
55
+ "coverageProvider": "v8",
57
56
  "testEnvironment": "node",
58
57
  "collectCoverage": true
59
- },
60
- "dependencies": {}
58
+ }
61
59
  }
package/index.js.flow DELETED
@@ -1,3 +0,0 @@
1
- // @flow
2
-
3
- declare module.exports: (addrOrHost: string, canBind?: Boolean) => Promise.<Boolean>;