tldts 7.3.1 → 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/README.md +22 -0
- package/dist/cjs/index.js +9 -0
- 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/README.md
CHANGED
|
@@ -68,6 +68,7 @@ Alternatively, you can try it _directly in your browser_ here: https://npm.runki
|
|
|
68
68
|
- `tldts.parse(url | hostname, options)`
|
|
69
69
|
- `tldts.getHostname(url | hostname, options)`
|
|
70
70
|
- `tldts.getDomain(url | hostname, options)`
|
|
71
|
+
- `tldts.getFullDomain(url | hostname, options)`
|
|
71
72
|
- `tldts.getPublicSuffix(url | hostname, options)`
|
|
72
73
|
- `tldts.getSubdomain(url, | hostname, options)`
|
|
73
74
|
- `tldts.getDomainWithoutSuffix(url | hostname, options)`
|
|
@@ -240,6 +241,27 @@ getDomain('fr.t.co'); // returns `t.co`
|
|
|
240
241
|
getDomain('https://user:password@example.co.uk:8080/some/path?and&query#hash'); // returns `example.co.uk`
|
|
241
242
|
```
|
|
242
243
|
|
|
244
|
+
### getFullDomain(url | hostname, options?)
|
|
245
|
+
|
|
246
|
+
Returns the full domain — the subdomain together with the registrable domain (as
|
|
247
|
+
returned by `getDomain(...)`), i.e. the whole hostname _including_ any subdomain —
|
|
248
|
+
or `null` when the input has no registrable domain (IP address, single label,
|
|
249
|
+
bare public suffix, …). The result is the normalized hostname (lower-cased,
|
|
250
|
+
trailing dot stripped); it is not a DNS-absolute name (no trailing root dot) and
|
|
251
|
+
no IDNA/punycode conversion is performed.
|
|
252
|
+
|
|
253
|
+
```javascript
|
|
254
|
+
const { getFullDomain } = require('tldts');
|
|
255
|
+
|
|
256
|
+
getFullDomain('google.com'); // returns `google.com`
|
|
257
|
+
getFullDomain('fr.google.com'); // returns `fr.google.com`
|
|
258
|
+
getFullDomain('foo.google.co.uk'); // returns `foo.google.co.uk`
|
|
259
|
+
getFullDomain('t.co'); // returns `t.co`
|
|
260
|
+
getFullDomain('fr.t.co'); // returns `fr.t.co`
|
|
261
|
+
getFullDomain('1.2.3.4'); // returns null (no registrable domain)
|
|
262
|
+
getFullDomain('localhost'); // returns null
|
|
263
|
+
```
|
|
264
|
+
|
|
243
265
|
### getDomainWithoutSuffix(url | hostname, options?)
|
|
244
266
|
|
|
245
267
|
Returns the domain (as returned by `getDomain(...)`) without the public suffix part.
|
package/dist/cjs/index.js
CHANGED
|
@@ -1141,6 +1141,14 @@ function getDomain(url, options) {
|
|
|
1141
1141
|
/*@__INLINE__*/ resetResult(RESULT);
|
|
1142
1142
|
return parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT).domain;
|
|
1143
1143
|
}
|
|
1144
|
+
function getFullDomain(url, options) {
|
|
1145
|
+
/*@__INLINE__*/ resetResult(RESULT);
|
|
1146
|
+
const result = parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT);
|
|
1147
|
+
// The hostname *is* the full domain (subdomain + domain) whenever a
|
|
1148
|
+
// registrable domain exists; gate on `domain` so non-registrable inputs
|
|
1149
|
+
// (IPs, suffix-less or invalid hostnames) return `null` like `getDomain`.
|
|
1150
|
+
return result.domain === null ? null : result.hostname;
|
|
1151
|
+
}
|
|
1144
1152
|
function getSubdomain(url, options) {
|
|
1145
1153
|
/*@__INLINE__*/ resetResult(RESULT);
|
|
1146
1154
|
return parseImpl(url, 4 /* FLAG.SUB_DOMAIN */, suffixLookup, options, RESULT)
|
|
@@ -1154,6 +1162,7 @@ function getDomainWithoutSuffix(url, options) {
|
|
|
1154
1162
|
|
|
1155
1163
|
exports.getDomain = getDomain;
|
|
1156
1164
|
exports.getDomainWithoutSuffix = getDomainWithoutSuffix;
|
|
1165
|
+
exports.getFullDomain = getFullDomain;
|
|
1157
1166
|
exports.getHostname = getHostname;
|
|
1158
1167
|
exports.getPublicSuffix = getPublicSuffix;
|
|
1159
1168
|
exports.getSubdomain = getSubdomain;
|