tldts 7.4.26 → 7.4.28
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 +34 -17
- package/dist/cjs/index.js.map +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
|
@@ -229,7 +229,7 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
229
229
|
start += 2;
|
|
230
230
|
}
|
|
231
231
|
else {
|
|
232
|
-
|
|
232
|
+
let indexOfProtocol = url.indexOf(':/', start);
|
|
233
233
|
if (indexOfProtocol !== -1) {
|
|
234
234
|
// "scheme://…". Classify the scheme, then position `start` at the host.
|
|
235
235
|
const special = getSpecialScheme(url, start, indexOfProtocol);
|
|
@@ -272,25 +272,40 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
272
272
|
code === 13 /* CR */) {
|
|
273
273
|
return extractHostname(url.replace(CONTROL_CHARS, ''), urlIsValidHostname, validate);
|
|
274
274
|
}
|
|
275
|
-
|
|
275
|
+
// A '/', '\', '?' or '#' first puts this ':/' in a path, query or
|
|
276
|
+
// fragment ("a.com/r?u=https://x"): re-read the input without it.
|
|
277
|
+
for (let j = i; j < indexOfProtocol; j += 1) {
|
|
278
|
+
const c = url.charCodeAt(j);
|
|
279
|
+
if (c === 47 || c === 92 || c === 63 || c === 35) {
|
|
280
|
+
indexOfProtocol = -1;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (indexOfProtocol !== -1) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
276
288
|
}
|
|
277
289
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
290
|
+
if (indexOfProtocol !== -1) {
|
|
291
|
+
// A non-special scheme has an authority only after "//" (else it is
|
|
292
|
+
// an opaque path with no host). `indexOf(':/')` already gave the
|
|
293
|
+
// first '/'.
|
|
294
|
+
if (url.charCodeAt(indexOfProtocol + 2) === 47 /* '/' */) {
|
|
295
|
+
isSpecial = false;
|
|
296
|
+
start = indexOfProtocol + 3;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
286
301
|
}
|
|
287
302
|
}
|
|
288
303
|
}
|
|
289
|
-
|
|
290
|
-
// Cold path: no scheme
|
|
291
|
-
// ':' would otherwise look like a scheme separator; "[…]" falls
|
|
292
|
-
// to the ipv6 handling below). May be a bare host, a host:port,
|
|
293
|
-
// user@host, a slash-less special scheme ("https:host"), or an opaque
|
|
304
|
+
if (indexOfProtocol === -1 && url.charCodeAt(start) !== 91 /* '[' */) {
|
|
305
|
+
// Cold path: no "scheme://" prefix, and not a bare IPv6 literal (whose
|
|
306
|
+
// first ':' would otherwise look like a scheme separator; "[…]" falls
|
|
307
|
+
// through to the ipv6 handling below). May be a bare host, a host:port,
|
|
308
|
+
// a user@host, a slash-less special scheme ("https:host"), or an opaque
|
|
294
309
|
// URI ("mailto:", "tel:", "urn:…").
|
|
295
310
|
let indexOfColon = -1;
|
|
296
311
|
for (let i = start; i < end; i += 1) {
|
|
@@ -341,7 +356,7 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
341
356
|
if (!allDigits) {
|
|
342
357
|
const special = getSpecialScheme(url, start, indexOfColon);
|
|
343
358
|
if (special === 0) {
|
|
344
|
-
// No "://"
|
|
359
|
+
// No "scheme://" on the cold path and not a special scheme.
|
|
345
360
|
// A second ':' before the host's end marks a bare, unbracketed
|
|
346
361
|
// IPv6 literal ("2a01:e35::1"): fall through and let the host
|
|
347
362
|
// loop + isIp classify it. Without one this is an opaque path
|
|
@@ -906,7 +921,9 @@ function parseImpl(url, step, suffixLookup, partialOptions, result) {
|
|
|
906
921
|
function fastPathLookup (hostname, options, out) {
|
|
907
922
|
// Fast path for very popular suffixes; this allows to by-pass lookup
|
|
908
923
|
// completely as well as any extra allocation or string manipulation.
|
|
909
|
-
if (!options.allowPrivateDomains &&
|
|
924
|
+
if (!options.allowPrivateDomains &&
|
|
925
|
+
options.allowIcannDomains &&
|
|
926
|
+
hostname.length > 3) {
|
|
910
927
|
const last = hostname.length - 1;
|
|
911
928
|
const c3 = hostname.charCodeAt(last);
|
|
912
929
|
const c2 = hostname.charCodeAt(last - 1);
|