tldts-icann 7.4.21 → 7.4.22
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/dist/cjs/index.js +31 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/es6/tsconfig.bundle.tsbuildinfo +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -190,23 +190,41 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
190
190
|
let start = 0;
|
|
191
191
|
let end = url.length;
|
|
192
192
|
let hasUpper = false;
|
|
193
|
-
let isSpecial =
|
|
193
|
+
let isSpecial = true; // '\' ends the host, unless non-special "scheme://"
|
|
194
194
|
extractedHostnameValidated = false;
|
|
195
195
|
if (!urlIsValidHostname) {
|
|
196
|
-
// Data URLs never carry a host (and may be huge — short-circuit them).
|
|
197
|
-
if (url.startsWith('data:')) {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
196
|
// WHATWG step 1: trim leading/trailing C0 control or space (<= U+0020).
|
|
201
197
|
// Tab/newline elsewhere are handled lazily below.
|
|
202
198
|
while (start < url.length && url.charCodeAt(start) <= 32) {
|
|
203
199
|
start += 1;
|
|
204
200
|
}
|
|
201
|
+
// "data:"/"javascript:" never reach a host (inline payload; data URLs may be
|
|
202
|
+
// huge). `| 32` lowercases letters only; tab/newline is re-parsed below.
|
|
203
|
+
if ((url.charCodeAt(start + 4) === 58 /* ':' */ &&
|
|
204
|
+
(url.charCodeAt(start) | 32) === 100 /* d */ &&
|
|
205
|
+
(url.charCodeAt(start + 1) | 32) === 97 /* a */ &&
|
|
206
|
+
(url.charCodeAt(start + 2) | 32) === 116 /* t */ &&
|
|
207
|
+
(url.charCodeAt(start + 3) | 32) === 97) /* a */ ||
|
|
208
|
+
(url.charCodeAt(start + 10) === 58 /* ':' */ &&
|
|
209
|
+
(url.charCodeAt(start) | 32) === 106 /* j */ &&
|
|
210
|
+
(url.charCodeAt(start + 1) | 32) === 97 /* a */ &&
|
|
211
|
+
(url.charCodeAt(start + 2) | 32) === 118 /* v */ &&
|
|
212
|
+
(url.charCodeAt(start + 3) | 32) === 97 /* a */ &&
|
|
213
|
+
(url.charCodeAt(start + 4) | 32) === 115 /* s */ &&
|
|
214
|
+
(url.charCodeAt(start + 5) | 32) === 99 /* c */ &&
|
|
215
|
+
(url.charCodeAt(start + 6) | 32) === 114 /* r */ &&
|
|
216
|
+
(url.charCodeAt(start + 7) | 32) === 105 /* i */ &&
|
|
217
|
+
(url.charCodeAt(start + 8) | 32) === 112 /* p */ &&
|
|
218
|
+
(url.charCodeAt(start + 9) | 32) === 116) /* t */) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
205
221
|
while (end > start + 1 && url.charCodeAt(end - 1) <= 32) {
|
|
206
222
|
end -= 1;
|
|
207
223
|
}
|
|
208
|
-
if (url.charCodeAt(start) === 47 /* '/' */
|
|
209
|
-
url.charCodeAt(start
|
|
224
|
+
if ((url.charCodeAt(start) === 47 /* '/' */ ||
|
|
225
|
+
url.charCodeAt(start) === 92) /* '\' */ &&
|
|
226
|
+
(url.charCodeAt(start + 1) === 47 /* '/' */ ||
|
|
227
|
+
url.charCodeAt(start + 1) === 92) /* '\' */) {
|
|
210
228
|
// Scheme-relative reference ("//host/path").
|
|
211
229
|
start += 2;
|
|
212
230
|
}
|
|
@@ -218,7 +236,6 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
218
236
|
if (special === 1) {
|
|
219
237
|
// Special scheme: skip the run of '/' and '\' after it
|
|
220
238
|
// (special-authority-(ignore-)slashes states; '\' acts as '/').
|
|
221
|
-
isSpecial = true;
|
|
222
239
|
start = indexOfProtocol + 2;
|
|
223
240
|
while (url.charCodeAt(start) === 47 /* '/' */ ||
|
|
224
241
|
url.charCodeAt(start) === 92 /* '\' */) {
|
|
@@ -228,7 +245,6 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
228
245
|
else if (special === 2) {
|
|
229
246
|
// file: the host is only what sits between "//" and the next slash, so
|
|
230
247
|
// "file://h/x" => "h" but "file:///x" / "file:/x" => no host.
|
|
231
|
-
isSpecial = true;
|
|
232
248
|
start = indexOfProtocol + 1;
|
|
233
249
|
let slashes = 0;
|
|
234
250
|
while ((url.charCodeAt(start) === 47 || url.charCodeAt(start) === 92) &&
|
|
@@ -244,15 +260,16 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
244
260
|
// Unknown scheme: validate the WHATWG scheme grammar [A-Za-z0-9+.-];
|
|
245
261
|
// a control char means it was split by a tab/newline (strip + re-parse).
|
|
246
262
|
for (let i = start; i < indexOfProtocol; i += 1) {
|
|
247
|
-
const code = url.charCodeAt(i)
|
|
248
|
-
if (!((code >= 97 && code <= 122) || // [a
|
|
263
|
+
const code = url.charCodeAt(i);
|
|
264
|
+
if (!(((code | 32) >= 97 && (code | 32) <= 122) || // [a-zA-Z] (fold letters only)
|
|
249
265
|
(code >= 48 && code <= 57) || // [0, 9]
|
|
250
266
|
code === 46 || // '.'
|
|
251
267
|
code === 45 || // '-'
|
|
252
268
|
code === 43 // '+'
|
|
253
269
|
)) {
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
if (code === 9 /* tab */ ||
|
|
271
|
+
code === 10 /* LF */ ||
|
|
272
|
+
code === 13 /* CR */) {
|
|
256
273
|
return extractHostname(url.replace(CONTROL_CHARS, ''), urlIsValidHostname, validate);
|
|
257
274
|
}
|
|
258
275
|
return null;
|
|
@@ -261,6 +278,7 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
261
278
|
// A non-special scheme has an authority only after "//" (else it is an
|
|
262
279
|
// opaque path with no host). `indexOf(':/')` already gave the first '/'.
|
|
263
280
|
if (url.charCodeAt(indexOfProtocol + 2) === 47 /* '/' */) {
|
|
281
|
+
isSpecial = false;
|
|
264
282
|
start = indexOfProtocol + 3;
|
|
265
283
|
}
|
|
266
284
|
else {
|
|
@@ -347,7 +365,6 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
347
365
|
}
|
|
348
366
|
}
|
|
349
367
|
else {
|
|
350
|
-
isSpecial = true;
|
|
351
368
|
start = indexOfColon + 1;
|
|
352
369
|
if (special === 2) {
|
|
353
370
|
// file (e.g. "file:\\host"): host only between "//" and next slash.
|