parse-domain 3.0.3 → 5.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.
Files changed (80) hide show
  1. package/LICENSE +17 -20
  2. package/README.md +129 -60
  3. package/bin/update.js +13 -13
  4. package/build-cjs/serialized-tries/icann.json +1 -1
  5. package/build-cjs/serialized-tries/info.json +1 -1
  6. package/build-cjs/serialized-tries/private.json +1 -1
  7. package/build-cjs/src/config.js +1 -0
  8. package/build-cjs/src/config.js.map +1 -1
  9. package/build-cjs/src/from-url.js +4 -2
  10. package/build-cjs/src/from-url.js.map +1 -1
  11. package/build-cjs/src/main.d.ts +1 -1
  12. package/build-cjs/src/main.js +9 -5
  13. package/build-cjs/src/main.js.map +1 -1
  14. package/build-cjs/src/parse-domain.d.ts +8 -2
  15. package/build-cjs/src/parse-domain.js +8 -6
  16. package/build-cjs/src/parse-domain.js.map +1 -1
  17. package/build-cjs/src/psl/build-tries.js +16 -14
  18. package/build-cjs/src/psl/build-tries.js.map +1 -1
  19. package/build-cjs/src/psl/fetch-psl.js +5 -3
  20. package/build-cjs/src/psl/fetch-psl.js.map +1 -1
  21. package/build-cjs/src/sanitize.d.ts +26 -4
  22. package/build-cjs/src/sanitize.js +105 -38
  23. package/build-cjs/src/sanitize.js.map +1 -1
  24. package/build-cjs/src/scripts/update-psl-fixture.js +4 -3
  25. package/build-cjs/src/scripts/update-psl-fixture.js.map +1 -1
  26. package/build-cjs/src/scripts/update-tries.js +6 -5
  27. package/build-cjs/src/scripts/update-tries.js.map +1 -1
  28. package/build-cjs/src/serialized-tries.js +1 -0
  29. package/build-cjs/src/serialized-tries.js.map +1 -1
  30. package/build-cjs/src/smoke-test.js +7 -5
  31. package/build-cjs/src/smoke-test.js.map +1 -1
  32. package/build-cjs/src/trie/characters.js +1 -0
  33. package/build-cjs/src/trie/characters.js.map +1 -1
  34. package/build-cjs/src/trie/create-trie.d.ts +1 -1
  35. package/build-cjs/src/trie/create-trie.js +5 -3
  36. package/build-cjs/src/trie/create-trie.js.map +1 -1
  37. package/build-cjs/src/trie/look-up.d.ts +2 -1
  38. package/build-cjs/src/trie/look-up.js +17 -3
  39. package/build-cjs/src/trie/look-up.js.map +1 -1
  40. package/build-cjs/src/trie/nodes.js +5 -2
  41. package/build-cjs/src/trie/nodes.js.map +1 -1
  42. package/build-cjs/src/trie/parse-trie.js +19 -5
  43. package/build-cjs/src/trie/parse-trie.js.map +1 -1
  44. package/build-cjs/src/trie/serialize-trie.js +3 -1
  45. package/build-cjs/src/trie/serialize-trie.js.map +1 -1
  46. package/build-cjs/src/type-util.d.ts +1 -1
  47. package/build-cjs/src/update-tries.js +7 -5
  48. package/build-cjs/src/update-tries.js.map +1 -1
  49. package/build-esm/serialized-tries/icann.json +1 -1
  50. package/build-esm/serialized-tries/info.json +1 -1
  51. package/build-esm/serialized-tries/private.json +1 -1
  52. package/build-esm/src/config.js.map +1 -1
  53. package/build-esm/src/from-url.js +1 -1
  54. package/build-esm/src/from-url.js.map +1 -1
  55. package/build-esm/src/main.d.ts +1 -1
  56. package/build-esm/src/main.js +3 -1
  57. package/build-esm/src/main.js.map +1 -1
  58. package/build-esm/src/parse-domain.d.ts +8 -2
  59. package/build-esm/src/parse-domain.js +2 -2
  60. package/build-esm/src/parse-domain.js.map +1 -1
  61. package/build-esm/src/psl/build-tries.js +10 -10
  62. package/build-esm/src/psl/build-tries.js.map +1 -1
  63. package/build-esm/src/psl/fetch-psl.js.map +1 -1
  64. package/build-esm/src/sanitize.d.ts +26 -4
  65. package/build-esm/src/sanitize.js +103 -35
  66. package/build-esm/src/sanitize.js.map +1 -1
  67. package/build-esm/src/serialized-tries.js.map +1 -1
  68. package/build-esm/src/smoke-test.js.map +1 -1
  69. package/build-esm/src/trie/create-trie.d.ts +1 -1
  70. package/build-esm/src/trie/create-trie.js.map +1 -1
  71. package/build-esm/src/trie/look-up.d.ts +2 -1
  72. package/build-esm/src/trie/look-up.js.map +1 -1
  73. package/build-esm/src/trie/nodes.js.map +1 -1
  74. package/build-esm/src/trie/parse-trie.js.map +1 -1
  75. package/build-esm/src/trie/serialize-trie.js.map +1 -1
  76. package/build-esm/src/type-util.d.ts +1 -1
  77. package/build-esm/src/type-util.js +1 -0
  78. package/build-esm/src/update-tries.js.map +1 -1
  79. package/package.json +93 -85
  80. package/CHANGELOG.md +0 -260
