tldts-experimental 7.3.0 → 7.4.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/dist/cjs/index.js +21 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/es6/index.js +8 -0
- package/dist/es6/index.js.map +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/dist/types/index.d.ts +1 -0
- package/index.ts +12 -0
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -431,7 +431,10 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
431
431
|
else if (code < 48 || code > 57) {
|
|
432
432
|
// < 64 and not a delimiter/dot/digit => only '-' (45) is a valid
|
|
433
433
|
// host char here; everything else (space, %, !, etc.) is invalid.
|
|
434
|
-
|
|
434
|
+
// A '-' must also not START a label (the byte right after a '.') —
|
|
435
|
+
// mirrors is-valid.ts; the first label is covered by the first-char
|
|
436
|
+
// rule above. (RFC 1034 §3.5 / RFC 1035 §2.3.1 LDH.)
|
|
437
|
+
if (code !== 45 || vLastCode === 46 /* label-leading '-' */) {
|
|
435
438
|
vValid = false;
|
|
436
439
|
}
|
|
437
440
|
}
|
|
@@ -711,8 +714,14 @@ function isValidHostname (hostname) {
|
|
|
711
714
|
}
|
|
712
715
|
lastDotIndex = i;
|
|
713
716
|
}
|
|
714
|
-
else if (
|
|
715
|
-
|
|
717
|
+
else if (
|
|
718
|
+
// A forbidden character in the label...
|
|
719
|
+
!( /*@__INLINE__*/(isValidAscii(code) || code === 45 || code === 95)) ||
|
|
720
|
+
// ...or a '-' starting a label (the byte right after a '.'). A label must
|
|
721
|
+
// not begin with a hyphen (RFC 1034 §3.5 / RFC 1035 §2.3.1 LDH, as amended
|
|
722
|
+
// by RFC 1123 §2.1; cf. UTS #46 CheckHyphens). The first label is covered by
|
|
723
|
+
// the leading-character guard above; mirrors the trailing-'-' rule below.
|
|
724
|
+
(code === 45 && lastCharCode === 46)) {
|
|
716
725
|
return false;
|
|
717
726
|
}
|
|
718
727
|
lastCharCode = code;
|
|
@@ -1184,6 +1193,14 @@ function getDomain(url, options) {
|
|
|
1184
1193
|
/*@__INLINE__*/ resetResult(RESULT);
|
|
1185
1194
|
return parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT).domain;
|
|
1186
1195
|
}
|
|
1196
|
+
function getFullDomain(url, options) {
|
|
1197
|
+
/*@__INLINE__*/ resetResult(RESULT);
|
|
1198
|
+
const result = parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT);
|
|
1199
|
+
// The hostname *is* the full domain (subdomain + domain) whenever a
|
|
1200
|
+
// registrable domain exists; gate on `domain` so non-registrable inputs
|
|
1201
|
+
// (IPs, suffix-less or invalid hostnames) return `null` like `getDomain`.
|
|
1202
|
+
return result.domain === null ? null : result.hostname;
|
|
1203
|
+
}
|
|
1187
1204
|
function getSubdomain(url, options) {
|
|
1188
1205
|
/*@__INLINE__*/ resetResult(RESULT);
|
|
1189
1206
|
return parseImpl(url, 4 /* FLAG.SUB_DOMAIN */, suffixLookup, options, RESULT)
|
|
@@ -1197,6 +1214,7 @@ function getDomainWithoutSuffix(url, options) {
|
|
|
1197
1214
|
|
|
1198
1215
|
exports.getDomain = getDomain;
|
|
1199
1216
|
exports.getDomainWithoutSuffix = getDomainWithoutSuffix;
|
|
1217
|
+
exports.getFullDomain = getFullDomain;
|
|
1200
1218
|
exports.getHostname = getHostname;
|
|
1201
1219
|
exports.getPublicSuffix = getPublicSuffix;
|
|
1202
1220
|
exports.getSubdomain = getSubdomain;
|