package/LICENSE CHANGED
@@ -1,24 +1,21 @@
1
- This is free and unencumbered software released into the public domain.
1
+ MIT License
2
2
 
3
- Anyone is free to copy, modify, publish, use, compile, sell, or
4
- distribute this software, either in source code form or as a compiled
5
- binary, for any purpose, commercial or non-commercial, and by any
6
- means.
3
+ Copyright (c) 2021 Peerigon GmbH
7
4
 
8
- In jurisdictions that recognize copyright laws, the author or authors
9
- of this software dedicate any and all copyright interest in the
10
- software to the public domain. We make this dedication for the benefit
11
- of the public at large and to the detriment of our heirs and
12
- successors. We intend this dedication to be an overt act of
13
- relinquishment in perpetuity of all present and future rights to this
14
- software under copyright law.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
15
11
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
23
14
 
24
- For more information, please refer to <http://unlicense.org>
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -7,36 +7,32 @@
7
7
  [![Monthly downloads on NPM](https://img.shields.io/npm/dm/parse-domain?style=for-the-badge)](https://www.npmjs.com/package/parse-domain)<br>
8
8
  [![NPM Bundle size minified](https://img.shields.io/bundlephobia/min/parse-domain?style=for-the-badge)](https://bundlephobia.com/result?p=parse-domain)
9
9
  [![NPM Bundle size minified and gzipped](https://img.shields.io/bundlephobia/minzip/parse-domain?style=for-the-badge)](https://bundlephobia.com/result?p=parse-domain)<br>
10
- [![Dependencies status](https://img.shields.io/david/peerigon/parse-domain?style=for-the-badge)](https://david-dm.org/peerigon/parse-domain)
11
- [![Known Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/parse-domain?style=for-the-badge)](https://snyk.io/test/github/peerigon/parse-domain)<br>
12
- ![Written in TypeScript](https://img.shields.io/npm/types/parse-domain?style=for-the-badge)
13
- [![Coverage Status](https://img.shields.io/coveralls/github/peerigon/parse-domain?style=for-the-badge)](https://coveralls.io/github/peerigon/parse-domain?branch=master)
14
- [![License](https://img.shields.io/npm/l/parse-domain?style=for-the-badge)](https://unlicense.org/)
10
+ [![License](https://img.shields.io/npm/l/parse-domain?style=for-the-badge)](./LICENSE)
15
11
 
16
12
  Since domain name registrars organize their namespaces in different ways, it's not straight-forward to split a hostname into subdomains, the domain and top-level domains. In order to do that **parse-domain** uses a [large list of known top-level domains](https://publicsuffix.org/list/public_suffix_list.dat) from [publicsuffix.org](https://publicsuffix.org/):
17
13
 
18
14
  ```javascript
19
- import {parseDomain, ParseResultType} from "parse-domain";
15
+ import { parseDomain, ParseResultType } from "parse-domain";
20
16
 
21
17
  const parseResult = parseDomain(
22
- // This should be a string with basic latin characters only.
23
- // More information below.
24
- "www.some.example.co.uk",
18
+ // This should be a string with basic latin letters only.
19
+ // More information below.
20
+ "www.some.example.co.uk"
25
21
  );
26
22
 
27
23
  // Check if the domain is listed in the public suffix list
28
24
  if (parseResult.type === ParseResultType.Listed) {
29
- const {subDomains, domain, topLevelDomains} = parseResult;
25
+ const { subDomains, domain, topLevelDomains } = parseResult;
30
26
 
31
- console.log(subDomains); // ["www", "some"]
32
- console.log(domain); // "example"
33
- console.log(topLevelDomains); // ["co", "uk"]
27
+ console.log(subDomains); // ["www", "some"]
28
+ console.log(domain); // "example"
29
+ console.log(topLevelDomains); // ["co", "uk"]
34
30
  } else {
35
- // Read more about other parseResult types below...
31
+ // Read more about other parseResult types below...
36
32
  }
37
33
  ```
38
34
 
39
- This package has been designed for modern Node and browser environments, supporting both CommonJS and ECMAScript modules. It assumes an ES2015 environment with [`Symbol()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) and [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL) globally available. You need to transpile it down to ES5 (e.g. by using [Babel](https://babeljs.io/)) if you need to support older environments.
35
+ This package has been designed for modern Node and browser environments, supporting both CommonJS and ECMAScript modules. It assumes an ES2015 environment with [`Symbol()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL) and [`TextDecoder()](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) globally available. You need to transpile it down to ES5 (e.g. by using [Babel](https://babeljs.io/)) if you need to support older environments.
40
36
 
41
37
  The list of top-level domains is stored in a [trie](https://en.wikipedia.org/wiki/Trie) data structure and serialization format to ensure the fastest lookup and the smallest possible library size. The library is side-effect free (this is important for proper [tree-shaking](https://webpack.js.org/guides/tree-shaking/)).
42
38
 
@@ -67,10 +63,10 @@ npm install parse-domain
67
63
  There is the utility function [`fromUrl`](#api-js-fromUrl) which tries to extract the hostname from a (partial) URL and puny-encodes it:
68
64
 
69
65
  ```javascript
70
- import {parseDomain, fromUrl} from "parse-domain";
66
+ import { parseDomain, fromUrl } from "parse-domain";
71
67
 
72
- const {subDomains, domain, topLevelDomains} = parseDomain(
73
- fromUrl("https://www.münchen.de?query"),
68
+ const { subDomains, domain, topLevelDomains } = parseDomain(
69
+ fromUrl("https://www.münchen.de?query")
74
70
  );
75
71
 
76
72
  console.log(subDomains); // ["www"]
@@ -78,7 +74,7 @@ console.log(domain); // "xn--mnchen-3ya"
78
74
  console.log(topLevelDomains); // ["de"]
79
75
 
80
76
  // You can use the 'punycode' NPM package to decode the domain again
81
- import {toUnicode} from "punycode";
77
+ import { toUnicode } from "punycode";
82
78
 
83
79
  console.log(toUnicode(domain)); // "münchen"
84
80
  ```
@@ -100,10 +96,10 @@ When parsing a hostname there are 5 possible results:
100
96
 
101
97
  ### 👉 Invalid domains
102
98
 
103
- The given input is first validated against [RFC 1034](https://tools.ietf.org/html/rfc1034). If the validation fails, `parseResult.type` will be `ParseResultType.Invalid`:
99
+ The given input is first validated against [RFC 3696](https://datatracker.ietf.org/doc/html/rfc3696#section-2) (the domain labels are limited to basic latin letters, numbers and hyphens). If the validation fails, `parseResult.type` will be `ParseResultType.Invalid`:
104
100
 
105
101
  ```javascript
106
- import {parseDomain, ParseResultType} from "parse-domain";
102
+ import { parseDomain, ParseResultType } from "parse-domain";
107
103
 
108
104
  const parseResult = parseDomain("münchen.de");
109
105
 
@@ -112,12 +108,26 @@ console.log(parseResult.type === ParseResultType.Invalid); // true
112
108
 
113
109
  Check out the [API](#api-ts-ValidationError) if you need more information about the validation error.
114
110
 
111
+ If you don't want the characters to be validated (e.g. because you need to allow underscores in hostnames), there's also a more relaxed validation mode (according to [RFC 2181](https://www.rfc-editor.org/rfc/rfc2181#section-11)).
112
+
113
+ ```javascript
114
+ import { parseDomain, ParseResultType, Validation } from "parse-domain";
115
+
116
+ const parseResult = parseDomain("_jabber._tcp.gmail.com", {
117
+ validation: Validation.Lax,
118
+ });
119
+
120
+ console.log(parseResult.type === ParseResultType.Listed); // true
121
+ ```
122
+
123
+ See also [#134](https://github.com/peerigon/parse-domain/issues/134) for the discussion.
124
+
115
125
  ### 👉 IP addresses
116
126
 
117
127
  If the given input is an IP address, `parseResult.type` will be `ParseResultType.Ip`:
118
128
 
119
129
  ```javascript
120
- import {parseDomain, ParseResultType} from "parse-domain";
130
+ import { parseDomain, ParseResultType } from "parse-domain";
121
131
 
122
132
  const parseResult = parseDomain("192.168.2.1");
123
133
 
@@ -140,7 +150,7 @@ There are 5 top-level domains that are not listed in the public suffix list but
140
150
  In these cases, `parseResult.type` will be `ParseResultType.Reserved`:
141
151
 
142
152
  ```javascript
143
- import {parseDomain, ParseResultType} from "parse-domain";
153
+ import { parseDomain, ParseResultType } from "parse-domain";
144
154
 
145
155
  const parseResult = parseDomain("pecorino.local");
146
156
 
@@ -153,7 +163,7 @@ console.log(parseResult.labels); // ["pecorino", "local"]
153
163
  If the given hostname is valid, but not listed in the downloaded public suffix list, `parseResult.type` will be `ParseResultType.NotListed`:
154
164
 
155
165
  ```javascript
156
- import {parseDomain, ParseResultType} from "parse-domain";
166
+ import { parseDomain, ParseResultType } from "parse-domain";
157
167
 
158
168
  const parseResult = parseDomain("this.is.not-listed");
159
169
 
@@ -179,7 +189,7 @@ Some examples for public suffixes:
179
189
  If the hostname is listed in the public suffix list, the `parseResult.type` will be `ParseResultType.Listed`:
180
190
 
181
191
  ```javascript
182
- import {parseDomain, ParseResultType} from "parse-domain";
192
+ import { parseDomain, ParseResultType } from "parse-domain";
183
193
 
184
194
  const parseResult = parseDomain("example.co.uk");
185
195
 
@@ -190,7 +200,7 @@ console.log(parseResult.labels); // ["example", "co", "uk"]
190
200
  Now `parseResult` will also provide a `subDomains`, `domain` and `topLevelDomains` property:
191
201
 
192
202
  ```javascript
193
- const {subDomains, domain, topLevelDomains} = parseResult;
203
+ const { subDomains, domain, topLevelDomains } = parseResult;
194
204
 
195
205
  console.log(subDomains); // []
196
206
  console.log(domain); // "example"
@@ -203,21 +213,21 @@ We recommend switching over the `parseResult.type`:
203
213
 
204
214
  ```javascript
205
215
  switch (parseResult.type) {
206
- case ParseResultType.Listed: {
207
- const {hostname, topLevelDomains} = parseResult;
208
-
209
- console.log(`${hostname} belongs to ${topLevelDomains.join(".")}`);
210
- break;
211
- }
212
- case ParseResultType.Reserved:
213
- case ParseResultType.NotListed: {
214
- const {hostname} = parseResult;
215
-
216
- console.log(`${hostname} is a reserved or unknown domain`);
217
- break;
218
- }
219
- default:
220
- throw new Error(`${hostname} is an ip address or invalid domain`);
216
+ case ParseResultType.Listed: {
217
+ const { hostname, topLevelDomains } = parseResult;
218
+
219
+ console.log(`${hostname} belongs to ${topLevelDomains.join(".")}`);
220
+ break;
221
+ }
222
+ case ParseResultType.Reserved:
223
+ case ParseResultType.NotListed: {
224
+ const { hostname } = parseResult;
225
+
226
+ console.log(`${hostname} is a reserved or unknown domain`);
227
+ break;
228
+ }
229
+ default:
230
+ throw new Error(`${hostname} is an ip address or invalid domain`);
221
231
  }
222
232
  ```
223
233
 
@@ -226,8 +236,8 @@ switch (parseResult.type) {
226
236
  What's surprising to a lot of people is that the definition of public suffix means that regular user domains can become effective top-level domains:
227
237
 
228
238
  ```javascript
229
- const {subDomains, domain, topLevelDomains} = parseDomain(
230
- "parse-domain.github.io",
239
+ const { subDomains, domain, topLevelDomains } = parseDomain(
240
+ "parse-domain.github.io"
231
241
  );
232
242
 
233
243
  console.log(subDomains); // []
@@ -241,7 +251,7 @@ If you want to deviate from the browser's understanding of a top-level domain an
241
251
 
242
252
  ```javascript
243
253
  const parseResult = parseDomain("parse-domain.github.io");
244
- const {subDomains, domain, topLevelDomains} = parseResult.icann;
254
+ const { subDomains, domain, topLevelDomains } = parseResult.icann;
245
255
 
246
256
  console.log(subDomains); // ["parse-domain"]
247
257
  console.log(domain); // "github"
@@ -251,7 +261,7 @@ console.log(topLevelDomains); // ["io"]
251
261
  ### ⚠️ `domain` can also be `undefined`
252
262
 
253
263
  ```javascript
254
- const {subDomains, domain, topLevelDomains} = parseDomain("co.uk");
264
+ const { subDomains, domain, topLevelDomains } = parseDomain("co.uk");
255
265
 
256
266
  console.log(subDomains); // []
257
267
  console.log(domain); // undefined
@@ -263,7 +273,7 @@ console.log(topLevelDomains); // ["co", "uk"]
263
273
  The empty string `""` represents the [DNS root](https://en.wikipedia.org/wiki/DNS_root_zone) and is considered to be valid. `parseResult.type` will be `ParseResultType.Reserved` in that case:
264
274
 
265
275
  ```javascript
266
- const {type, subDomains, domain, topLevelDomains} = parseDomain("");
276
+ const { type, subDomains, domain, topLevelDomains } = parseDomain("");
267
277
 
268
278
  console.log(type === ParseResultType.Reserved); // true
269
279
  console.log(subDomains); // []
@@ -277,17 +287,27 @@ console.log(topLevelDomains); // []
277
287
  🧬 = TypeScript export
278
288
 
279
289
  <h3 id="api-js-parseDomain">
280
- 🧩 <code>export parseDomain(hostname: string | typeof <a href="#api-js-NO_HOSTNAME">NO_HOSTNAME</a>): <a href="#api-ts-ParseResult">ParseResult</a></code>
290
+ 🧩 <code>export parseDomain(hostname: string | typeof <a href="#api-js-NO_HOSTNAME">NO_HOSTNAME</a>, options?: <a href="#api-ts-ParseDomainOptions">ParseDomainOptions</a>): <a href="#api-ts-ParseResult">ParseResult</a></code>
281
291
  </h3>
282
292
 
283
- Takes a hostname (e.g. `"www.example.com"`) and returns a [`ParseResult`](#api-ts-ParseResult). The hostname must only contain basic latin characters, digits, hyphens and dots. International hostnames must be puny-encoded. Does not throw an error, even with invalid input.
293
+ Takes a hostname (e.g. `"www.example.com"`) and returns a [`ParseResult`](#api-ts-ParseResult). The hostname must only contain basic latin letters, digits, hyphens and dots. International hostnames must be puny-encoded. Does not throw an error, even with invalid input.
284
294
 
285
295
  ```javascript
286
- import {parseDomain} from "parse-domain";
296
+ import { parseDomain } from "parse-domain";
287
297
 
288
298
  const parseResult = parseDomain("www.example.com");
289
299
  ```
290
300
 
301
+ Use `Validation.Lax` if you want to allow all characters:
302
+
303
+ ```javascript
304
+ import { parseDomain, Validation } from "parse-domain";
305
+
306
+ const parseResult = parseDomain("_jabber._tcp.gmail.com", {
307
+ validation: Validation.Lax,
308
+ });
309
+ ```
310
+
291
311
  <h3 id="api-js-fromUrl">
292
312
  🧩 <code>export fromUrl(input: string): string | typeof <a href="#api-js-NO_HOSTNAME">NO_HOSTNAME</a></code>
293
313
  </h3>
@@ -300,6 +320,54 @@ Takes a URL-like string and tries to extract the hostname. Requires the global [
300
320
 
301
321
  `NO_HOSTNAME` is a symbol that is returned by [`fromUrl`](#api-js-fromUrl) when it was not able to extract a hostname from the given string. When passed to [`parseDomain`](#api-js-parseDomain), it will always yield a [`ParseResultInvalid`](#api-ts-ParseResultInvalid).
302
322
 
323
+ <h3 id="api-ts-ParseDomainOptions">
324
+ 🧬 <code>export type ParseDomainOptions</code>
325
+ </h3>
326
+
327
+ ```ts
328
+ export type ParseDomainOptions = {
329
+ /**
330
+ * If no validation is specified, Validation.Strict will be used.
331
+ **/
332
+ validation?: Validation;
333
+ };
334
+ ```
335
+
336
+ <h3 id="api-js-Validation">
337
+ 🧩 <code>export Validation</code>
338
+ </h3>
339
+
340
+ An object that holds all possible [Validation](#api-ts-Validation) `validation` values:
341
+
342
+ ```javascript
343
+ export const Validation = {
344
+ /**
345
+ * Allows any octets as labels
346
+ * but still restricts the length of labels and the overall domain.
347
+ *
348
+ * @see https://www.rfc-editor.org/rfc/rfc2181#section-11
349
+ **/
350
+ Lax: "LAX",
351
+
352
+ /**
353
+ * Only allows ASCII letters, digits and hyphens (aka LDH),
354
+ * forbids hyphens at the beginning or end of a label
355
+ * and requires top-level domain names not to be all-numeric.
356
+ *
357
+ * This is the default if no validation is configured.
358
+ *
359
+ * @see https://datatracker.ietf.org/doc/html/rfc3696#section-2
360
+ */
361
+ Strict: "STRICT",
362
+ };
363
+ ```
364
+
365
+ <h3 id="api-ts-Validation">
366
+ 🧬 <code>export Validation</code>
367
+ </h3>
368
+
369
+ This type represents all possible `validation` values.
370
+
303
371
  <h3 id="api-ts-ParseResult">
304
372
  🧬 <code>export ParseResult</code>
305
373
  </h3>
@@ -318,11 +386,11 @@ An object that holds all possible [ParseResult](#api-ts-ParseResult) `type` valu
318
386
 
319
387
  ```javascript
320
388
  const ParseResultType = {
321
- Invalid: "INVALID",
322
- Ip: "IP",
323
- Reserved: "RESERVED",
324
- NotListed: "NOT_LISTED",
325
- Listed: "LISTED",
389
+ Invalid: "INVALID",
390
+ Ip: "IP",
391
+ Reserved: "RESERVED",
392
+ NotListed: "NOT_LISTED",
393
+ Listed: "LISTED",
326
394
  };
327
395
  ```
328
396
 
@@ -390,11 +458,12 @@ An object that holds all possible [ValidationError](#api-ts-ValidationError) `ty
390
458
 
391
459
  ```javascript
392
460
  const ValidationErrorType = {
393
- NoHostname: "NO_HOSTNAME",
394
- DomainMaxLength: "DOMAIN_MAX_LENGTH",
395
- LabelMinLength: "LABEL_MIN_LENGTH",
396
- LabelMaxLength: "LABEL_MAX_LENGTH",
397
- LabelInvalidCharacter: "LABEL_INVALID_CHARACTER",
461
+ NoHostname: "NO_HOSTNAME",
462
+ DomainMaxLength: "DOMAIN_MAX_LENGTH",
463
+ LabelMinLength: "LABEL_MIN_LENGTH",
464
+ LabelMaxLength: "LABEL_MAX_LENGTH",
465
+ LabelInvalidCharacter: "LABEL_INVALID_CHARACTER",
466
+ LastLabelInvalid: "LAST_LABEL_INVALID",
398
467
  };
399
468
  ```
400
469
 
@@ -525,7 +594,7 @@ type ParseResultListed = {
525
594
 
526
595
  ## License
527
596
 
528
- Unlicense
597
+ MIT
529
598
 
530
599
  ## Sponsors
531
600
 
package/bin/update.js CHANGED
@@ -2,24 +2,24 @@
2
2
 
3
3
  "use strict";
4
4
 
5
- const {EOL} = require("os");
5
+ const { EOL } = require("os");
6
6
 
7
7
  (async () => {
8
- process.argv.push(
9
- "--",
10
- "../../serialized-tries",
11
- "../../../build-esm/serialized-tries",
12
- );
8
+ process.argv.push(
9
+ "--",
10
+ "../../serialized-tries",
11
+ "../../../build-esm/serialized-tries"
12
+ );
13
13
 
14
- await require("../build-cjs/src/scripts/update-tries.js").done;
14
+ await require("../build-cjs/src/scripts/update-tries.js").done;
15
15
 
16
- process.stderr.write("Running smoke test... ");
16
+ process.stderr.write("Running smoke test... ");
17
17
 
18
- require("../build-cjs/src/smoke-test.js").runSmokeTest();
18
+ require("../build-cjs/src/smoke-test.js").runSmokeTest();
19
19
 
20
- process.stdout.write("ok" + EOL);
20
+ process.stdout.write("ok" + EOL);
21
21
  })().catch((error) => {
22
- console.error(`parse-domain update failed: ${error}`);
23
- // eslint-disable-next-line no-process-exit
24
- process.exit(1);
22
+ console.error(`parse-domain update failed: ${error}`);
23
+ // eslint-disable-next-line no-process-exit, node/no-process-exit
24
+ process.exit(1);
25
25
  });