Complete Email Sortierer implementation with Appwrite and Stripe integration

This commit is contained in:
knso committed 2026-01-14 20:02:16 +01:00
commit 95349af50b
3355 files changed
+644802

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
Copyright (c) 2017 Thomas Parisot, 2018 Rémi Berson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+327
View File
@@ -0,0 +1,327 @@
# tldts - Blazing Fast URL Parsing
`tldts` is a JavaScript library to extract hostnames, domains, public suffixes, top-level domains and subdomains from URLs.
**Features**:
1. Tuned for **performance** (order of 0.1 to 1 μs per input)
2. Handles both URLs and hostnames
3. Full Unicode/IDNA support
4. Support parsing email addresses
5. Detect IPv4 and IPv6 addresses
6. Continuously updated version of the public suffix list
7. **TypeScript**, ships with `umd`, `esm`, `cjs` bundles and _type definitions_
8. Small bundles and small memory footprint
9. Battle tested: full test coverage and production use
# Install
```bash
npm install --save tldts
```
# Usage
Using the command-line interface:
```js
$ npx tldts 'http://www.writethedocs.org/conf/eu/2017/'
{
"domain": "writethedocs.org",
"domainWithoutSuffix": "writethedocs",
"hostname": "www.writethedocs.org",
"isIcann": true,
"isIp": false,
"isPrivate": false,
"publicSuffix": "org",
"subdomain": "www"
}
```
Programmatically:
```js
const { parse } = require('tldts');
// Retrieving hostname related informations of a given URL
parse('http://www.writethedocs.org/conf/eu/2017/');
// { domain: 'writethedocs.org',
// domainWithoutSuffix: 'writethedocs',
// hostname: 'www.writethedocs.org',
// isIcann: true,
// isIp: false,
// isPrivate: false,
// publicSuffix: 'org',
// subdomain: 'www' }
```
Modern _ES6 modules import_ is also supported:
```js
import { parse } from 'tldts';
```
Alternatively, you can try it _directly in your browser_ here: https://npm.runkit.com/tldts
# API
- `tldts.parse(url | hostname, options)`
- `tldts.getHostname(url | hostname, options)`
- `tldts.getDomain(url | hostname, options)`
- `tldts.getPublicSuffix(url | hostname, options)`
- `tldts.getSubdomain(url, | hostname, options)`
- `tldts.getDomainWithoutSuffix(url | hostname, options)`
The behavior of `tldts` can be customized using an `options` argument for all
the functions exposed as part of the public API. This is useful to both change
the behavior of the library as well as fine-tune the performance depending on
your inputs.
```js
{
// Use suffixes from ICANN section (default: true)
allowIcannDomains: boolean;
// Use suffixes from Private section (default: false)
allowPrivateDomains: boolean;
// Extract and validate hostname (default: true)
// When set to `false`, inputs will be considered valid hostnames.
extractHostname: boolean;
// Validate hostnames after parsing (default: true)
// If a hostname is not valid, not further processing is performed. When set
// to `false`, inputs to the library will be considered valid and parsing will
// proceed regardless.
validateHostname: boolean;
// Perform IP address detection (default: true).
detectIp: boolean;
// Assume that both URLs and hostnames can be given as input (default: true)
// If set to `false` we assume only URLs will be given as input, which
// speed-ups processing.
mixedInputs: boolean;
// Specifies extra valid suffixes (default: null)
validHosts: string[] | null;
}
```
The `parse` method returns handy **properties about a URL or a hostname**.
```js
const tldts = require('tldts');
tldts.parse('https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv');
// { domain: 'amazonaws.com',
// domainWithoutSuffix: 'amazonaws',
// hostname: 'spark-public.s3.amazonaws.com',
// isIcann: true,
// isIp: false,
// isPrivate: false,
// publicSuffix: 'com',
// subdomain: 'spark-public.s3' }
tldts.parse(
'https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv',
{ allowPrivateDomains: true },
);
// { domain: 'spark-public.s3.amazonaws.com',
// domainWithoutSuffix: 'spark-public',
// hostname: 'spark-public.s3.amazonaws.com',
// isIcann: false,
// isIp: false,
// isPrivate: true,
// publicSuffix: 's3.amazonaws.com',
// subdomain: '' }
tldts.parse('gopher://domain.unknown/');
// { domain: 'domain.unknown',
// domainWithoutSuffix: 'domain',
// hostname: 'domain.unknown',
// isIcann: false,
// isIp: false,
// isPrivate: false,
// publicSuffix: 'unknown',
// subdomain: '' }
tldts.parse('https://192.168.0.0'); // IPv4
// { domain: null,
// domainWithoutSuffix: null,
// hostname: '192.168.0.0',
// isIcann: null,
// isIp: true,
// isPrivate: null,
// publicSuffix: null,
// subdomain: null }
tldts.parse('https://[::1]'); // IPv6
// { domain: null,
// domainWithoutSuffix: null,
// hostname: '::1',
// isIcann: null,
// isIp: true,
// isPrivate: null,
// publicSuffix: null,
// subdomain: null }
tldts.parse('tldts@emailprovider.co.uk'); // email
// { domain: 'emailprovider.co.uk',
// domainWithoutSuffix: 'emailprovider',
// hostname: 'emailprovider.co.uk',
// isIcann: true,
// isIp: false,
// isPrivate: false,
// publicSuffix: 'co.uk',
// subdomain: '' }
```
| Property Name | Type | Description |
| :-------------------- | :----- | :---------------------------------------------- |
| `hostname` | `str` | `hostname` of the input extracted automatically |
| `domain` | `str` | Domain (tld + sld) |
| `domainWithoutSuffix` | `str` | Domain without public suffix |
| `subdomain` | `str` | Sub domain (what comes after `domain`) |
| `publicSuffix` | `str` | Public Suffix (tld) of `hostname` |
| `isIcann` | `bool` | Does TLD come from ICANN part of the list |
| `isPrivate` | `bool` | Does TLD come from Private part of the list |
| `isIP` | `bool` | Is `hostname` an IP address? |
## Single purpose methods
These methods are shorthands if you want to retrieve only a single value (and
will perform better than `parse` because less work will be needed).
### getHostname(url | hostname, options?)
Returns the hostname from a given string.
```javascript
const { getHostname } = require('tldts');
getHostname('google.com'); // returns `google.com`
getHostname('fr.google.com'); // returns `fr.google.com`
getHostname('fr.google.google'); // returns `fr.google.google`
getHostname('foo.google.co.uk'); // returns `foo.google.co.uk`
getHostname('t.co'); // returns `t.co`
getHostname('fr.t.co'); // returns `fr.t.co`
getHostname(
'https://user:password@example.co.uk:8080/some/path?and&query#hash',
); // returns `example.co.uk`
```
### getDomain(url | hostname, options?)
Returns the fully qualified domain from a given string.
```javascript
const { getDomain } = require('tldts');
getDomain('google.com'); // returns `google.com`
getDomain('fr.google.com'); // returns `google.com`
getDomain('fr.google.google'); // returns `google.google`
getDomain('foo.google.co.uk'); // returns `google.co.uk`
getDomain('t.co'); // returns `t.co`
getDomain('fr.t.co'); // returns `t.co`
getDomain('https://user:password@example.co.uk:8080/some/path?and&query#hash'); // returns `example.co.uk`
```
### getDomainWithoutSuffix(url | hostname, options?)
Returns the domain (as returned by `getDomain(...)`) without the public suffix part.
```javascript
const { getDomainWithoutSuffix } = require('tldts');
getDomainWithoutSuffix('google.com'); // returns `google`
getDomainWithoutSuffix('fr.google.com'); // returns `google`
getDomainWithoutSuffix('fr.google.google'); // returns `google`
getDomainWithoutSuffix('foo.google.co.uk'); // returns `google`
getDomainWithoutSuffix('t.co'); // returns `t`
getDomainWithoutSuffix('fr.t.co'); // returns `t`
getDomainWithoutSuffix(
'https://user:password@example.co.uk:8080/some/path?and&query#hash',
); // returns `example`
```
### getSubdomain(url | hostname, options?)
Returns the complete subdomain for a given string.
```javascript
const { getSubdomain } = require('tldts');
getSubdomain('google.com'); // returns ``
getSubdomain('fr.google.com'); // returns `fr`
getSubdomain('google.co.uk'); // returns ``
getSubdomain('foo.google.co.uk'); // returns `foo`
getSubdomain('moar.foo.google.co.uk'); // returns `moar.foo`
getSubdomain('t.co'); // returns ``
getSubdomain('fr.t.co'); // returns `fr`
getSubdomain(
'https://user:password@secure.example.co.uk:443/some/path?and&query#hash',
); // returns `secure`
```
### getPublicSuffix(url | hostname, options?)
Returns the [public suffix][] for a given string.
```javascript
const { getPublicSuffix } = require('tldts');
getPublicSuffix('google.com'); // returns `com`
getPublicSuffix('fr.google.com'); // returns `com`
getPublicSuffix('google.co.uk'); // returns `co.uk`
getPublicSuffix('s3.amazonaws.com'); // returns `com`
getPublicSuffix('s3.amazonaws.com', { allowPrivateDomains: true }); // returns `s3.amazonaws.com`
getPublicSuffix('tld.is.unknown'); // returns `unknown`
```
# Troubleshooting
## Retrieving subdomain of `localhost` and custom hostnames
`tldts` methods `getDomain` and `getSubdomain` are designed to **work only with _known and valid_ TLDs**.
This way, you can trust what a domain is.
`localhost` is a valid hostname but not a TLD. You can pass additional options to each method exposed by `tldts`:
```js
const tldts = require('tldts');
tldts.getDomain('localhost'); // returns null
tldts.getSubdomain('vhost.localhost'); // returns null
tldts.getDomain('localhost', { validHosts: ['localhost'] }); // returns 'localhost'
tldts.getSubdomain('vhost.localhost', { validHosts: ['localhost'] }); // returns 'vhost'
```
## Updating the TLDs List
`tldts` made the opinionated choice of shipping with a list of suffixes directly
in its bundle. There is currently no mechanism to update the lists yourself, but
we make sure that the version shipped is always up-to-date.
If you keep `tldts` updated, the lists should be up-to-date as well!
# Performance
`tldts` is the _fastest JavaScript library_ available for parsing hostnames. It is able to parse _millions of inputs per second_ (typically 2-3M depending on your hardware and inputs). It also offers granular options to fine-tune the behavior and performance of the library depending on the kind of inputs you are dealing with (e.g.: if you know you only manipulate valid hostnames you can disable the hostname extraction step with `{ extractHostname: false }`).
Please see [this detailed comparison](./comparison/comparison.md) with other available libraries.
## Contributors
`tldts` is based upon the excellent `tld.js` library and would not exist without
the many contributors who worked on the project:
<a href="graphs/contributors"><img src="https://opencollective.com/tldjs/contributors.svg?width=890" /></a>
This project would not be possible without the amazing Mozilla's
[public suffix list][]. Thank you for your hard work!
# License
[MIT License](LICENSE).
[badge-ci]: https://secure.travis-ci.org/remusao/tldts.svg?branch=master
[badge-downloads]: https://img.shields.io/npm/dm/tldts.svg
[public suffix list]: https://publicsuffix.org/list/
[list the recent changes]: https://github.com/publicsuffix/list/commits/master
[changes Atom Feed]: https://github.com/publicsuffix/list/commits/master.atom
[public suffix]: https://publicsuffix.org/learn/
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env node
'use strict';
const { parse } = require('..');
const readline = require('readline');
if (process.argv.length > 2) {
// URL(s) was specified in the command arguments
console.log(
JSON.stringify(parse(process.argv[process.argv.length - 1]), null, 2),
);
} else {
// No arguments were specified, read URLs from each line of STDIN
const rlInterface = readline.createInterface({
input: process.stdin,
});
rlInterface.on('line', function (line) {
console.log(JSON.stringify(parse(line), null, 2));
});
}
+669
View File
@@ -0,0 +1,669 @@
'use strict';
/**
* Check if `vhost` is a valid suffix of `hostname` (top-domain)
*
* It means that `vhost` needs to be a suffix of `hostname` and we then need to
* make sure that: either they are equal, or the character preceding `vhost` in
* `hostname` is a '.' (it should not be a partial label).
*
* * hostname = 'not.evil.com' and vhost = 'vil.com' => not ok
* * hostname = 'not.evil.com' and vhost = 'evil.com' => ok
* * hostname = 'not.evil.com' and vhost = 'not.evil.com' => ok
*/
function shareSameDomainSuffix(hostname, vhost) {
if (hostname.endsWith(vhost)) {
return (hostname.length === vhost.length ||
hostname[hostname.length - vhost.length - 1] === '.');
}
return false;
}
/**
* Given a hostname and its public suffix, extract the general domain.
*/
function extractDomainWithSuffix(hostname, publicSuffix) {
// Locate the index of the last '.' in the part of the `hostname` preceding
// the public suffix.
//
// examples:
// 1. not.evil.co.uk => evil.co.uk
// ^ ^
// | | start of public suffix
// | index of the last dot
//
// 2. example.co.uk => example.co.uk
// ^ ^
// | | start of public suffix
// |
// | (-1) no dot found before the public suffix
const publicSuffixIndex = hostname.length - publicSuffix.length - 2;
const lastDotBeforeSuffixIndex = hostname.lastIndexOf('.', publicSuffixIndex);
// No '.' found, then `hostname` is the general domain (no sub-domain)
if (lastDotBeforeSuffixIndex === -1) {
return hostname;
}
// Extract the part between the last '.'
return hostname.slice(lastDotBeforeSuffixIndex + 1);
}
/**
* Detects the domain based on rules and upon and a host string
*/
function getDomain$1(suffix, hostname, options) {
// Check if `hostname` ends with a member of `validHosts`.
if (options.validHosts !== null) {
const validHosts = options.validHosts;
for (const vhost of validHosts) {
if ( /*@__INLINE__*/shareSameDomainSuffix(hostname, vhost)) {
return vhost;
}
}
}
let numberOfLeadingDots = 0;
if (hostname.startsWith('.')) {
while (numberOfLeadingDots < hostname.length &&
hostname[numberOfLeadingDots] === '.') {
numberOfLeadingDots += 1;
}
}
// If `hostname` is a valid public suffix, then there is no domain to return.
// Since we already know that `getPublicSuffix` returns a suffix of `hostname`
// there is no need to perform a string comparison and we only compare the
// size.
if (suffix.length === hostname.length - numberOfLeadingDots) {
return null;
}
// To extract the general domain, we start by identifying the public suffix
// (if any), then consider the domain to be the public suffix with one added
// level of depth. (e.g.: if hostname is `not.evil.co.uk` and public suffix:
// `co.uk`, then we take one more level: `evil`, giving the final result:
// `evil.co.uk`).
return /*@__INLINE__*/ extractDomainWithSuffix(hostname, suffix);
}
/**
* Return the part of domain without suffix.
*
* Example: for domain 'foo.com', the result would be 'foo'.
*/
function getDomainWithoutSuffix$1(domain, suffix) {
// Note: here `domain` and `suffix` cannot have the same length because in
// this case we set `domain` to `null` instead. It is thus safe to assume
// that `suffix` is shorter than `domain`.
return domain.slice(0, -suffix.length - 1);
}
/**
* @param url - URL we want to extract a hostname from.
* @param urlIsValidHostname - hint from caller; true if `url` is already a valid hostname.
*/
function extractHostname(url, urlIsValidHostname) {
let start = 0;
let end = url.length;
let hasUpper = false;
// If url is not already a valid hostname, then try to extract hostname.
if (!urlIsValidHostname) {
// Special handling of data URLs
if (url.startsWith('data:')) {
return null;
}
// Trim leading spaces
while (start < url.length && url.charCodeAt(start) <= 32) {
start += 1;
}
// Trim trailing spaces
while (end > start + 1 && url.charCodeAt(end - 1) <= 32) {
end -= 1;
}
// Skip scheme.
if (url.charCodeAt(start) === 47 /* '/' */ &&
url.charCodeAt(start + 1) === 47 /* '/' */) {
start += 2;
}
else {
const indexOfProtocol = url.indexOf(':/', start);
if (indexOfProtocol !== -1) {
// Implement fast-path for common protocols. We expect most protocols
// should be one of these 4 and thus we will not need to perform the
// more expansive validity check most of the time.
const protocolSize = indexOfProtocol - start;
const c0 = url.charCodeAt(start);
const c1 = url.charCodeAt(start + 1);
const c2 = url.charCodeAt(start + 2);
const c3 = url.charCodeAt(start + 3);
const c4 = url.charCodeAt(start + 4);
if (protocolSize === 5 &&
c0 === 104 /* 'h' */ &&
c1 === 116 /* 't' */ &&
c2 === 116 /* 't' */ &&
c3 === 112 /* 'p' */ &&
c4 === 115 /* 's' */) ;
else if (protocolSize === 4 &&
c0 === 104 /* 'h' */ &&
c1 === 116 /* 't' */ &&
c2 === 116 /* 't' */ &&
c3 === 112 /* 'p' */) ;
else if (protocolSize === 3 &&
c0 === 119 /* 'w' */ &&
c1 === 115 /* 's' */ &&
c2 === 115 /* 's' */) ;
else if (protocolSize === 2 &&
c0 === 119 /* 'w' */ &&
c1 === 115 /* 's' */) ;
else {
// Check that scheme is valid
for (let i = start; i < indexOfProtocol; i += 1) {
const lowerCaseCode = url.charCodeAt(i) | 32;
if (!(((lowerCaseCode >= 97 && lowerCaseCode <= 122) || // [a, z]
(lowerCaseCode >= 48 && lowerCaseCode <= 57) || // [0, 9]
lowerCaseCode === 46 || // '.'
lowerCaseCode === 45 || // '-'
lowerCaseCode === 43) // '+'
)) {
return null;
}
}
}
// Skip 0, 1 or more '/' after ':/'
start = indexOfProtocol + 2;
while (url.charCodeAt(start) === 47 /* '/' */) {
start += 1;
}
}
}
// Detect first occurrence of '/', '?' or '#'. We also keep track of the
// last occurrence of '@', ']' or ':' to speed-up subsequent parsing of
// (respectively), identifier, ipv6 or port.
let indexOfIdentifier = -1;
let indexOfClosingBracket = -1;
let indexOfPort = -1;
for (let i = start; i < end; i += 1) {
const code = url.charCodeAt(i);
if (code === 35 || // '#'
code === 47 || // '/'
code === 63 // '?'
) {
end = i;
break;
}
else if (code === 64) {
// '@'
indexOfIdentifier = i;
}
else if (code === 93) {
// ']'
indexOfClosingBracket = i;
}
else if (code === 58) {
// ':'
indexOfPort = i;
}
else if (code >= 65 && code <= 90) {
hasUpper = true;
}
}
// Detect identifier: '@'
if (indexOfIdentifier !== -1 &&
indexOfIdentifier > start &&
indexOfIdentifier < end) {
start = indexOfIdentifier + 1;
}
// Handle ipv6 addresses
if (url.charCodeAt(start) === 91 /* '[' */) {
if (indexOfClosingBracket !== -1) {
return url.slice(start + 1, indexOfClosingBracket).toLowerCase();
}
return null;
}
else if (indexOfPort !== -1 && indexOfPort > start && indexOfPort < end) {
// Detect port: ':'
end = indexOfPort;
}
}
// Trim trailing dots
while (end > start + 1 && url.charCodeAt(end - 1) === 46 /* '.' */) {
end -= 1;
}
const hostname = start !== 0 || end !== url.length ? url.slice(start, end) : url;
if (hasUpper) {
return hostname.toLowerCase();
}
return hostname;
}
/**
* Check if a hostname is an IP. You should be aware that this only works
* because `hostname` is already garanteed to be a valid hostname!
*/
function isProbablyIpv4(hostname) {
// Cannot be shorted than 1.1.1.1
if (hostname.length < 7) {
return false;
}
// Cannot be longer than: 255.255.255.255
if (hostname.length > 15) {
return false;
}
let numberOfDots = 0;
for (let i = 0; i < hostname.length; i += 1) {
const code = hostname.charCodeAt(i);
if (code === 46 /* '.' */) {
numberOfDots += 1;
}
else if (code < 48 /* '0' */ || code > 57 /* '9' */) {
return false;
}
}
return (numberOfDots === 3 &&
hostname.charCodeAt(0) !== 46 /* '.' */ &&
hostname.charCodeAt(hostname.length - 1) !== 46 /* '.' */);
}
/**
* Similar to isProbablyIpv4.
*/
function isProbablyIpv6(hostname) {
if (hostname.length < 3) {
return false;
}
let start = hostname.startsWith('[') ? 1 : 0;
let end = hostname.length;
if (hostname[end - 1] === ']') {
end -= 1;
}
// We only consider the maximum size of a normal IPV6. Note that this will
// fail on so-called "IPv4 mapped IPv6 addresses" but this is a corner-case
// and a proper validation library should be used for these.
if (end - start > 39) {
return false;
}
let hasColon = false;
for (; start < end; start += 1) {
const code = hostname.charCodeAt(start);
if (code === 58 /* ':' */) {
hasColon = true;
}
else if (!(((code >= 48 && code <= 57) || // 0-9
(code >= 97 && code <= 102) || // a-f
(code >= 65 && code <= 90)) // A-F
)) {
return false;
}
}
return hasColon;
}
/**
* Check if `hostname` is *probably* a valid ip addr (either ipv6 or ipv4).
* This *will not* work on any string. We need `hostname` to be a valid
* hostname.
*/
function isIp(hostname) {
return isProbablyIpv6(hostname) || isProbablyIpv4(hostname);
}
/**
* Implements fast shallow verification of hostnames. This does not perform a
* struct check on the content of labels (classes of Unicode characters, etc.)
* but instead check that the structure is valid (number of labels, length of
* labels, etc.).
*
* If you need stricter validation, consider using an external library.
*/
function isValidAscii(code) {
return ((code >= 97 && code <= 122) || (code >= 48 && code <= 57) || code > 127);
}
/**
* Check if a hostname string is valid. It's usually a preliminary check before
* trying to use getDomain or anything else.
*
* Beware: it does not check if the TLD exists.
*/
function isValidHostname (hostname) {
if (hostname.length > 255) {
return false;
}
if (hostname.length === 0) {
return false;
}
if (
/*@__INLINE__*/ !isValidAscii(hostname.charCodeAt(0)) &&
hostname.charCodeAt(0) !== 46 && // '.' (dot)
hostname.charCodeAt(0) !== 95 // '_' (underscore)
) {
return false;
}
// Validate hostname according to RFC
let lastDotIndex = -1;
let lastCharCode = -1;
const len = hostname.length;
for (let i = 0; i < len; i += 1) {
const code = hostname.charCodeAt(i);
if (code === 46 /* '.' */) {
if (
// Check that previous label is < 63 bytes long (64 = 63 + '.')
i - lastDotIndex > 64 ||
// Check that previous character was not already a '.'
lastCharCode === 46 ||
// Check that the previous label does not end with a '-' (dash)
lastCharCode === 45 ||
// Check that the previous label does not end with a '_' (underscore)
lastCharCode === 95) {
return false;
}
lastDotIndex = i;
}
else if (!( /*@__INLINE__*/(isValidAscii(code) || code === 45 || code === 95))) {
// Check if there is a forbidden character in the label
return false;
}
lastCharCode = code;
}
return (
// Check that last label is shorter than 63 chars
len - lastDotIndex - 1 <= 63 &&
// Check that the last character is an allowed trailing label character.
// Since we already checked that the char is a valid hostname character,
// we only need to check that it's different from '-'.
lastCharCode !== 45);
}
function setDefaultsImpl({ allowIcannDomains = true, allowPrivateDomains = false, detectIp = true, extractHostname = true, mixedInputs = true, validHosts = null, validateHostname = true, }) {
return {
allowIcannDomains,
allowPrivateDomains,
detectIp,
extractHostname,
mixedInputs,
validHosts,
validateHostname,
};
}
const DEFAULT_OPTIONS = /*@__INLINE__*/ setDefaultsImpl({});
function setDefaults(options) {
if (options === undefined) {
return DEFAULT_OPTIONS;
}
return /*@__INLINE__*/ setDefaultsImpl(options);
}
/**
* Returns the subdomain of a hostname string
*/
function getSubdomain$1(hostname, domain) {
// If `hostname` and `domain` are the same, then there is no sub-domain
if (domain.length === hostname.length) {
return '';
}
return hostname.slice(0, -domain.length - 1);
}
/**
* Implement a factory allowing to plug different implementations of suffix
* lookup (e.g.: using a trie or the packed hashes datastructures). This is used
* and exposed in `tldts.ts` and `tldts-experimental.ts` bundle entrypoints.
*/
function getEmptyResult() {
return {
domain: null,
domainWithoutSuffix: null,
hostname: null,
isIcann: null,
isIp: null,
isPrivate: null,
publicSuffix: null,
subdomain: null,
};
}
function resetResult(result) {
result.domain = null;
result.domainWithoutSuffix = null;
result.hostname = null;
result.isIcann = null;
result.isIp = null;
result.isPrivate = null;
result.publicSuffix = null;
result.subdomain = null;
}
function parseImpl(url, step, suffixLookup, partialOptions, result) {
const options = /*@__INLINE__*/ setDefaults(partialOptions);
// Very fast approximate check to make sure `url` is a string. This is needed
// because the library will not necessarily be used in a typed setup and
// values of arbitrary types might be given as argument.
if (typeof url !== 'string') {
return result;
}
// Extract hostname from `url` only if needed. This can be made optional
// using `options.extractHostname`. This option will typically be used
// whenever we are sure the inputs to `parse` are already hostnames and not
// arbitrary URLs.
//
// `mixedInput` allows to specify if we expect a mix of URLs and hostnames
// as input. If only hostnames are expected then `extractHostname` can be
// set to `false` to speed-up parsing. If only URLs are expected then
// `mixedInputs` can be set to `false`. The `mixedInputs` is only a hint
// and will not change the behavior of the library.
if (!options.extractHostname) {
result.hostname = url;
}
else if (options.mixedInputs) {
result.hostname = extractHostname(url, isValidHostname(url));
}
else {
result.hostname = extractHostname(url, false);
}
// Check if `hostname` is a valid ip address
if (options.detectIp && result.hostname !== null) {
result.isIp = isIp(result.hostname);
if (result.isIp) {
return result;
}
}
// Perform hostname validation if enabled. If hostname is not valid, no need to
// go further as there will be no valid domain or sub-domain. This validation
// is applied before any early returns to ensure consistent behavior across
// all API methods including getHostname().
if (options.validateHostname &&
options.extractHostname &&
result.hostname !== null &&
!isValidHostname(result.hostname)) {
result.hostname = null;
return result;
}
if (step === 0 /* FLAG.HOSTNAME */ || result.hostname === null) {
return result;
}
// Extract public suffix
suffixLookup(result.hostname, options, result);
if (step === 2 /* FLAG.PUBLIC_SUFFIX */ || result.publicSuffix === null) {
return result;
}
// Extract domain
result.domain = getDomain$1(result.publicSuffix, result.hostname, options);
if (step === 3 /* FLAG.DOMAIN */ || result.domain === null) {
return result;
}
// Extract subdomain
result.subdomain = getSubdomain$1(result.hostname, result.domain);
if (step === 4 /* FLAG.SUB_DOMAIN */) {
return result;
}
// Extract domain without suffix
result.domainWithoutSuffix = getDomainWithoutSuffix$1(result.domain, result.publicSuffix);
return result;
}
function fastPathLookup (hostname, options, out) {
// Fast path for very popular suffixes; this allows to by-pass lookup
// completely as well as any extra allocation or string manipulation.
if (!options.allowPrivateDomains && hostname.length > 3) {
const last = hostname.length - 1;
const c3 = hostname.charCodeAt(last);
const c2 = hostname.charCodeAt(last - 1);
const c1 = hostname.charCodeAt(last - 2);
const c0 = hostname.charCodeAt(last - 3);
if (c3 === 109 /* 'm' */ &&
c2 === 111 /* 'o' */ &&
c1 === 99 /* 'c' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'com';
return true;
}
else if (c3 === 103 /* 'g' */ &&
c2 === 114 /* 'r' */ &&
c1 === 111 /* 'o' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'org';
return true;
}
else if (c3 === 117 /* 'u' */ &&
c2 === 100 /* 'd' */ &&
c1 === 101 /* 'e' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'edu';
return true;
}
else if (c3 === 118 /* 'v' */ &&
c2 === 111 /* 'o' */ &&
c1 === 103 /* 'g' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'gov';
return true;
}
else if (c3 === 116 /* 't' */ &&
c2 === 101 /* 'e' */ &&
c1 === 110 /* 'n' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'net';
return true;
}
else if (c3 === 101 /* 'e' */ &&
c2 === 100 /* 'd' */ &&
c1 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'de';
return true;
}
}
return false;
}
const exceptions = (function () {
const _0 = [1, {}], _1 = [0, { "city": _0 }];
const exceptions = [0, { "ck": [0, { "www": _0 }], "jp": [0, { "kawasaki": _1, "kitakyushu": _1, "kobe": _1, "nagoya": _1, "sapporo": _1, "sendai": _1, "yokohama": _1 }] }];
return exceptions;
})();
const rules = (function () {
const _2 = [1, {}], _3 = [2, {}], _4 = [1, { "com": _2, "edu": _2, "gov": _2, "net": _2, "org": _2 }], _5 = [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2 }], _6 = [0, { "*": _3 }], _7 = [2, { "s": _6 }], _8 = [0, { "relay": _3 }], _9 = [2, { "id": _3 }], _10 = [1, { "gov": _2 }], _11 = [0, { "airflow": _6, "lambda-url": _3, "transfer-webapp": _3 }], _12 = [0, { "airflow": _6, "transfer-webapp": _3 }], _13 = [0, { "transfer-webapp": _3, "transfer-webapp-fips": _3 }], _14 = [0, { "notebook": _3, "studio": _3 }], _15 = [0, { "labeling": _3, "notebook": _3, "studio": _3 }], _16 = [0, { "notebook": _3 }], _17 = [0, { "labeling": _3, "notebook": _3, "notebook-fips": _3, "studio": _3 }], _18 = [0, { "notebook": _3, "notebook-fips": _3, "studio": _3, "studio-fips": _3 }], _19 = [0, { "shop": _3 }], _20 = [0, { "*": _2 }], _21 = [1, { "co": _3 }], _22 = [0, { "objects": _3 }], _23 = [2, { "nodes": _3 }], _24 = [0, { "my": _3 }], _25 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-website": _3 }], _26 = [0, { "s3": _3, "s3-accesspoint": _3 }], _27 = [0, { "direct": _3 }], _28 = [0, { "webview-assets": _3 }], _29 = [0, { "vfs": _3, "webview-assets": _3 }], _30 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _31 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _26, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _32 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "analytics-gateway": _3, "aws-cloud9": _28, "cloud9": _29 }], _33 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3 }], _34 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-website": _3 }], _35 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _34, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _36 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _34, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-deprecated": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3, "analytics-gateway": _3, "aws-cloud9": _28, "cloud9": _29 }], _37 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3 }], _38 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _37, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3 }], _39 = [0, { "auth": _3 }], _40 = [0, { "auth": _3, "auth-fips": _3 }], _41 = [0, { "auth-fips": _3 }], _42 = [0, { "apps": _3 }], _43 = [0, { "paas": _3 }], _44 = [2, { "eu": _3 }], _45 = [0, { "app": _3 }], _46 = [0, { "site": _3 }], _47 = [1, { "com": _2, "edu": _2, "net": _2, "org": _2 }], _48 = [0, { "j": _3 }], _49 = [0, { "dyn": _3 }], _50 = [2, { "web": _3 }], _51 = [1, { "co": _2, "com": _2, "edu": _2, "gov": _2, "net": _2, "org": _2 }], _52 = [0, { "p": _3 }], _53 = [0, { "user": _3 }], _54 = [0, { "cdn": _3 }], _55 = [2, { "raw": _6 }], _56 = [0, { "cust": _3, "reservd": _3 }], _57 = [0, { "cust": _3 }], _58 = [0, { "s3": _3 }], _59 = [1, { "biz": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "net": _2, "org": _2 }], _60 = [0, { "ipfs": _3 }], _61 = [1, { "framer": _3 }], _62 = [0, { "forgot": _3 }], _63 = [1, { "gs": _2 }], _64 = [0, { "nes": _2 }], _65 = [1, { "k12": _2, "cc": _2, "lib": _2 }], _66 = [1, { "cc": _2 }], _67 = [1, { "cc": _2, "lib": _2 }];
const rules = [0, { "ac": [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "drr": _3, "feedback": _3, "forms": _3 }], "ad": _2, "ae": [1, { "ac": _2, "co": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "sch": _2 }], "aero": [1, { "airline": _2, "airport": _2, "accident-investigation": _2, "accident-prevention": _2, "aerobatic": _2, "aeroclub": _2, "aerodrome": _2, "agents": _2, "air-surveillance": _2, "air-traffic-control": _2, "aircraft": _2, "airtraffic": _2, "ambulance": _2, "association": _2, "author": _2, "ballooning": _2, "broker": _2, "caa": _2, "cargo": _2, "catering": _2, "certification": _2, "championship": _2, "charter": _2, "civilaviation": _2, "club": _2, "conference": _2, "consultant": _2, "consulting": _2, "control": _2, "council": _2, "crew": _2, "design": _2, "dgca": _2, "educator": _2, "emergency": _2, "engine": _2, "engineer": _2, "entertainment": _2, "equipment": _2, "exchange": _2, "express": _2, "federation": _2, "flight": _2, "freight": _2, "fuel": _2, "gliding": _2, "government": _2, "groundhandling": _2, "group": _2, "hanggliding": _2, "homebuilt": _2, "insurance": _2, "journal": _2, "journalist": _2, "leasing": _2, "logistics": _2, "magazine": _2, "maintenance": _2, "marketplace": _2, "media": _2, "microlight": _2, "modelling": _2, "navigation": _2, "parachuting": _2, "paragliding": _2, "passenger-association": _2, "pilot": _2, "press": _2, "production": _2, "recreation": _2, "repbody": _2, "res": _2, "research": _2, "rotorcraft": _2, "safety": _2, "scientist": _2, "services": _2, "show": _2, "skydiving": _2, "software": _2, "student": _2, "taxi": _2, "trader": _2, "trading": _2, "trainer": _2, "union": _2, "workinggroup": _2, "works": _2 }], "af": _4, "ag": [1, { "co": _2, "com": _2, "net": _2, "nom": _2, "org": _2, "obj": _3 }], "ai": [1, { "com": _2, "net": _2, "off": _2, "org": _2, "uwu": _3, "framer": _3 }], "al": _5, "am": [1, { "co": _2, "com": _2, "commune": _2, "net": _2, "org": _2, "radio": _3 }], "ao": [1, { "co": _2, "ed": _2, "edu": _2, "gov": _2, "gv": _2, "it": _2, "og": _2, "org": _2, "pb": _2 }], "aq": _2, "ar": [1, { "bet": _2, "com": _2, "coop": _2, "edu": _2, "gob": _2, "gov": _2, "int": _2, "mil": _2, "musica": _2, "mutual": _2, "net": _2, "org": _2, "seg": _2, "senasa": _2, "tur": _2 }], "arpa": [1, { "e164": _2, "home": _2, "in-addr": _2, "ip6": _2, "iris": _2, "uri": _2, "urn": _2 }], "as": _10, "asia": [1, { "cloudns": _3, "daemon": _3, "dix": _3 }], "at": [1, { "4": _3, "ac": [1, { "sth": _2 }], "co": _2, "gv": _2, "or": _2, "funkfeuer": [0, { "wien": _3 }], "futurecms": [0, { "*": _3, "ex": _6, "in": _6 }], "futurehosting": _3, "futuremailing": _3, "ortsinfo": [0, { "ex": _6, "kunden": _6 }], "biz": _3, "info": _3, "123webseite": _3, "priv": _3, "my": _3, "myspreadshop": _3, "12hp": _3, "2ix": _3, "4lima": _3, "lima-city": _3 }], "au": [1, { "asn": _2, "com": [1, { "cloudlets": [0, { "mel": _3 }], "myspreadshop": _3 }], "edu": [1, { "act": _2, "catholic": _2, "nsw": _2, "nt": _2, "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2 }], "gov": [1, { "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2 }], "id": _2, "net": _2, "org": _2, "conf": _2, "oz": _2, "act": _2, "nsw": _2, "nt": _2, "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2, "hrsn": [0, { "vps": _3 }] }], "aw": [1, { "com": _2 }], "ax": _2, "az": [1, { "biz": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "int": _2, "mil": _2, "name": _2, "net": _2, "org": _2, "pp": _2, "pro": _2 }], "ba": [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "brendly": _19, "rs": _3 }], "bb": [1, { "biz": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "net": _2, "org": _2, "store": _2, "tv": _2 }], "bd": [1, { "ac": _2, "ai": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "id": _2, "info": _2, "it": _2, "mil": _2, "net": _2, "org": _2, "sch": _2, "tv": _2 }], "be": [1, { "ac": _2, "cloudns": _3, "webhosting": _3, "interhostsolutions": [0, { "cloud": _3 }], "kuleuven": [0, { "ezproxy": _3 }], "123website": _3, "myspreadshop": _3, "transurl": _6 }], "bf": _10, "bg": [1, { "0": _2, "1": _2, "2": _2, "3": _2, "4": _2, "5": _2, "6": _2, "7": _2, "8": _2, "9": _2, "a": _2, "b": _2, "c": _2, "d": _2, "e": _2, "f": _2, "g": _2, "h": _2, "i": _2, "j": _2, "k": _2, "l": _2, "m": _2, "n": _2, "o": _2, "p": _2, "q": _2, "r": _2, "s": _2, "t": _2, "u": _2, "v": _2, "w": _2, "x": _2, "y": _2, "z": _2, "barsy": _3 }], "bh": _4, "bi": [1, { "co": _2, "com": _2, "edu": _2, "or": _2, "org": _2 }], "biz": [1, { "activetrail": _3, "cloud-ip": _3, "cloudns": _3, "jozi": _3, "dyndns": _3, "for-better": _3, "for-more": _3, "for-some": _3, "for-the": _3, "selfip": _3, "webhop": _3, "orx": _3, "mmafan": _3, "myftp": _3, "no-ip": _3, "dscloud": _3 }], "bj": [1, { "africa": _2, "agro": _2, "architectes": _2, "assur": _2, "avocats": _2, "co": _2, "com": _2, "eco": _2, "econo": _2, "edu": _2, "info": _2, "loisirs": _2, "money": _2, "net": _2, "org": _2, "ote": _2, Line truncated
return rules;
})();
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(parts, trie, index, allowedMask) {
let result = null;
let node = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === 1 /* RULE_TYPE.ICANN */,
isPrivate: node[0] === 2 /* RULE_TYPE.PRIVATE */,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index])
? succ[parts[index]]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
function suffixLookup(hostname, options, out) {
var _a;
if (fastPathLookup(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask = (options.allowPrivateDomains ? 2 /* RULE_TYPE.PRIVATE */ : 0) |
(options.allowIcannDomains ? 1 /* RULE_TYPE.ICANN */ : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(hostnameParts, exceptions, hostnameParts.length - 1, allowedMask);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(hostnameParts, rules, hostnameParts.length - 1, allowedMask);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = (_a = hostnameParts[hostnameParts.length - 1]) !== null && _a !== void 0 ? _a : null;
}
// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT = getEmptyResult();
function parse(url, options = {}) {
return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, getEmptyResult());
}
function getHostname(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 0 /* FLAG.HOSTNAME */, suffixLookup, options, RESULT).hostname;
}
function getPublicSuffix(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 2 /* FLAG.PUBLIC_SUFFIX */, suffixLookup, options, RESULT)
.publicSuffix;
}
function getDomain(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT).domain;
}
function getSubdomain(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 4 /* FLAG.SUB_DOMAIN */, suffixLookup, options, RESULT)
.subdomain;
}
function getDomainWithoutSuffix(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, RESULT)
.domainWithoutSuffix;
}
exports.getDomain = getDomain;
exports.getDomainWithoutSuffix = getDomainWithoutSuffix;
exports.getHostname = getHostname;
exports.getPublicSuffix = getPublicSuffix;
exports.getSubdomain = getSubdomain;
exports.parse = parse;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../tldts-core/src/domain.ts","../../../tldts-core/src/domain-without-suffix.ts","../../../tldts-core/src/extract-hostname.ts","../../../tldts-core/src/is-ip.ts","../../../tldts-core/src/is-valid.ts","../../../tldts-core/src/options.ts","../../../tldts-core/src/subdomain.ts","../../../tldts-core/src/factory.ts","../../../tldts-core/src/lookup/fast-path.ts","../../src/data/trie.ts","../../src/suffix-trie.ts","../../index.ts"],"sourcesContent":["import { IOptions } from './options';\n\n/**\n * Check if `vhost` is a valid suffix of `hostname` (top-domain)\n *\n * It means that `vhost` needs to be a suffix of `hostname` and we then need to\n * make sure that: either they are equal, or the character preceding `vhost` in\n * `hostname` is a '.' (it should not be a partial label).\n *\n * * hostname = 'not.evil.com' and vhost = 'vil.com' => not ok\n * * hostname = 'not.evil.com' and vhost = 'evil.com' => ok\n * * hostname = 'not.evil.com' and vhost = 'not.evil.com' => ok\n */\nfunction shareSameDomainSuffix(hostname: string, vhost: string): boolean {\n if (hostname.endsWith(vhost)) {\n return (\n hostname.length === vhost.length ||\n hostname[hostname.length - vhost.length - 1] === '.'\n );\n }\n\n return false;\n}\n\n/**\n * Given a hostname and its public suffix, extract the general domain.\n */\nfunction extractDomainWithSuffix(\n hostname: string,\n publicSuffix: string,\n): string {\n // Locate the index of the last '.' in the part of the `hostname` preceding\n // the public suffix.\n //\n // examples:\n // 1. not.evil.co.uk => evil.co.uk\n // ^ ^\n // | | start of public suffix\n // | index of the last dot\n //\n // 2. example.co.uk => example.co.uk\n // ^ ^\n // | | start of public suffix\n // |\n // | (-1) no dot found before the public suffix\n const publicSuffixIndex = hostname.length - publicSuffix.length - 2;\n const lastDotBeforeSuffixIndex = hostname.lastIndexOf('.', publicSuffixIndex);\n\n // No '.' found, then `hostname` is the general domain (no sub-domain)\n if (lastDotBeforeSuffixIndex === -1) {\n return hostname;\n }\n\n // Extract the part between the last '.'\n return hostname.slice(lastDotBeforeSuffixIndex + 1);\n}\n\n/**\n * Detects the domain based on rules and upon and a host string\n */\nexport default function getDomain(\n suffix: string,\n hostname: string,\n options: IOptions,\n): string | null {\n // Check if `hostname` ends with a member of `validHosts`.\n if (options.validHosts !== null) {\n const validHosts = options.validHosts;\n for (const vhost of validHosts) {\n if (/*@__INLINE__*/ shareSameDomainSuffix(hostname, vhost)) {\n return vhost;\n }\n }\n }\n\n let numberOfLeadingDots = 0;\n if (hostname.startsWith('.')) {\n while (\n numberOfLeadingDots < hostname.length &&\n hostname[numberOfLeadingDots] === '.'\n ) {\n numberOfLeadingDots += 1;\n }\n }\n\n // If `hostname` is a valid public suffix, then there is no domain to return.\n // Since we already know that `getPublicSuffix` returns a suffix of `hostname`\n // there is no need to perform a string comparison and we only compare the\n // size.\n if (suffix.length === hostname.length - numberOfLeadingDots) {\n return null;\n }\n\n // To extract the general domain, we start by identifying the public suffix\n // (if any), then consider the domain to be the public suffix with one added\n // level of depth. (e.g.: if hostname is `not.evil.co.uk` and public suffix:\n // `co.uk`, then we take one more level: `evil`, giving the final result:\n // `evil.co.uk`).\n return /*@__INLINE__*/ extractDomainWithSuffix(hostname, suffix);\n}\n","/**\n * Return the part of domain without suffix.\n *\n * Example: for domain 'foo.com', the result would be 'foo'.\n */\nexport default function getDomainWithoutSuffix(\n domain: string,\n suffix: string,\n): string {\n // Note: here `domain` and `suffix` cannot have the same length because in\n // this case we set `domain` to `null` instead. It is thus safe to assume\n // that `suffix` is shorter than `domain`.\n return domain.slice(0, -suffix.length - 1);\n}\n","/**\n * @param url - URL we want to extract a hostname from.\n * @param urlIsValidHostname - hint from caller; true if `url` is already a valid hostname.\n */\nexport default function extractHostname(\n url: string,\n urlIsValidHostname: boolean,\n): string | null {\n let start = 0;\n let end: number = url.length;\n let hasUpper = false;\n\n // If url is not already a valid hostname, then try to extract hostname.\n if (!urlIsValidHostname) {\n // Special handling of data URLs\n if (url.startsWith('data:')) {\n return null;\n }\n\n // Trim leading spaces\n while (start < url.length && url.charCodeAt(start) <= 32) {\n start += 1;\n }\n\n // Trim trailing spaces\n Line truncated
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rules = exports.exceptions = void 0;
exports.exceptions = (function () {
const _0 = [1, {}], _1 = [0, { "city": _0 }];
const exceptions = [0, { "ck": [0, { "www": _0 }], "jp": [0, { "kawasaki": _1, "kitakyushu": _1, "kobe": _1, "nagoya": _1, "sapporo": _1, "sendai": _1, "yokohama": _1 }] }];
return exceptions;
})();
exports.rules = (function () {
const _2 = [1, {}], _3 = [2, {}], _4 = [1, { "com": _2, "edu": _2, "gov": _2, "net": _2, "org": _2 }], _5 = [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2 }], _6 = [0, { "*": _3 }], _7 = [2, { "s": _6 }], _8 = [0, { "relay": _3 }], _9 = [2, { "id": _3 }], _10 = [1, { "gov": _2 }], _11 = [0, { "airflow": _6, "lambda-url": _3, "transfer-webapp": _3 }], _12 = [0, { "airflow": _6, "transfer-webapp": _3 }], _13 = [0, { "transfer-webapp": _3, "transfer-webapp-fips": _3 }], _14 = [0, { "notebook": _3, "studio": _3 }], _15 = [0, { "labeling": _3, "notebook": _3, "studio": _3 }], _16 = [0, { "notebook": _3 }], _17 = [0, { "labeling": _3, "notebook": _3, "notebook-fips": _3, "studio": _3 }], _18 = [0, { "notebook": _3, "notebook-fips": _3, "studio": _3, "studio-fips": _3 }], _19 = [0, { "shop": _3 }], _20 = [0, { "*": _2 }], _21 = [1, { "co": _3 }], _22 = [0, { "objects": _3 }], _23 = [2, { "nodes": _3 }], _24 = [0, { "my": _3 }], _25 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-website": _3 }], _26 = [0, { "s3": _3, "s3-accesspoint": _3 }], _27 = [0, { "direct": _3 }], _28 = [0, { "webview-assets": _3 }], _29 = [0, { "vfs": _3, "webview-assets": _3 }], _30 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _31 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _26, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _32 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "analytics-gateway": _3, "aws-cloud9": _28, "cloud9": _29 }], _33 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3 }], _34 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-website": _3 }], _35 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _34, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _36 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _34, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-deprecated": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3, "analytics-gateway": _3, "aws-cloud9": _28, "cloud9": _29 }], _37 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3 }], _38 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _37, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3 }], _39 = [0, { "auth": _3 }], _40 = [0, { "auth": _3, "auth-fips": _3 }], _41 = [0, { "auth-fips": _3 }], _42 = [0, { "apps": _3 }], _43 = [0, { "paas": _3 }], _44 = [2, { "eu": _3 }], _45 = [0, { "app": _3 }], _46 = [0, { "site": _3 }], _47 = [1, { "com": _2, "edu": _2, "net": _2, "org": _2 }], _48 = [0, { "j": _3 }], _49 = [0, { "dyn": _3 }], _50 = [2, { "web": _3 }], _51 = [1, { "co": _2, "com": _2, "edu": _2, "gov": _2, "net": _2, "org": _2 }], _52 = [0, { "p": _3 }], _53 = [0, { "user": _3 }], _54 = [0, { "cdn": _3 }], _55 = [2, { "raw": _6 }], _56 = [0, { "cust": _3, "reservd": _3 }], _57 = [0, { "cust": _3 }], _58 = [0, { "s3": _3 }], _59 = [1, { "biz": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "net": _2, "org": _2 }], _60 = [0, { "ipfs": _3 }], _61 = [1, { "framer": _3 }], _62 = [0, { "forgot": _3 }], _63 = [1, { "gs": _2 }], _64 = [0, { "nes": _2 }], _65 = [1, { "k12": _2, "cc": _2, "lib": _2 }], _66 = [1, { "cc": _2 }], _67 = [1, { "cc": _2, "lib": _2 }];
const rules = [0, { "ac": [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "drr": _3, "feedback": _3, "forms": _3 }], "ad": _2, "ae": [1, { "ac": _2, "co": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "sch": _2 }], "aero": [1, { "airline": _2, "airport": _2, "accident-investigation": _2, "accident-prevention": _2, "aerobatic": _2, "aeroclub": _2, "aerodrome": _2, "agents": _2, "air-surveillance": _2, "air-traffic-control": _2, "aircraft": _2, "airtraffic": _2, "ambulance": _2, "association": _2, "author": _2, "ballooning": _2, "broker": _2, "caa": _2, "cargo": _2, "catering": _2, "certification": _2, "championship": _2, "charter": _2, "civilaviation": _2, "club": _2, "conference": _2, "consultant": _2, "consulting": _2, "control": _2, "council": _2, "crew": _2, "design": _2, "dgca": _2, "educator": _2, "emergency": _2, "engine": _2, "engineer": _2, "entertainment": _2, "equipment": _2, "exchange": _2, "express": _2, "federation": _2, "flight": _2, "freight": _2, "fuel": _2, "gliding": _2, "government": _2, "groundhandling": _2, "group": _2, "hanggliding": _2, "homebuilt": _2, "insurance": _2, "journal": _2, "journalist": _2, "leasing": _2, "logistics": _2, "magazine": _2, "maintenance": _2, "marketplace": _2, "media": _2, "microlight": _2, "modelling": _2, "navigation": _2, "parachuting": _2, "paragliding": _2, "passenger-association": _2, "pilot": _2, "press": _2, "production": _2, "recreation": _2, "repbody": _2, "res": _2, "research": _2, "rotorcraft": _2, "safety": _2, "scientist": _2, "services": _2, "show": _2, "skydiving": _2, "software": _2, "student": _2, "taxi": _2, "trader": _2, "trading": _2, "trainer": _2, "union": _2, "workinggroup": _2, "works": _2 }], "af": _4, "ag": [1, { "co": _2, "com": _2, "net": _2, "nom": _2, "org": _2, "obj": _3 }], "ai": [1, { "com": _2, "net": _2, "off": _2, "org": _2, "uwu": _3, "framer": _3 }], "al": _5, "am": [1, { "co": _2, "com": _2, "commune": _2, "net": _2, "org": _2, "radio": _3 }], "ao": [1, { "co": _2, "ed": _2, "edu": _2, "gov": _2, "gv": _2, "it": _2, "og": _2, "org": _2, "pb": _2 }], "aq": _2, "ar": [1, { "bet": _2, "com": _2, "coop": _2, "edu": _2, "gob": _2, "gov": _2, "int": _2, "mil": _2, "musica": _2, "mutual": _2, "net": _2, "org": _2, "seg": _2, "senasa": _2, "tur": _2 }], "arpa": [1, { "e164": _2, "home": _2, "in-addr": _2, "ip6": _2, "iris": _2, "uri": _2, "urn": _2 }], "as": _10, "asia": [1, { "cloudns": _3, "daemon": _3, "dix": _3 }], "at": [1, { "4": _3, "ac": [1, { "sth": _2 }], "co": _2, "gv": _2, "or": _2, "funkfeuer": [0, { "wien": _3 }], "futurecms": [0, { "*": _3, "ex": _6, "in": _6 }], "futurehosting": _3, "futuremailing": _3, "ortsinfo": [0, { "ex": _6, "kunden": _6 }], "biz": _3, "info": _3, "123webseite": _3, "priv": _3, "my": _3, "myspreadshop": _3, "12hp": _3, "2ix": _3, "4lima": _3, "lima-city": _3 }], "au": [1, { "asn": _2, "com": [1, { "cloudlets": [0, { "mel": _3 }], "myspreadshop": _3 }], "edu": [1, { "act": _2, "catholic": _2, "nsw": _2, "nt": _2, "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2 }], "gov": [1, { "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2 }], "id": _2, "net": _2, "org": _2, "conf": _2, "oz": _2, "act": _2, "nsw": _2, "nt": _2, "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2, "hrsn": [0, { "vps": _3 }] }], "aw": [1, { "com": _2 }], "ax": _2, "az": [1, { "biz": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "int": _2, "mil": _2, "name": _2, "net": _2, "org": _2, "pp": _2, "pro": _2 }], "ba": [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "brendly": _19, "rs": _3 }], "bb": [1, { "biz": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "net": _2, "org": _2, "store": _2, "tv": _2 }], "bd": [1, { "ac": _2, "ai": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "id": _2, "info": _2, "it": _2, "mil": _2, "net": _2, "org": _2, "sch": _2, "tv": _2 }], "be": [1, { "ac": _2, "cloudns": _3, "webhosting": _3, "interhostsolutions": [0, { "cloud": _3 }], "kuleuven": [0, { "ezproxy": _3 }], "123website": _3, "myspreadshop": _3, "transurl": _6 }], "bf": _10, "bg": [1, { "0": _2, "1": _2, "2": _2, "3": _2, "4": _2, "5": _2, "6": _2, "7": _2, "8": _2, "9": _2, "a": _2, "b": _2, "c": _2, "d": _2, "e": _2, "f": _2, "g": _2, "h": _2, "i": _2, "j": _2, "k": _2, "l": _2, "m": _2, "n": _2, "o": _2, "p": _2, "q": _2, "r": _2, "s": _2, "t": _2, "u": _2, "v": _2, "w": _2, "x": _2, "y": _2, "z": _2, "barsy": _3 }], "bh": _4, "bi": [1, { "co": _2, "com": _2, "edu": _2, "or": _2, "org": _2 }], "biz": [1, { "activetrail": _3, "cloud-ip": _3, "cloudns": _3, "jozi": _3, "dyndns": _3, "for-better": _3, "for-more": _3, "for-some": _3, "for-the": _3, "selfip": _3, "webhop": _3, "orx": _3, "mmafan": _3, "myftp": _3, "no-ip": _3, "dscloud": _3 }], "bj": [1, { "africa": _2, "agro": _2, "architectes": _2, "assur": _2, "avocats": _2, "co": _2, "com": _2, "eco": _2, "econo": _2, "edu": _2, "info": _2, "loisirs": _2, "money": _2, "net": _2, "org": _2, "ote": _2, Line truncated
return rules;
})();
//# sourceMappingURL=trie.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"trie.js","sourceRoot":"","sources":["../../../../src/data/trie.ts"],"names":[],"mappings":";;;AAGa,QAAA,UAAU,GAAU,CAAC;IAChC,MAAM,EAAE,GAAU,CAAC,CAAC,EAAC,EAAE,CAAC,EAAC,EAAE,GAAU,CAAC,CAAC,EAAC,EAAC,MAAM,EAAC,EAAE,EAAC,CAAC,CAAC;IACvD,MAAM,UAAU,GAAU,CAAC,CAAC,EAA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AAE,EAAC,mBAAmB,EAAC,EAAE,EAAC,gBAAgB,EAAC,EAAE,EAAC,WAAW,EAAC,GAAG,EAAC,IAAI,EAAC,EAAE,EAAC,gBAAgB,EAAC,EAAE,EAAC,qBAAqB,EAAC,EAAE,EAAC,eAAe,EAAC,EAAE,EAAC,SAAS,EAAC,EAAE,EAAC,kBAAkB,EAAC,EAAE,EAAC,YAAY,EAAC,EAAE,EAAC,mBAAmB,EAAC,EAAE,EAAC,YAAY,EAAC,GAAG,EAAC,QAAQ,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,GAAU,CAAC,CAAC,EAAC,EAAC,IAAI,EAAC,EAAE,EAAC,gBAAgB,EAAC,EAAE,EAAC,qBAAqB,EAAC,EAAE,EAAC,SAAS,EAAC,EAAE,EAAC,CAAC,EAAC,GAAG,GAAU,CAAC,CAAC,EAAC,EAAC,aAAa,EAAC,EAAE,EAAC,eAAe,EAAC,EAAE,EAAC,mBAAmB,EAAC,EAAE,EAAC,gBAAgB,EAAC,EAAE,EAAC,WAAW,EAAC,GAAG,EAAC,IAAI,EAAC,EAAE,EAAC,gBAAgB,EAAC,EAAE,EAAC,qBAAqB,EAAC,EAAE,EAAC,SAAS,EAAC,EAAE,ELine truncated
+67
View File
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = suffixLookup;
const tldts_core_1 = require("tldts-core");
const trie_1 = require("./data/trie");
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(parts, trie, index, allowedMask) {
let result = null;
let node = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === 1 /* RULE_TYPE.ICANN */,
isPrivate: node[0] === 2 /* RULE_TYPE.PRIVATE */,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index])
? succ[parts[index]]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
function suffixLookup(hostname, options, out) {
var _a;
if ((0, tldts_core_1.fastPathLookup)(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask = (options.allowPrivateDomains ? 2 /* RULE_TYPE.PRIVATE */ : 0) |
(options.allowIcannDomains ? 1 /* RULE_TYPE.ICANN */ : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(hostnameParts, trie_1.exceptions, hostnameParts.length - 1, allowedMask);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(hostnameParts, trie_1.rules, hostnameParts.length - 1, allowedMask);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = (_a = hostnameParts[hostnameParts.length - 1]) !== null && _a !== void 0 ? _a : null;
}
//# sourceMappingURL=suffix-trie.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"suffix-trie.js","sourceRoot":"","sources":["../../../src/suffix-trie.ts"],"names":[],"mappings":";;AA0DA,+BAmDC;AA7GD,2CAIoB;AACpB,sCAAuD;AAcvD;;GAEG;AACH,SAAS,YAAY,CACnB,KAAe,EACf,IAAW,EACX,KAAa,EACb,WAAmB;IAEnB,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,IAAI,IAAI,GAAsB,IAAI,CAAC;IACnC,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,mBAAmB;QACnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YA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G,cAAc,CAAC,OAAO,CAAC;QACrC,GAAG,CAAC,SAAS,GAAG,cAAc,CAAC,SAAS,CAAC;QACzC,GAAG,CAAC,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3E,OAAO;IACT,CAAC;IAED,4BAA4B;IAC5B,MAAM,UAAU,GAAG,YAAY,CAC7B,aAAa,EACb,YAAK,EACL,aAAa,CAAC,MAAM,GAAG,CAAC,EACxB,WAAW,CACZ,CAAC;IAEF,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QACjC,GAAG,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACrC,GAAG,CAAC,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnE,OAAO;IACT,CAAC;IAED,oBAAoB;IACpB,uEAAuE;IACvE,8DAA8D;IAC9D,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACpB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;IACtB,GAAG,CAAC,YAAY,GAAG,MAAA,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,mCAAI,IAAI,CAAC;AACrE,CAAC"}
+1
View File
@@ -0,0 +1 @@
{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../node_modules/typescript/lib/lib.scripthost.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../../../node_modules/typescript/lib/lib.esnext.float16.d.ts","../../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/typescript/lib/lib.es2017.full.d.ts","../../../tldts-core/dist/types/src/lookup/interface.d.ts","../../../tldts-core/dist/types/src/options.d.ts","../../../tldts-core/dist/types/src/factory.d.ts","../../../tldts-core/dist/types/src/lookup/fast-path.d.ts","../../../tldts-core/dist/types/index.d.ts","../../src/data/trie.ts","../../src/suffix-trie.ts","../../index.ts","../../../../node_modules/@types/chai/index.d.ts","../../../../node_modules/@types/command-line-args/index.d.ts","../../../../node_modules/@types/command-line-usage/index.d.ts","../../../../node_modules/@types/estree/index.d.ts","../../../../node_modules/@types/minimatch/index.d.ts","../../../../node_modules/@types/minimist/index.d.ts","../../../../node_modules/@types/mocha/index.d.ts","../../../../node_modules/@types/node/compatibility/iterators.d.ts","../../../../node_modules/@types/node/globals.typedarray.d.ts","../../../../node_modules/@types/node/buffer.buffer.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/web-globals/abortcontroller.d.ts","../../../../node_modules/@types/node/web-globals/domexception.d.ts","../../../../node_modules/@types/node/web-globals/events.d.ts","../../../../node_modules/buffer/index.d.ts","../../../../node_modules/undici-types/utility.d.ts","../../../../node_modules/undici-types/header.d.ts","../../../../node_modules/undici-types/readable.d.ts","../../../../node_modules/undici-types/fetch.d.ts","../../../../node_modules/undici-types/formdata.d.ts","../../../../node_modules/undici-types/connector.d.ts","../../../../node_modules/undici-types/client-stats.d.ts","../../../.Line truncated
+33
View File
@@ -0,0 +1,33 @@
import { getEmptyResult, parseImpl, resetResult, } from 'tldts-core';
import suffixLookup from './src/suffix-trie';
// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT = getEmptyResult();
export function parse(url, options = {}) {
return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, getEmptyResult());
}
export function getHostname(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 0 /* FLAG.HOSTNAME */, suffixLookup, options, RESULT).hostname;
}
export function getPublicSuffix(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 2 /* FLAG.PUBLIC_SUFFIX */, suffixLookup, options, RESULT)
.publicSuffix;
}
export function getDomain(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT).domain;
}
export function getSubdomain(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 4 /* FLAG.SUB_DOMAIN */, suffixLookup, options, RESULT)
.subdomain;
}
export function getDomainWithoutSuffix(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, RESULT)
.domainWithoutSuffix;
}
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGd,SAAS,EACT,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C,4EAA4E;AAC5E,+EAA+E;AAC/E,yEAAyE;AACzE,MAAM,MAAM,GAAY,cAAc,EAAE,CAAC;AAEzC,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,UAA6B,EAAE;IAChE,OAAO,SAAS,CAAC,GAAG,oBAAY,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,GAAW,EACX,UAA6B,EAAE;IAE/B,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC,GAAG,yBAAiB,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,GAAW,EACX,UAA6B,EAAE;IAE/B,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC,GAAG,8BAAsB,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;SACrE,YAAY,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,GAAW,EACX,UAA6B,EAAE;IAE/B,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC,GAAG,uBAAe,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,GAAW,EACX,UAA6B,EAAE;IAE/B,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC,GAAG,2BAAmB,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;SAClE,SAAS,CAAC;AACf,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,GAAW,EACX,UAA6B,EAAE;IAE/B,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC,GAAG,oBAAY,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;SAC3D,mBAAmB,CAAC;AACzB,CAAC"}
+11
View File
@@ -0,0 +1,11 @@
export const exceptions = (function () {
const _0 = [1, {}], _1 = [0, { "city": _0 }];
const exceptions = [0, { "ck": [0, { "www": _0 }], "jp": [0, { "kawasaki": _1, "kitakyushu": _1, "kobe": _1, "nagoya": _1, "sapporo": _1, "sendai": _1, "yokohama": _1 }] }];
return exceptions;
})();
export const rules = (function () {
const _2 = [1, {}], _3 = [2, {}], _4 = [1, { "com": _2, "edu": _2, "gov": _2, "net": _2, "org": _2 }], _5 = [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2 }], _6 = [0, { "*": _3 }], _7 = [2, { "s": _6 }], _8 = [0, { "relay": _3 }], _9 = [2, { "id": _3 }], _10 = [1, { "gov": _2 }], _11 = [0, { "airflow": _6, "lambda-url": _3, "transfer-webapp": _3 }], _12 = [0, { "airflow": _6, "transfer-webapp": _3 }], _13 = [0, { "transfer-webapp": _3, "transfer-webapp-fips": _3 }], _14 = [0, { "notebook": _3, "studio": _3 }], _15 = [0, { "labeling": _3, "notebook": _3, "studio": _3 }], _16 = [0, { "notebook": _3 }], _17 = [0, { "labeling": _3, "notebook": _3, "notebook-fips": _3, "studio": _3 }], _18 = [0, { "notebook": _3, "notebook-fips": _3, "studio": _3, "studio-fips": _3 }], _19 = [0, { "shop": _3 }], _20 = [0, { "*": _2 }], _21 = [1, { "co": _3 }], _22 = [0, { "objects": _3 }], _23 = [2, { "nodes": _3 }], _24 = [0, { "my": _3 }], _25 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-website": _3 }], _26 = [0, { "s3": _3, "s3-accesspoint": _3 }], _27 = [0, { "direct": _3 }], _28 = [0, { "webview-assets": _3 }], _29 = [0, { "vfs": _3, "webview-assets": _3 }], _30 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _31 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _26, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _32 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3, "analytics-gateway": _3, "aws-cloud9": _28, "cloud9": _29 }], _33 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _25, "s3": _3, "s3-accesspoint": _3, "s3-object-lambda": _3, "s3-website": _3 }], _34 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-website": _3 }], _35 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _34, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3, "aws-cloud9": _28, "cloud9": _29 }], _36 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _34, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-deprecated": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3, "analytics-gateway": _3, "aws-cloud9": _28, "cloud9": _29 }], _37 = [0, { "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3 }], _38 = [0, { "execute-api": _3, "emrappui-prod": _3, "emrnotebooks-prod": _3, "emrstudio-prod": _3, "dualstack": _37, "s3": _3, "s3-accesspoint": _3, "s3-accesspoint-fips": _3, "s3-fips": _3, "s3-object-lambda": _3, "s3-website": _3 }], _39 = [0, { "auth": _3 }], _40 = [0, { "auth": _3, "auth-fips": _3 }], _41 = [0, { "auth-fips": _3 }], _42 = [0, { "apps": _3 }], _43 = [0, { "paas": _3 }], _44 = [2, { "eu": _3 }], _45 = [0, { "app": _3 }], _46 = [0, { "site": _3 }], _47 = [1, { "com": _2, "edu": _2, "net": _2, "org": _2 }], _48 = [0, { "j": _3 }], _49 = [0, { "dyn": _3 }], _50 = [2, { "web": _3 }], _51 = [1, { "co": _2, "com": _2, "edu": _2, "gov": _2, "net": _2, "org": _2 }], _52 = [0, { "p": _3 }], _53 = [0, { "user": _3 }], _54 = [0, { "cdn": _3 }], _55 = [2, { "raw": _6 }], _56 = [0, { "cust": _3, "reservd": _3 }], _57 = [0, { "cust": _3 }], _58 = [0, { "s3": _3 }], _59 = [1, { "biz": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "net": _2, "org": _2 }], _60 = [0, { "ipfs": _3 }], _61 = [1, { "framer": _3 }], _62 = [0, { "forgot": _3 }], _63 = [1, { "gs": _2 }], _64 = [0, { "nes": _2 }], _65 = [1, { "k12": _2, "cc": _2, "lib": _2 }], _66 = [1, { "cc": _2 }], _67 = [1, { "cc": _2, "lib": _2 }];
const rules = [0, { "ac": [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "drr": _3, "feedback": _3, "forms": _3 }], "ad": _2, "ae": [1, { "ac": _2, "co": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "sch": _2 }], "aero": [1, { "airline": _2, "airport": _2, "accident-investigation": _2, "accident-prevention": _2, "aerobatic": _2, "aeroclub": _2, "aerodrome": _2, "agents": _2, "air-surveillance": _2, "air-traffic-control": _2, "aircraft": _2, "airtraffic": _2, "ambulance": _2, "association": _2, "author": _2, "ballooning": _2, "broker": _2, "caa": _2, "cargo": _2, "catering": _2, "certification": _2, "championship": _2, "charter": _2, "civilaviation": _2, "club": _2, "conference": _2, "consultant": _2, "consulting": _2, "control": _2, "council": _2, "crew": _2, "design": _2, "dgca": _2, "educator": _2, "emergency": _2, "engine": _2, "engineer": _2, "entertainment": _2, "equipment": _2, "exchange": _2, "express": _2, "federation": _2, "flight": _2, "freight": _2, "fuel": _2, "gliding": _2, "government": _2, "groundhandling": _2, "group": _2, "hanggliding": _2, "homebuilt": _2, "insurance": _2, "journal": _2, "journalist": _2, "leasing": _2, "logistics": _2, "magazine": _2, "maintenance": _2, "marketplace": _2, "media": _2, "microlight": _2, "modelling": _2, "navigation": _2, "parachuting": _2, "paragliding": _2, "passenger-association": _2, "pilot": _2, "press": _2, "production": _2, "recreation": _2, "repbody": _2, "res": _2, "research": _2, "rotorcraft": _2, "safety": _2, "scientist": _2, "services": _2, "show": _2, "skydiving": _2, "software": _2, "student": _2, "taxi": _2, "trader": _2, "trading": _2, "trainer": _2, "union": _2, "workinggroup": _2, "works": _2 }], "af": _4, "ag": [1, { "co": _2, "com": _2, "net": _2, "nom": _2, "org": _2, "obj": _3 }], "ai": [1, { "com": _2, "net": _2, "off": _2, "org": _2, "uwu": _3, "framer": _3 }], "al": _5, "am": [1, { "co": _2, "com": _2, "commune": _2, "net": _2, "org": _2, "radio": _3 }], "ao": [1, { "co": _2, "ed": _2, "edu": _2, "gov": _2, "gv": _2, "it": _2, "og": _2, "org": _2, "pb": _2 }], "aq": _2, "ar": [1, { "bet": _2, "com": _2, "coop": _2, "edu": _2, "gob": _2, "gov": _2, "int": _2, "mil": _2, "musica": _2, "mutual": _2, "net": _2, "org": _2, "seg": _2, "senasa": _2, "tur": _2 }], "arpa": [1, { "e164": _2, "home": _2, "in-addr": _2, "ip6": _2, "iris": _2, "uri": _2, "urn": _2 }], "as": _10, "asia": [1, { "cloudns": _3, "daemon": _3, "dix": _3 }], "at": [1, { "4": _3, "ac": [1, { "sth": _2 }], "co": _2, "gv": _2, "or": _2, "funkfeuer": [0, { "wien": _3 }], "futurecms": [0, { "*": _3, "ex": _6, "in": _6 }], "futurehosting": _3, "futuremailing": _3, "ortsinfo": [0, { "ex": _6, "kunden": _6 }], "biz": _3, "info": _3, "123webseite": _3, "priv": _3, "my": _3, "myspreadshop": _3, "12hp": _3, "2ix": _3, "4lima": _3, "lima-city": _3 }], "au": [1, { "asn": _2, "com": [1, { "cloudlets": [0, { "mel": _3 }], "myspreadshop": _3 }], "edu": [1, { "act": _2, "catholic": _2, "nsw": _2, "nt": _2, "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2 }], "gov": [1, { "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2 }], "id": _2, "net": _2, "org": _2, "conf": _2, "oz": _2, "act": _2, "nsw": _2, "nt": _2, "qld": _2, "sa": _2, "tas": _2, "vic": _2, "wa": _2, "hrsn": [0, { "vps": _3 }] }], "aw": [1, { "com": _2 }], "ax": _2, "az": [1, { "biz": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "int": _2, "mil": _2, "name": _2, "net": _2, "org": _2, "pp": _2, "pro": _2 }], "ba": [1, { "com": _2, "edu": _2, "gov": _2, "mil": _2, "net": _2, "org": _2, "brendly": _19, "rs": _3 }], "bb": [1, { "biz": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "info": _2, "net": _2, "org": _2, "store": _2, "tv": _2 }], "bd": [1, { "ac": _2, "ai": _2, "co": _2, "com": _2, "edu": _2, "gov": _2, "id": _2, "info": _2, "it": _2, "mil": _2, "net": _2, "org": _2, "sch": _2, "tv": _2 }], "be": [1, { "ac": _2, "cloudns": _3, "webhosting": _3, "interhostsolutions": [0, { "cloud": _3 }], "kuleuven": [0, { "ezproxy": _3 }], "123website": _3, "myspreadshop": _3, "transurl": _6 }], "bf": _10, "bg": [1, { "0": _2, "1": _2, "2": _2, "3": _2, "4": _2, "5": _2, "6": _2, "7": _2, "8": _2, "9": _2, "a": _2, "b": _2, "c": _2, "d": _2, "e": _2, "f": _2, "g": _2, "h": _2, "i": _2, "j": _2, "k": _2, "l": _2, "m": _2, "n": _2, "o": _2, "p": _2, "q": _2, "r": _2, "s": _2, "t": _2, "u": _2, "v": _2, "w": _2, "x": _2, "y": _2, "z": _2, "barsy": _3 }], "bh": _4, "bi": [1, { "co": _2, "com": _2, "edu": _2, "or": _2, "org": _2 }], "biz": [1, { "activetrail": _3, "cloud-ip": _3, "cloudns": _3, "jozi": _3, "dyndns": _3, "for-better": _3, "for-more": _3, "for-some": _3, "for-the": _3, "selfip": _3, "webhop": _3, "orx": _3, "mmafan": _3, "myftp": _3, "no-ip": _3, "dscloud": _3 }], "bj": [1, { "africa": _2, "agro": _2, "architectes": _2, "assur": _2, "avocats": _2, "co": _2, "com": _2, "eco": _2, "econo": _2, "edu": _2, "info": _2, "loisirs": _2, "money": _2, "net": _2, "org": _2, "ote": _2, Line truncated
return rules;
})();
//# sourceMappingURL=trie.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"trie.js","sourceRoot":"","sources":["../../../../src/data/trie.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,UAAU,GAAU,CAAC;IAChC,MAAM,EAAE,GAAU,CAAC,CAAC,EAAC,EAAE,CAAC,EAAC,EAAE,GAAU,CAAC,CAAC,EAAC,EAAC,MAAM,EAAC,EAAE,EAAC,CAAC,CAAC;IACvD,MAAM,UAAU,GAAU,CAAC,CAAC,EAAC,EAAC,IAAI,EAAC,CAAC,CAAC,EAAC,EAAC,KAAK,EAAC,EAAE,EAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,EAAC,EAAC,UAAU,EAAC,EAAE,EAAC,YAAY,EAAC,EAAE,EAAC,MAAM,EAAC,EAAE,EAAC,QAAQ,EAAC,EAAE,EAAC,SAAS,EAAC,EAAE,EAAC,QAAQ,EAAC,EAAE,EAAC,UAAU,EAAC,EAAE,EAAC,CAAC,EAAC,CAAC,CAAC;IACxJ,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC,EAAE,CAAC;AAEL,MAAM,CAAC,MAAM,KAAK,GAAU,CAAC;IAC3B,MAAM,EAAE,GAAU,CAAC,CAAC,EAAC,EAAE,CAAC,EAAC,EAAE,GAAU,CAAC,CAAC,EAAC,EAAE,CAAC,EAAC,EAAE,GAAU,CAAC,CAAC,EAAC,EAAC,KAAK,EAAC,EAAE,EAAC,KAAK,EAAC,EAAE,EAAC,KAAK,EAAC,EAAE,EAAC,KAAK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AAC,EAAE,EAAC,WAAW,EAAC,GAAG,EAAC,IAAI,EAAC,EAAE,EAAC,gBAAgB,EAAC,EAAE,EAAC,qBAAqB,EAAC,EAAE,EAACLine truncated
+64
View File
@@ -0,0 +1,64 @@
import { fastPathLookup, } from 'tldts-core';
import { exceptions, rules } from './data/trie';
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(parts, trie, index, allowedMask) {
let result = null;
let node = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === 1 /* RULE_TYPE.ICANN */,
isPrivate: node[0] === 2 /* RULE_TYPE.PRIVATE */,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index])
? succ[parts[index]]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
export default function suffixLookup(hostname, options, out) {
var _a;
if (fastPathLookup(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask = (options.allowPrivateDomains ? 2 /* RULE_TYPE.PRIVATE */ : 0) |
(options.allowIcannDomains ? 1 /* RULE_TYPE.ICANN */ : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(hostnameParts, exceptions, hostnameParts.length - 1, allowedMask);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(hostnameParts, rules, hostnameParts.length - 1, allowedMask);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = (_a = hostnameParts[hostnameParts.length - 1]) !== null && _a !== void 0 ? _a : null;
}
//# sourceMappingURL=suffix-trie.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"suffix-trie.js","sourceRoot":"","sources":["../../../src/suffix-trie.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAS,KAAK,EAAE,MAAM,aAAa,CAAC;AAcvD;;GAEG;AACH,SAAS,YAAY,CACnB,KAAe,EACf,IAAW,EACX,KAAa,EACb,WAAmB;IAEnB,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,IAAI,IAAI,GAAsB,IAAI,CAAC;IACnC,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,mBAAmB;QACnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,GAAG;gBACP,KAAK,EAAE,KAAK,GAAG,CAAC;gBAChB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,4BAAoB;gBACpC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8BAAsB;aACzC,CAAC;QACJ,CAAC;QAED,8BAA8B;QAC9B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM;QACR,CAAC;QAED,MAAM,IAAI,GAA+B,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAE,CAAC;YAC9D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,Y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;IAED,oBAAoB;IACpB,uEAAuE;IACvE,8DAA8D;IAC9D,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACpB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;IACtB,GAAG,CAAC,YAAY,GAAG,MAAA,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,mCAAI,IAAI,CAAC;AACrE,CAAC"}
+1
View File
@@ -0,0 +1 @@
{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../node_modules/typescript/lib/lib.scripthost.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../../../node_modules/typescript/lib/lib.esnext.float16.d.ts","../../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/typescript/lib/lib.es2017.full.d.ts","../../../tldts-core/dist/types/src/lookup/interface.d.ts","../../../tldts-core/dist/types/src/options.d.ts","../../../tldts-core/dist/types/src/factory.d.ts","../../../tldts-core/dist/types/src/lookup/fast-path.d.ts","../../../tldts-core/dist/types/index.d.ts","../../src/data/trie.ts","../../src/suffix-trie.ts","../../index.ts","../../../../node_modules/@types/chai/index.d.ts","../../../../node_modules/@types/command-line-args/index.d.ts","../../../../node_modules/@types/command-line-usage/index.d.ts","../../../../node_modules/@types/estree/index.d.ts","../../../../node_modules/@types/minimatch/index.d.ts","../../../../node_modules/@types/minimist/index.d.ts","../../../../node_modules/@types/mocha/index.d.ts","../../../../node_modules/@types/node/compatibility/iterators.d.ts","../../../../node_modules/@types/node/globals.typedarray.d.ts","../../../../node_modules/@types/node/buffer.buffer.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/web-globals/abortcontroller.d.ts","../../../../node_modules/@types/node/web-globals/domexception.d.ts","../../../../node_modules/@types/node/web-globals/events.d.ts","../../../../node_modules/buffer/index.d.ts","../../../../node_modules/undici-types/utility.d.ts","../../../../node_modules/undici-types/header.d.ts","../../../../node_modules/undici-types/readable.d.ts","../../../../node_modules/undici-types/fetch.d.ts","../../../../node_modules/undici-types/formdata.d.ts","../../../../node_modules/undici-types/connector.d.ts","../../../../node_modules/undici-types/client-stats.d.ts","../../../.Line truncated
+2
View File
@@ -0,0 +1,2 @@
"use strict";function a(a,e){let o=0,i=a.length,s=!1;if(!e){if(a.startsWith("data:"))return null;for(;o<a.length&&a.charCodeAt(o)<=32;)o+=1;for(;i>o+1&&a.charCodeAt(i-1)<=32;)i-=1;if(47===a.charCodeAt(o)&&47===a.charCodeAt(o+1))o+=2;else{const e=a.indexOf(":/",o);if(-1!==e){const i=e-o,s=a.charCodeAt(o),n=a.charCodeAt(o+1),t=a.charCodeAt(o+2),r=a.charCodeAt(o+3),u=a.charCodeAt(o+4);if(5===i&&104===s&&116===n&&116===t&&112===r&&115===u);else if(4===i&&104===s&&116===n&&116===t&&112===r);else if(3===i&&119===s&&115===n&&115===t);else if(2===i&&119===s&&115===n);else for(let i=o;i<e;i+=1){const e=32|a.charCodeAt(i);if(!(e>=97&&e<=122||e>=48&&e<=57||46===e||45===e||43===e))return null}for(o=e+2;47===a.charCodeAt(o);)o+=1}}let e=-1,n=-1,t=-1;for(let r=o;r<i;r+=1){const o=a.charCodeAt(r);if(35===o||47===o||63===o){i=r;break}64===o?e=r:93===o?n=r:58===o?t=r:o>=65&&o<=90&&(s=!0)}if(-1!==e&&e>o&&e<i&&(o=e+1),91===a.charCodeAt(o))return-1!==n?a.slice(o+1,n).toLowerCase():null;-1!==t&&t>o&&t<i&&(i=t)}for(;i>o+1&&46===a.charCodeAt(i-1);)i-=1;const n=0!==o||i!==a.length?a.slice(o,i):a;return s?n.toLowerCase():n}function e(a){return a>=97&&a<=122||a>=48&&a<=57||a>127}function o(a){if(a.length>255)return!1;if(0===a.length)return!1;if(!e(a.charCodeAt(0))&&46!==a.charCodeAt(0)&&95!==a.charCodeAt(0))return!1;let o=-1,i=-1;const s=a.length;for(let n=0;n<s;n+=1){const s=a.charCodeAt(n);if(46===s){if(n-o>64||46===i||45===i||95===i)return!1;o=n}else if(!e(s)&&45!==s&&95!==s)return!1;i=s}return s-o-1<=63&&45!==i}const i=function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}({});function s(e,s,n,t,r){const u=function(a){return void 0===a?i:function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}(a)}(t);return"string"!=typeof e?r:(u.extractHostname?u.mixedInputs?r.hostname=a(e,o(e)):r.hostname=a(e,!1):r.hostname=e,u.detectIp&&null!==r.hostname&&(r.isIp=function(a){if(a.length<3)return!1;let e=a.startsWith("[")?1:0,o=a.length;if("]"===a[o-1]&&(o-=1),o-e>39)return!1;let i=!1;for(;e<o;e+=1){const o=a.charCodeAt(e);if(58===o)i=!0;else if(!(o>=48&&o<=57||o>=97&&o<=102||o>=65&&o<=90))return!1}return i}(l=r.hostname)||function(a){if(a.length<7)return!1;if(a.length>15)return!1;let e=0;for(let o=0;o<a.length;o+=1){const i=a.charCodeAt(o);if(46===i)e+=1;else if(i<48||i>57)return!1}return 3===e&&46!==a.charCodeAt(0)&&46!==a.charCodeAt(a.length-1)}(l),r.isIp)?r:u.validateHostname&&u.extractHostname&&null!==r.hostname&&!o(r.hostname)?(r.hostname=null,r):0===s||null===r.hostname?r:(n(r.hostname,u,r),2===s||null===r.publicSuffix?r:(r.domain=function(a,e,o){if(null!==o.validHosts){const a=o.validHosts;for(const o of a)if(function(a,e){return!!a.endsWith(e)&&(a.length===e.length||"."===a[a.length-e.length-1])}(e,o))return o}let i=0;if(e.startsWith("."))for(;i<e.length&&"."===e[i];)i+=1;return a.length===e.length-i?null:function(a,e){const o=a.length-e.length-2,i=a.lastIndexOf(".",o);return-1===i?a:a.slice(i+1)}(e,a)}(r.publicSuffix,r.hostname,u),3===s||null===r.domain?r:(r.subdomain=function(a,e){return e.length===a.length?"":a.slice(0,-e.length-1)}(r.hostname,r.domain),4===s||(r.domainWithoutSuffix=(m=r.domain,c=r.publicSuffix,m.slice(0,-c.length-1))),r))));var l,m,c}const n=function(){const a=[1,{}],e=[0,{city:a}];return[0,{ck:[0,{www:a}],jp:[0,{kawasaki:e,kitakyushu:e,kobe:e,nagoya:e,sapporo:e,sendai:e,yokohama:e}]}]}(),t=function(){const a=[1,{}],e=[2,{}],o=[1,{com:a,edu:a,gov:a,net:a,org:a}],i=[1,{com:a,edu:a,gov:a,mil:a,net:a,org:a}],s=[0,{"*":e}],n=[2,{s:s}],t=[0,{relay:e}],r=[2,{id:e}],u=[1,{gov:a}],l=[0,{airflow:s,"lambda-url":e,"transfer-webapp":e}],m=[0,{airflow:s,"transfer-webapp":e}],c=[0,{"transfer-webapp":e,"transfer-webapp-fips":e}],d=[0,{notebook:e,studio:e}],g=[0,{labeling:e,notebook:e,studio:e}],h=[0,{notebook:e}],k=[0,{labeling:e,notebook:e,"notebook-fips":e,studio:e}],p=[0,{notebook:e,"notebook-fips":e,studio:e,"studio-fips":e}],b=[0,{shop:e}],y=[0,{"*":a}],f=[1,{co:e}],v=[0,{objects:e}],w=[2,{nodes:e}],x=[0,{my:e}],z=[0,{s3:e,"s3-accesspoint":e,"s3-website":e}],j=[0,{s3:e,"s3-accesspoint":e}],q=[0,{direct:e}],I=[0,{"webview-assets":e}],S=[0,{vfs:e,"webview-assets":e}],C=[0,{"execute-api":e,"emrappui-prod":e,"emrnotebooks-prod":e,"emrstudio-prod":e,dualstack:z,s3:e,"s3-accesspoint":e,"s3-object-lambda":e,"s3-website":e,"aws-cloud9":I,cloud9:S}],P=[0,{"execute-api":e,"emrappui-prod":e,"emrnotebooks-prod":e,"emrstudio-prod":e,dualstack:j,s3:e,"s3-accesspoint":e,"s3-object-lambda":e,"s3-website":e,"aws-cloud9":I,cloud9:S}],A=[0,{"execute-api":e,"emrappui-prod":e,"emrnotebooks-prod":e,"emrstudioLine truncated
//# sourceMappingURL=index.cjs.min.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.cjs.min.js","sources":["../../tldts-core/src/extract-hostname.ts","../../tldts-core/src/is-valid.ts","../../tldts-core/src/options.ts","../../tldts-core/src/factory.ts","../../tldts-core/src/is-ip.ts","../../tldts-core/src/domain.ts","../../tldts-core/src/subdomain.ts","../../tldts-core/src/domain-without-suffix.ts","../src/data/trie.ts","../src/suffix-trie.ts","../../tldts-core/src/lookup/fast-path.ts","../index.ts"],"sourcesContent":["/**\n * @param url - URL we want to extract a hostname from.\n * @param urlIsValidHostname - hint from caller; true if `url` is already a valid hostname.\n */\nexport default function extractHostname(\n url: string,\n urlIsValidHostname: boolean,\n): string | null {\n let start = 0;\n let end: number = url.length;\n let hasUpper = false;\n\n // If url is not already a valid hostname, then try to extract hostname.\n if (!urlIsValidHostname) {\n // Special handling of data URLs\n if (url.startsWith('data:')) {\n return null;\n }\n\n // Trim leading spaces\n while (start < url.length && url.charCodeAt(start) <= 32) {\n start += 1;\n }\n\n // Trim trailing spaces\n while (end > start + 1 && url.charCodeAt(end - 1) <= 32) {\n end -= 1;\n }\n\n // Skip scheme.\n if (\n url.charCodeAt(start) === 47 /* '/' */ &&\n url.charCodeAt(start + 1) === 47 /* '/' */\n ) {\n start += 2;\n } else {\n const indexOfProtocol = url.indexOf(':/', start);\n if (indexOfProtocol !== -1) {\n // Implement fast-path for common protocols. We expect most protocols\n // should be one of these 4 and thus we will not need to perform the\n // more expansive validity check most of the time.\n const protocolSize = indexOfProtocol - start;\n const c0 = url.charCodeAt(start);\n const c1 = url.charCodeAt(start + 1);\n const c2 = url.charCodeAt(start + 2);\n const c3 = url.charCodeAt(start + 3);\n const c4 = url.charCodeAt(start + 4);\n\n if (\n protocolSize === 5 &&\n c0 === 104 /* 'h' */ &&\n c1 === 116 /* 't' */ &&\n c2 === 116 /* 't' */ &&\n c3 === 112 /* 'p' */ &&\n c4 === 115 /* 's' */\n ) {\n // https\n } else if (\n protocolSize === 4 &&\n c0 === 104 /* 'h' */ &&\n c1 === 116 /* 't' */ &&\n c2 === 116 /* 't' */ &&\n c3 === 112 /* 'p' */\n ) {\n // http\n } else if (\n protocolSize === 3 &&\n c0 === 119 /* 'w' */ &&\n c1 === 115 /* 's' */ &&\n c2 === 115 /* 's' */\n ) {\n // wss\n } else if (\n protocolSize === 2 &&\n c0 === 119 /* 'w' */ &&\n c1 === 115 /* 's' */\n ) {\n // ws\n } else {\n // Check that scheme is valid\n for (let i = start; i < indexOfProtocol; i += 1) {\n const lowerCaseCode = url.charCodeAt(i) | 32;\n if (\n !(\n (\n (lowerCaseCode >= 97 && lowerCaseCode <= 122) || // [a, z]\n (lowerCaseCode >= 48 && lowerCaseCode <= 57) || // [0, 9]\n lowerCaseCode === 46 || // '.'\n lowerCaseCode === 45 || // '-'\n lowerCaseCode === 43\n ) // '+'\n )\n ) {\n return null;\n }\n }\n }\n\n // Skip 0, 1 or more '/' after ':/'\n start = indexOfProtocol + 2;\n while (url.charCodeAt(start) === 47 /* '/' */) {\n start += 1;\n }\n }\n }\n\n // Detect first occurrence of '/', '?' or '#'. We also keep track of the\n // last occurrence of '@', ']' or ':' to speed-up subsequent parsing of\n // (respectively), identifier, ipv6 or port.\n let indexOfIdentifier = -1;\n let indexOfClosingBracket = -1;\n let indexOfPort = -1;\n for (let i = start; i < end; i += 1) {\n const code: number = url.charCodeAt(i);\n if (\n code === 35 || // '#'\n code === 47 || // '/'\n code === 63 // '?'\n ) {\n end = i;\n break;\n } else if (code === 64) {\n // '@'\n indexOfIdentifier = i;\n } else if (code === 93) {\n // ']'\n indexOfClosingBracket = i;\n } else if (code === 58) {\n // ':'\n indexOfPort = i;\n } else if (code >= 65 && code <= 90) {\n hasUpper = true;\n }\n }\n\n // Detect identifier: '@'\n if (\n indexOfIdentifier !== -1 &&\n indexOfIdentifier > start &&\n indexOfIdentifier < end\n ) {\n start = indexOfIdentifier + 1;\n }\n\n // Handle ipv6 addresses\n if (url.charCodeAt(start) === 91 /* '[' */) {\n if (indexOfClosingBracket !== -1) {\n return url.slice(start + 1, indexOfClosingBracket).toLowerCase();\n }\n return null;\nLine truncated
+2
View File
@@ -0,0 +1,2 @@
function a(a,e){let o=0,i=a.length,s=!1;if(!e){if(a.startsWith("data:"))return null;for(;o<a.length&&a.charCodeAt(o)<=32;)o+=1;for(;i>o+1&&a.charCodeAt(i-1)<=32;)i-=1;if(47===a.charCodeAt(o)&&47===a.charCodeAt(o+1))o+=2;else{const e=a.indexOf(":/",o);if(-1!==e){const i=e-o,s=a.charCodeAt(o),n=a.charCodeAt(o+1),t=a.charCodeAt(o+2),r=a.charCodeAt(o+3),u=a.charCodeAt(o+4);if(5===i&&104===s&&116===n&&116===t&&112===r&&115===u);else if(4===i&&104===s&&116===n&&116===t&&112===r);else if(3===i&&119===s&&115===n&&115===t);else if(2===i&&119===s&&115===n);else for(let i=o;i<e;i+=1){const e=32|a.charCodeAt(i);if(!(e>=97&&e<=122||e>=48&&e<=57||46===e||45===e||43===e))return null}for(o=e+2;47===a.charCodeAt(o);)o+=1}}let e=-1,n=-1,t=-1;for(let r=o;r<i;r+=1){const o=a.charCodeAt(r);if(35===o||47===o||63===o){i=r;break}64===o?e=r:93===o?n=r:58===o?t=r:o>=65&&o<=90&&(s=!0)}if(-1!==e&&e>o&&e<i&&(o=e+1),91===a.charCodeAt(o))return-1!==n?a.slice(o+1,n).toLowerCase():null;-1!==t&&t>o&&t<i&&(i=t)}for(;i>o+1&&46===a.charCodeAt(i-1);)i-=1;const n=0!==o||i!==a.length?a.slice(o,i):a;return s?n.toLowerCase():n}function e(a){return a>=97&&a<=122||a>=48&&a<=57||a>127}function o(a){if(a.length>255)return!1;if(0===a.length)return!1;if(!e(a.charCodeAt(0))&&46!==a.charCodeAt(0)&&95!==a.charCodeAt(0))return!1;let o=-1,i=-1;const s=a.length;for(let n=0;n<s;n+=1){const s=a.charCodeAt(n);if(46===s){if(n-o>64||46===i||45===i||95===i)return!1;o=n}else if(!e(s)&&45!==s&&95!==s)return!1;i=s}return s-o-1<=63&&45!==i}const i=function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}({});function s(e,s,n,t,r){const u=function(a){return void 0===a?i:function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}(a)}(t);return"string"!=typeof e?r:(u.extractHostname?u.mixedInputs?r.hostname=a(e,o(e)):r.hostname=a(e,!1):r.hostname=e,u.detectIp&&null!==r.hostname&&(r.isIp=function(a){if(a.length<3)return!1;let e=a.startsWith("[")?1:0,o=a.length;if("]"===a[o-1]&&(o-=1),o-e>39)return!1;let i=!1;for(;e<o;e+=1){const o=a.charCodeAt(e);if(58===o)i=!0;else if(!(o>=48&&o<=57||o>=97&&o<=102||o>=65&&o<=90))return!1}return i}(l=r.hostname)||function(a){if(a.length<7)return!1;if(a.length>15)return!1;let e=0;for(let o=0;o<a.length;o+=1){const i=a.charCodeAt(o);if(46===i)e+=1;else if(i<48||i>57)return!1}return 3===e&&46!==a.charCodeAt(0)&&46!==a.charCodeAt(a.length-1)}(l),r.isIp)?r:u.validateHostname&&u.extractHostname&&null!==r.hostname&&!o(r.hostname)?(r.hostname=null,r):0===s||null===r.hostname?r:(n(r.hostname,u,r),2===s||null===r.publicSuffix?r:(r.domain=function(a,e,o){if(null!==o.validHosts){const a=o.validHosts;for(const o of a)if(function(a,e){return!!a.endsWith(e)&&(a.length===e.length||"."===a[a.length-e.length-1])}(e,o))return o}let i=0;if(e.startsWith("."))for(;i<e.length&&"."===e[i];)i+=1;return a.length===e.length-i?null:function(a,e){const o=a.length-e.length-2,i=a.lastIndexOf(".",o);return-1===i?a:a.slice(i+1)}(e,a)}(r.publicSuffix,r.hostname,u),3===s||null===r.domain?r:(r.subdomain=function(a,e){return e.length===a.length?"":a.slice(0,-e.length-1)}(r.hostname,r.domain),4===s||(r.domainWithoutSuffix=(m=r.domain,c=r.publicSuffix,m.slice(0,-c.length-1))),r))));var l,m,c}const n=function(){const a=[1,{}],e=[0,{city:a}];return[0,{ck:[0,{www:a}],jp:[0,{kawasaki:e,kitakyushu:e,kobe:e,nagoya:e,sapporo:e,sendai:e,yokohama:e}]}]}(),t=function(){const a=[1,{}],e=[2,{}],o=[1,{com:a,edu:a,gov:a,net:a,org:a}],i=[1,{com:a,edu:a,gov:a,mil:a,net:a,org:a}],s=[0,{"*":e}],n=[2,{s:s}],t=[0,{relay:e}],r=[2,{id:e}],u=[1,{gov:a}],l=[0,{airflow:s,"lambda-url":e,"transfer-webapp":e}],m=[0,{airflow:s,"transfer-webapp":e}],c=[0,{"transfer-webapp":e,"transfer-webapp-fips":e}],d=[0,{notebook:e,studio:e}],g=[0,{labeling:e,notebook:e,studio:e}],h=[0,{notebook:e}],k=[0,{labeling:e,notebook:e,"notebook-fips":e,studio:e}],p=[0,{notebook:e,"notebook-fips":e,studio:e,"studio-fips":e}],b=[0,{shop:e}],y=[0,{"*":a}],f=[1,{co:e}],v=[0,{objects:e}],w=[2,{nodes:e}],x=[0,{my:e}],z=[0,{s3:e,"s3-accesspoint":e,"s3-website":e}],j=[0,{s3:e,"s3-accesspoint":e}],q=[0,{direct:e}],I=[0,{"webview-assets":e}],S=[0,{vfs:e,"webview-assets":e}],C=[0,{"execute-api":e,"emrappui-prod":e,"emrnotebooks-prod":e,"emrstudio-prod":e,dualstack:z,s3:e,"s3-accesspoint":e,"s3-object-lambda":e,"s3-website":e,"aws-cloud9":I,cloud9:S}],A=[0,{"execute-api":e,"emrappui-prod":e,"emrnotebooks-prod":e,"emrstudio-prod":e,dualstack:j,s3:e,"s3-accesspoint":e,"s3-object-lambda":e,"s3-website":e,"aws-cloud9":I,cloud9:S}],P=[0,{"execute-api":e,"emrappui-prod":e,"emrnotebooks-prod":e,"emrstudio-prod":e,dualLine truncated
//# sourceMappingURL=index.esm.min.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.esm.min.js","sources":["../../tldts-core/src/extract-hostname.ts","../../tldts-core/src/is-valid.ts","../../tldts-core/src/options.ts","../../tldts-core/src/factory.ts","../../tldts-core/src/is-ip.ts","../../tldts-core/src/domain.ts","../../tldts-core/src/subdomain.ts","../../tldts-core/src/domain-without-suffix.ts","../src/data/trie.ts","../src/suffix-trie.ts","../../tldts-core/src/lookup/fast-path.ts","../index.ts"],"sourcesContent":["/**\n * @param url - URL we want to extract a hostname from.\n * @param urlIsValidHostname - hint from caller; true if `url` is already a valid hostname.\n */\nexport default function extractHostname(\n url: string,\n urlIsValidHostname: boolean,\n): string | null {\n let start = 0;\n let end: number = url.length;\n let hasUpper = false;\n\n // If url is not already a valid hostname, then try to extract hostname.\n if (!urlIsValidHostname) {\n // Special handling of data URLs\n if (url.startsWith('data:')) {\n return null;\n }\n\n // Trim leading spaces\n while (start < url.length && url.charCodeAt(start) <= 32) {\n start += 1;\n }\n\n // Trim trailing spaces\n while (end > start + 1 && url.charCodeAt(end - 1) <= 32) {\n end -= 1;\n }\n\n // Skip scheme.\n if (\n url.charCodeAt(start) === 47 /* '/' */ &&\n url.charCodeAt(start + 1) === 47 /* '/' */\n ) {\n start += 2;\n } else {\n const indexOfProtocol = url.indexOf(':/', start);\n if (indexOfProtocol !== -1) {\n // Implement fast-path for common protocols. We expect most protocols\n // should be one of these 4 and thus we will not need to perform the\n // more expansive validity check most of the time.\n const protocolSize = indexOfProtocol - start;\n const c0 = url.charCodeAt(start);\n const c1 = url.charCodeAt(start + 1);\n const c2 = url.charCodeAt(start + 2);\n const c3 = url.charCodeAt(start + 3);\n const c4 = url.charCodeAt(start + 4);\n\n if (\n protocolSize === 5 &&\n c0 === 104 /* 'h' */ &&\n c1 === 116 /* 't' */ &&\n c2 === 116 /* 't' */ &&\n c3 === 112 /* 'p' */ &&\n c4 === 115 /* 's' */\n ) {\n // https\n } else if (\n protocolSize === 4 &&\n c0 === 104 /* 'h' */ &&\n c1 === 116 /* 't' */ &&\n c2 === 116 /* 't' */ &&\n c3 === 112 /* 'p' */\n ) {\n // http\n } else if (\n protocolSize === 3 &&\n c0 === 119 /* 'w' */ &&\n c1 === 115 /* 's' */ &&\n c2 === 115 /* 's' */\n ) {\n // wss\n } else if (\n protocolSize === 2 &&\n c0 === 119 /* 'w' */ &&\n c1 === 115 /* 's' */\n ) {\n // ws\n } else {\n // Check that scheme is valid\n for (let i = start; i < indexOfProtocol; i += 1) {\n const lowerCaseCode = url.charCodeAt(i) | 32;\n if (\n !(\n (\n (lowerCaseCode >= 97 && lowerCaseCode <= 122) || // [a, z]\n (lowerCaseCode >= 48 && lowerCaseCode <= 57) || // [0, 9]\n lowerCaseCode === 46 || // '.'\n lowerCaseCode === 45 || // '-'\n lowerCaseCode === 43\n ) // '+'\n )\n ) {\n return null;\n }\n }\n }\n\n // Skip 0, 1 or more '/' after ':/'\n start = indexOfProtocol + 2;\n while (url.charCodeAt(start) === 47 /* '/' */) {\n start += 1;\n }\n }\n }\n\n // Detect first occurrence of '/', '?' or '#'. We also keep track of the\n // last occurrence of '@', ']' or ':' to speed-up subsequent parsing of\n // (respectively), identifier, ipv6 or port.\n let indexOfIdentifier = -1;\n let indexOfClosingBracket = -1;\n let indexOfPort = -1;\n for (let i = start; i < end; i += 1) {\n const code: number = url.charCodeAt(i);\n if (\n code === 35 || // '#'\n code === 47 || // '/'\n code === 63 // '?'\n ) {\n end = i;\n break;\n } else if (code === 64) {\n // '@'\n indexOfIdentifier = i;\n } else if (code === 93) {\n // ']'\n indexOfClosingBracket = i;\n } else if (code === 58) {\n // ':'\n indexOfPort = i;\n } else if (code >= 65 && code <= 90) {\n hasUpper = true;\n }\n }\n\n // Detect identifier: '@'\n if (\n indexOfIdentifier !== -1 &&\n indexOfIdentifier > start &&\n indexOfIdentifier < end\n ) {\n start = indexOfIdentifier + 1;\n }\n\n // Handle ipv6 addresses\n if (url.charCodeAt(start) === 91 /* '[' */) {\n if (indexOfClosingBracket !== -1) {\n return url.slice(start + 1, indexOfClosingBracket).toLowerCase();\n }\n return null;\nLine truncated
+2
View File
@@ -0,0 +1,2 @@
!function(a,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((a="undefined"!=typeof globalThis?globalThis:a||self).tldts={})}(this,(function(a){"use strict";function e(a,e){let o=0,i=a.length,s=!1;if(!e){if(a.startsWith("data:"))return null;for(;o<a.length&&a.charCodeAt(o)<=32;)o+=1;for(;i>o+1&&a.charCodeAt(i-1)<=32;)i-=1;if(47===a.charCodeAt(o)&&47===a.charCodeAt(o+1))o+=2;else{const e=a.indexOf(":/",o);if(-1!==e){const i=e-o,s=a.charCodeAt(o),n=a.charCodeAt(o+1),t=a.charCodeAt(o+2),r=a.charCodeAt(o+3),u=a.charCodeAt(o+4);if(5===i&&104===s&&116===n&&116===t&&112===r&&115===u);else if(4===i&&104===s&&116===n&&116===t&&112===r);else if(3===i&&119===s&&115===n&&115===t);else if(2===i&&119===s&&115===n);else for(let i=o;i<e;i+=1){const e=32|a.charCodeAt(i);if(!(e>=97&&e<=122||e>=48&&e<=57||46===e||45===e||43===e))return null}for(o=e+2;47===a.charCodeAt(o);)o+=1}}let e=-1,n=-1,t=-1;for(let r=o;r<i;r+=1){const o=a.charCodeAt(r);if(35===o||47===o||63===o){i=r;break}64===o?e=r:93===o?n=r:58===o?t=r:o>=65&&o<=90&&(s=!0)}if(-1!==e&&e>o&&e<i&&(o=e+1),91===a.charCodeAt(o))return-1!==n?a.slice(o+1,n).toLowerCase():null;-1!==t&&t>o&&t<i&&(i=t)}for(;i>o+1&&46===a.charCodeAt(i-1);)i-=1;const n=0!==o||i!==a.length?a.slice(o,i):a;return s?n.toLowerCase():n}function o(a){return a>=97&&a<=122||a>=48&&a<=57||a>127}function i(a){if(a.length>255)return!1;if(0===a.length)return!1;if(!o(a.charCodeAt(0))&&46!==a.charCodeAt(0)&&95!==a.charCodeAt(0))return!1;let e=-1,i=-1;const s=a.length;for(let n=0;n<s;n+=1){const s=a.charCodeAt(n);if(46===s){if(n-e>64||46===i||45===i||95===i)return!1;e=n}else if(!o(s)&&45!==s&&95!==s)return!1;i=s}return s-e-1<=63&&45!==i}const s=function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}({});function n(a,o,n,t,r){const u=function(a){return void 0===a?s:function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,extractHostname:i=!0,mixedInputs:s=!0,validHosts:n=null,validateHostname:t=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,extractHostname:i,mixedInputs:s,validHosts:n,validateHostname:t}}(a)}(t);return"string"!=typeof a?r:(u.extractHostname?u.mixedInputs?r.hostname=e(a,i(a)):r.hostname=e(a,!1):r.hostname=a,u.detectIp&&null!==r.hostname&&(r.isIp=function(a){if(a.length<3)return!1;let e=a.startsWith("[")?1:0,o=a.length;if("]"===a[o-1]&&(o-=1),o-e>39)return!1;let i=!1;for(;e<o;e+=1){const o=a.charCodeAt(e);if(58===o)i=!0;else if(!(o>=48&&o<=57||o>=97&&o<=102||o>=65&&o<=90))return!1}return i}(l=r.hostname)||function(a){if(a.length<7)return!1;if(a.length>15)return!1;let e=0;for(let o=0;o<a.length;o+=1){const i=a.charCodeAt(o);if(46===i)e+=1;else if(i<48||i>57)return!1}return 3===e&&46!==a.charCodeAt(0)&&46!==a.charCodeAt(a.length-1)}(l),r.isIp)?r:u.validateHostname&&u.extractHostname&&null!==r.hostname&&!i(r.hostname)?(r.hostname=null,r):0===o||null===r.hostname?r:(n(r.hostname,u,r),2===o||null===r.publicSuffix?r:(r.domain=function(a,e,o){if(null!==o.validHosts){const a=o.validHosts;for(const o of a)if(function(a,e){return!!a.endsWith(e)&&(a.length===e.length||"."===a[a.length-e.length-1])}(e,o))return o}let i=0;if(e.startsWith("."))for(;i<e.length&&"."===e[i];)i+=1;return a.length===e.length-i?null:function(a,e){const o=a.length-e.length-2,i=a.lastIndexOf(".",o);return-1===i?a:a.slice(i+1)}(e,a)}(r.publicSuffix,r.hostname,u),3===o||null===r.domain?r:(r.subdomain=function(a,e){return e.length===a.length?"":a.slice(0,-e.length-1)}(r.hostname,r.domain),4===o||(r.domainWithoutSuffix=(m=r.domain,c=r.publicSuffix,m.slice(0,-c.length-1))),r))));var l,m,c}const t=function(){const a=[1,{}],e=[0,{city:a}];return[0,{ck:[0,{www:a}],jp:[0,{kawasaki:e,kitakyushu:e,kobe:e,nagoya:e,sapporo:e,sendai:e,yokohama:e}]}]}(),r=function(){const a=[1,{}],e=[2,{}],o=[1,{com:a,edu:a,gov:a,net:a,org:a}],i=[1,{com:a,edu:a,gov:a,mil:a,net:a,org:a}],s=[0,{"*":e}],n=[2,{s:s}],t=[0,{relay:e}],r=[2,{id:e}],u=[1,{gov:a}],l=[0,{airflow:s,"lambda-url":e,"transfer-webapp":e}],m=[0,{airflow:s,"transfer-webapp":e}],c=[0,{"transfer-webapp":e,"transfer-webapp-fips":e}],d=[0,{notebook:e,studio:e}],g=[0,{labeling:e,notebook:e,studio:e}],h=[0,{notebook:e}],k=[0,{labeling:e,notebook:e,"notebook-fips":e,studio:e}],p=[0,{notebook:e,"notebook-fips":e,studio:e,"studio-fips":e}],b=[0,{shop:e}],y=[0,{"*":a}],f=[1,{co:e}],v=[0,{objects:e}],w=[2,{nodes:e}],x=[0,{my:e}],z=[0,{s3:e,"s3-accesspoint":e,"s3-website":e}],j=[0,{s3:e,"s3-accesspoint":e}],q=[0,{direct:e}],I=[0,{"webview-assets":e}],S=[0,{vfs:e,"webview-assets":e}],C=[0,{"execute-api":e,"emrappui-prod":e,"emrnotebooks-prod":e,"emrstudio-prod":e,dualstack:z,s3:e,"s3-accesspoint":e,"s3-object-lambda":e,"s3-website":e,"aws-cloud9":I,cloud9:S}],P=[0,{"execute-api":e,"emraLine truncated
//# sourceMappingURL=index.umd.min.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.umd.min.js","sources":["../../tldts-core/src/extract-hostname.ts","../../tldts-core/src/is-valid.ts","../../tldts-core/src/options.ts","../../tldts-core/src/factory.ts","../../tldts-core/src/is-ip.ts","../../tldts-core/src/domain.ts","../../tldts-core/src/subdomain.ts","../../tldts-core/src/domain-without-suffix.ts","../src/data/trie.ts","../src/suffix-trie.ts","../../tldts-core/src/lookup/fast-path.ts","../index.ts"],"sourcesContent":["/**\n * @param url - URL we want to extract a hostname from.\n * @param urlIsValidHostname - hint from caller; true if `url` is already a valid hostname.\n */\nexport default function extractHostname(\n url: string,\n urlIsValidHostname: boolean,\n): string | null {\n let start = 0;\n let end: number = url.length;\n let hasUpper = false;\n\n // If url is not already a valid hostname, then try to extract hostname.\n if (!urlIsValidHostname) {\n // Special handling of data URLs\n if (url.startsWith('data:')) {\n return null;\n }\n\n // Trim leading spaces\n while (start < url.length && url.charCodeAt(start) <= 32) {\n start += 1;\n }\n\n // Trim trailing spaces\n while (end > start + 1 && url.charCodeAt(end - 1) <= 32) {\n end -= 1;\n }\n\n // Skip scheme.\n if (\n url.charCodeAt(start) === 47 /* '/' */ &&\n url.charCodeAt(start + 1) === 47 /* '/' */\n ) {\n start += 2;\n } else {\n const indexOfProtocol = url.indexOf(':/', start);\n if (indexOfProtocol !== -1) {\n // Implement fast-path for common protocols. We expect most protocols\n // should be one of these 4 and thus we will not need to perform the\n // more expansive validity check most of the time.\n const protocolSize = indexOfProtocol - start;\n const c0 = url.charCodeAt(start);\n const c1 = url.charCodeAt(start + 1);\n const c2 = url.charCodeAt(start + 2);\n const c3 = url.charCodeAt(start + 3);\n const c4 = url.charCodeAt(start + 4);\n\n if (\n protocolSize === 5 &&\n c0 === 104 /* 'h' */ &&\n c1 === 116 /* 't' */ &&\n c2 === 116 /* 't' */ &&\n c3 === 112 /* 'p' */ &&\n c4 === 115 /* 's' */\n ) {\n // https\n } else if (\n protocolSize === 4 &&\n c0 === 104 /* 'h' */ &&\n c1 === 116 /* 't' */ &&\n c2 === 116 /* 't' */ &&\n c3 === 112 /* 'p' */\n ) {\n // http\n } else if (\n protocolSize === 3 &&\n c0 === 119 /* 'w' */ &&\n c1 === 115 /* 's' */ &&\n c2 === 115 /* 's' */\n ) {\n // wss\n } else if (\n protocolSize === 2 &&\n c0 === 119 /* 'w' */ &&\n c1 === 115 /* 's' */\n ) {\n // ws\n } else {\n // Check that scheme is valid\n for (let i = start; i < indexOfProtocol; i += 1) {\n const lowerCaseCode = url.charCodeAt(i) | 32;\n if (\n !(\n (\n (lowerCaseCode >= 97 && lowerCaseCode <= 122) || // [a, z]\n (lowerCaseCode >= 48 && lowerCaseCode <= 57) || // [0, 9]\n lowerCaseCode === 46 || // '.'\n lowerCaseCode === 45 || // '-'\n lowerCaseCode === 43\n ) // '+'\n )\n ) {\n return null;\n }\n }\n }\n\n // Skip 0, 1 or more '/' after ':/'\n start = indexOfProtocol + 2;\n while (url.charCodeAt(start) === 47 /* '/' */) {\n start += 1;\n }\n }\n }\n\n // Detect first occurrence of '/', '?' or '#'. We also keep track of the\n // last occurrence of '@', ']' or ':' to speed-up subsequent parsing of\n // (respectively), identifier, ipv6 or port.\n let indexOfIdentifier = -1;\n let indexOfClosingBracket = -1;\n let indexOfPort = -1;\n for (let i = start; i < end; i += 1) {\n const code: number = url.charCodeAt(i);\n if (\n code === 35 || // '#'\n code === 47 || // '/'\n code === 63 // '?'\n ) {\n end = i;\n break;\n } else if (code === 64) {\n // '@'\n indexOfIdentifier = i;\n } else if (code === 93) {\n // ']'\n indexOfClosingBracket = i;\n } else if (code === 58) {\n // ':'\n indexOfPort = i;\n } else if (code >= 65 && code <= 90) {\n hasUpper = true;\n }\n }\n\n // Detect identifier: '@'\n if (\n indexOfIdentifier !== -1 &&\n indexOfIdentifier > start &&\n indexOfIdentifier < end\n ) {\n start = indexOfIdentifier + 1;\n }\n\n // Handle ipv6 addresses\n if (url.charCodeAt(start) === 91 /* '[' */) {\n if (indexOfClosingBracket !== -1) {\n return url.slice(start + 1, indexOfClosingBracket).toLowerCase();\n }\n return null;\nLine truncated
+7
View File
@@ -0,0 +1,7 @@
import { IOptions, IResult } from 'tldts-core';
export declare function parse(url: string, options?: Partial<IOptions>): IResult;
export declare function getHostname(url: string, options?: Partial<IOptions>): string | null;
export declare function getPublicSuffix(url: string, options?: Partial<IOptions>): string | null;
export declare function getDomain(url: string, options?: Partial<IOptions>): string | null;
export declare function getSubdomain(url: string, options?: Partial<IOptions>): string | null;
export declare function getDomainWithoutSuffix(url: string, options?: Partial<IOptions>): string | null;
+5
View File
@@ -0,0 +1,5 @@
export type ITrie = [0 | 1 | 2, {
[label: string]: ITrie;
}];
export declare const exceptions: ITrie;
export declare const rules: ITrie;
+5
View File
@@ -0,0 +1,5 @@
import { IPublicSuffix, ISuffixLookupOptions } from 'tldts-core';
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
export default function suffixLookup(hostname: string, options: ISuffixLookupOptions, out: IPublicSuffix): void;
+62
View File
@@ -0,0 +1,62 @@
import {
FLAG,
getEmptyResult,
IOptions,
IResult,
parseImpl,
resetResult,
} from 'tldts-core';
import suffixLookup from './src/suffix-trie';
// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT: IResult = getEmptyResult();
export function parse(url: string, options: Partial<IOptions> = {}): IResult {
return parseImpl(url, FLAG.ALL, suffixLookup, options, getEmptyResult());
}
export function getHostname(
url: string,
options: Partial<IOptions> = {},
): string | null {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, FLAG.HOSTNAME, suffixLookup, options, RESULT).hostname;
}
export function getPublicSuffix(
url: string,
options: Partial<IOptions> = {},
): string | null {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, FLAG.PUBLIC_SUFFIX, suffixLookup, options, RESULT)
.publicSuffix;
}
export function getDomain(
url: string,
options: Partial<IOptions> = {},
): string | null {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, FLAG.DOMAIN, suffixLookup, options, RESULT).domain;
}
export function getSubdomain(
url: string,
options: Partial<IOptions> = {},
): string | null {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, FLAG.SUB_DOMAIN, suffixLookup, options, RESULT)
.subdomain;
}
export function getDomainWithoutSuffix(
url: string,
options: Partial<IOptions> = {},
): string | null {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, FLAG.ALL, suffixLookup, options, RESULT)
.domainWithoutSuffix;
}
+91
View File
@@ -0,0 +1,91 @@
{
"name": "tldts",
"version": "7.0.19",
"description": "Library to work against complex domain names, subdomains and URIs.",
"author": {
"name": "Rémi Berson"
},
"contributors": [
"Alexei <alexeiatyahoodotcom@gmail.com>",
"Alexey <kureev-mail@ya.ru>",
"Andrew <chefandrew@seomoz.org>",
"Johannes Ewald <johannes.ewald@peerigon.com>",
"Jérôme Desboeufs <jerome.desboeufs@gmail.com>",
"Kelly Campbell <kelly.a.campbell@gmail.com>",
"Kiko Beats <josefrancisco.verdu@gmail.com>",
"Kris Reeves <krisreeves@searchfanatics.com>",
"Krzysztof Jan Modras <chrmod@chrmod.net>",
"Olivier Melcher <olivier.melcher@gmail.com>",
"Rémi Berson <remi.berson@pm.me>",
"Saad Rashid <srashid@lendinghome.com>",
"Thomas Parisot <hi@oncletom.io>",
"Timo Tijhof <krinklemail@gmail.com>",
"Xavier Damman <xdamman@gmail.com>",
"Yehezkiel Syamsuhadi <yehezkielbs@gmail.com>"
],
"publishConfig": {
"access": "public"
},
"license": "MIT",
"homepage": "https://github.com/remusao/tldts#readme",
"bugs": {
"url": "https://github.com/remusao/tldts/issues"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/remusao/tldts.git"
},
"main": "dist/cjs/index.js",
"module": "dist/es6/index.js",
"types": "dist/types/index.d.ts",
"files": [
"dist",
"src",
"index.ts"
],
"bin": {
"tldts": "bin/cli.js"
},
"scripts": {
"clean": "rimraf dist coverage",
"build": "tsc --build ./tsconfig.json",
"bundle": "tsc --build ./tsconfig.bundle.json && rollup --config ./rollup.config.mjs",
"prepack": "yarn run bundle",
"test": "nyc mocha --config ../../.mocharc.cjs"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^12.1.0",
"@types/chai": "^4.2.18",
"@types/mocha": "^10.0.0",
"@types/node": "^24.3.1",
"chai": "^4.4.1",
"mocha": "^11.0.1",
"nyc": "^17.0.0",
"rimraf": "^5.0.1",
"rollup": "^4.1.0",
"rollup-plugin-sourcemaps": "^0.6.1",
"tldts-tests": "^7.0.19",
"typescript": "^5.0.4"
},
"dependencies": {
"tldts-core": "^7.0.19"
},
"keywords": [
"tld",
"sld",
"domain",
"subdomain",
"subdomain",
"hostname",
"browser",
"uri",
"url",
"domain name",
"public suffix",
"url parsing",
"typescript"
],
"gitHead": "ad04671e990387eef9e98dee432b2142566722ca"
}
+14
View File
@@ -0,0 +1,14 @@
export type ITrie = [0 | 1 | 2, { [label: string]: ITrie}];
export const exceptions: ITrie = (function() {
const _0: ITrie = [1,{}],_1: ITrie = [0,{"city":_0}];
const exceptions: ITrie = [0,{"ck":[0,{"www":_0}],"jp":[0,{"kawasaki":_1,"kitakyushu":_1,"kobe":_1,"nagoya":_1,"sapporo":_1,"sendai":_1,"yokohama":_1}]}];
return exceptions;
})();
export const rules: ITrie = (function() {
const _2: ITrie = [1,{}],_3: ITrie = [2,{}],_4: ITrie = [1,{"com":_2,"edu":_2,"gov":_2,"net":_2,"org":_2}],_5: ITrie = [1,{"com":_2,"edu":_2,"gov":_2,"mil":_2,"net":_2,"org":_2}],_6: ITrie = [0,{"*":_3}],_7: ITrie = [2,{"s":_6}],_8: ITrie = [0,{"relay":_3}],_9: ITrie = [2,{"id":_3}],_10: ITrie = [1,{"gov":_2}],_11: ITrie = [0,{"airflow":_6,"lambda-url":_3,"transfer-webapp":_3}],_12: ITrie = [0,{"airflow":_6,"transfer-webapp":_3}],_13: ITrie = [0,{"transfer-webapp":_3,"transfer-webapp-fips":_3}],_14: ITrie = [0,{"notebook":_3,"studio":_3}],_15: ITrie = [0,{"labeling":_3,"notebook":_3,"studio":_3}],_16: ITrie = [0,{"notebook":_3}],_17: ITrie = [0,{"labeling":_3,"notebook":_3,"notebook-fips":_3,"studio":_3}],_18: ITrie = [0,{"notebook":_3,"notebook-fips":_3,"studio":_3,"studio-fips":_3}],_19: ITrie = [0,{"shop":_3}],_20: ITrie = [0,{"*":_2}],_21: ITrie = [1,{"co":_3}],_22: ITrie = [0,{"objects":_3}],_23: ITrie = [2,{"nodes":_3}],_24: ITrie = [0,{"my":_3}],_25: ITrie = [0,{"s3":_3,"s3-accesspoint":_3,"s3-website":_3}],_26: ITrie = [0,{"s3":_3,"s3-accesspoint":_3}],_27: ITrie = [0,{"direct":_3}],_28: ITrie = [0,{"webview-assets":_3}],_29: ITrie = [0,{"vfs":_3,"webview-assets":_3}],_30: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_25,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3,"aws-cloud9":_28,"cloud9":_29}],_31: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_26,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3,"aws-cloud9":_28,"cloud9":_29}],_32: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_25,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3,"analytics-gateway":_3,"aws-cloud9":_28,"cloud9":_29}],_33: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_25,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3}],_34: ITrie = [0,{"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3,"s3-website":_3}],_35: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_34,"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3,"s3-object-lambda":_3,"s3-website":_3,"aws-cloud9":_28,"cloud9":_29}],_36: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_34,"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-deprecated":_3,"s3-fips":_3,"s3-object-lambda":_3,"s3-website":_3,"analytics-gateway":_3,"aws-cloud9":_28,"cloud9":_29}],_37: ITrie = [0,{"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3}],_38: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_37,"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3,"s3-object-lambda":_3,"s3-website":_3}],_39: ITrie = [0,{"auth":_3}],_40: ITrie = [0,{"auth":_3,"auth-fips":_3}],_41: ITrie = [0,{"auth-fips":_3}],_42: ITrie = [0,{"apps":_3}],_43: ITrie = [0,{"paas":_3}],_44: ITrie = [2,{"eu":_3}],_45: ITrie = [0,{"app":_3}],_46: ITrie = [0,{"site":_3}],_47: ITrie = [1,{"com":_2,"edu":_2,"net":_2,"org":_2}],_48: ITrie = [0,{"j":_3}],_49: ITrie = [0,{"dyn":_3}],_50: ITrie = [2,{"web":_3}],_51: ITrie = [1,{"co":_2,"com":_2,"edu":_2,"gov":_2,"net":_2,"org":_2}],_52: ITrie = [0,{"p":_3}],_53: ITrie = [0,{"user":_3}],_54: ITrie = [0,{"cdn":_3}],_55: ITrie = [2,{"raw":_6}],_56: ITrie = [0,{"cust":_3,"reservd":_3}],_57: ITrie = [0,{"cust":_3}],_58: ITrie = [0,{"s3":_3}],_59: ITrie = [1,{"biz":_2,"com":_2,"edu":_2,"gov":_2,"info":_2,"net":_2,"org":_2}],_60: ITrie = [0,{"ipfs":_3}],_61: ITrie = [1,{"framer":_3}],_62: ITrie = [0,{"forgot":_3}],_63: ITrie = [1,{"gs":_2}],_64: ITrie = [0,{"nes":_2}],_65: ITrie = [1,{"k12":_2,"cc":_2,"lib":_2}],_66: ITrie = [1,{"cc":_2}],_67: ITrie = [1,{"cc":_2,"lib":_2}];
const rules: ITrie = [0,{"ac":[1,{"com":_2,"edu":_2,"gov":_2,"mil":_2,"net":_2,"org":_2,"drr":_3,"feedback":_3,"forms":_3}],"ad":_2,"ae":[1,{"ac":_2,"co":_2,"gov":_2,"mil":_2,"net":_2,"org":_2,"sch":_2}],"aero":[1,{"airline":_2,"airport":_2,"accident-investigation":_2,"accident-prevention":_2,"aerobatic":_2,"aeroclub":_2,"aerodrome":_2,"agents":_2,"air-surveillance":_2,"air-traffic-control":_2,"aircraft":_2,"airtraffic":_2,"ambulance":_2,"association":_2,"author":_2,"ballooning":_2,"broker":_2,"caa":_2,"cargo":_2,"catering":_2,"certification":_2,"championship":_2,"charter":_2,"civilaviation":_2,"club":_2,"conference":_2,"consultant":_2,"consulting":_2,"control":_2,"council":_2,"crew":_2,"design":_2,"dgca":_2,"educator":_2,"emergency":_2,"engine":_2,"engineer":_2,"entertainment":_2,"equipment":_2,"exchange":_2,"express":_2,"federation":_2,"flight":_2,"freight":_2,"fuel":_2,"gliding":_2,"government":_2,"groundhandling":_2,"group":_2,"hanggliding":_2,"homebuilt":_2,"insurance":_2,"journal":_2,"journalist":_2,"leasing":_2,"logistics":_2,"magazine":_2,"maintenance":_2,"marketplace":_2,"media":_2,"microlight":_2,"modelling":_2,"navigation":_2,"parachuting":_2,"paragliding":_2,"passenger-association":_2,"pilot":_2,"press":_2,"production":_2,"recreation":_2,"repbody":_2,"res":_2,"research":_2,"rotorcraft":_2,"safety":_2,"scientist":_2,"services":_2,"show":_2,"skydiving":_2,"software":_2,"student":_2,"taxi":_2,"trader":_2,"trading":_2,"trainer":_2,"union":_2,"workinggroup":_2,"works":_2}],"af":_4,"ag":[1,{"co":_2,"com":_2,"net":_2,"nom":_2,"org":_2,"obj":_3}],"ai":[1,{"com":_2,"net":_2,"off":_2,"org":_2,"uwu":_3,"framer":_3}],"al":_5,"am":[1,{"co":_2,"com":_2,"commune":_2,"net":_2,"org":_2,"radio":_3}],"ao":[1,{"co":_2,"ed":_2,"edu":_2,"gov":_2,"gv":_2,"it":_2,"og":_2,"org":_2,"pb":_2}],"aq":_2,"ar":[1,{"bet":_2,"com":_2,"coop":_2,"edu":_2,"gob":_2,"gov":_2,"int":_2,"mil":_2,"musica":_2,"mutual":_2,"net":_2,"org":_2,"seg":_2,"senasa":_2,"tur":_2}],"arpa":[1,{"e164":_2,"home":_2,"in-addr":_2,"ip6":_2,"iris":_2,"uri":_2,"urn":_2}],"as":_10,"asia":[1,{"cloudns":_3,"daemon":_3,"dix":_3}],"at":[1,{"4":_3,"ac":[1,{"sth":_2}],"co":_2,"gv":_2,"or":_2,"funkfeuer":[0,{"wien":_3}],"futurecms":[0,{"*":_3,"ex":_6,"in":_6}],"futurehosting":_3,"futuremailing":_3,"ortsinfo":[0,{"ex":_6,"kunden":_6}],"biz":_3,"info":_3,"123webseite":_3,"priv":_3,"my":_3,"myspreadshop":_3,"12hp":_3,"2ix":_3,"4lima":_3,"lima-city":_3}],"au":[1,{"asn":_2,"com":[1,{"cloudlets":[0,{"mel":_3}],"myspreadshop":_3}],"edu":[1,{"act":_2,"catholic":_2,"nsw":_2,"nt":_2,"qld":_2,"sa":_2,"tas":_2,"vic":_2,"wa":_2}],"gov":[1,{"qld":_2,"sa":_2,"tas":_2,"vic":_2,"wa":_2}],"id":_2,"net":_2,"org":_2,"conf":_2,"oz":_2,"act":_2,"nsw":_2,"nt":_2,"qld":_2,"sa":_2,"tas":_2,"vic":_2,"wa":_2,"hrsn":[0,{"vps":_3}]}],"aw":[1,{"com":_2}],"ax":_2,"az":[1,{"biz":_2,"co":_2,"com":_2,"edu":_2,"gov":_2,"info":_2,"int":_2,"mil":_2,"name":_2,"net":_2,"org":_2,"pp":_2,"pro":_2}],"ba":[1,{"com":_2,"edu":_2,"gov":_2,"mil":_2,"net":_2,"org":_2,"brendly":_19,"rs":_3}],"bb":[1,{"biz":_2,"co":_2,"com":_2,"edu":_2,"gov":_2,"info":_2,"net":_2,"org":_2,"store":_2,"tv":_2}],"bd":[1,{"ac":_2,"ai":_2,"co":_2,"com":_2,"edu":_2,"gov":_2,"id":_2,"info":_2,"it":_2,"mil":_2,"net":_2,"org":_2,"sch":_2,"tv":_2}],"be":[1,{"ac":_2,"cloudns":_3,"webhosting":_3,"interhostsolutions":[0,{"cloud":_3}],"kuleuven":[0,{"ezproxy":_3}],"123website":_3,"myspreadshop":_3,"transurl":_6}],"bf":_10,"bg":[1,{"0":_2,"1":_2,"2":_2,"3":_2,"4":_2,"5":_2,"6":_2,"7":_2,"8":_2,"9":_2,"a":_2,"b":_2,"c":_2,"d":_2,"e":_2,"f":_2,"g":_2,"h":_2,"i":_2,"j":_2,"k":_2,"l":_2,"m":_2,"n":_2,"o":_2,"p":_2,"q":_2,"r":_2,"s":_2,"t":_2,"u":_2,"v":_2,"w":_2,"x":_2,"y":_2,"z":_2,"barsy":_3}],"bh":_4,"bi":[1,{"co":_2,"com":_2,"edu":_2,"or":_2,"org":_2}],"biz":[1,{"activetrail":_3,"cloud-ip":_3,"cloudns":_3,"jozi":_3,"dyndns":_3,"for-better":_3,"for-more":_3,"for-some":_3,"for-the":_3,"selfip":_3,"webhop":_3,"orx":_3,"mmafan":_3,"myftp":_3,"no-ip":_3,"dscloud":_3}],"bj":[1,{"africa":_2,"agro":_2,"architectes":_2,"assur":_2,"avocats":_2,"co":_2,"com":_2,"eco":_2,"econo":_2,"edu":_2,"info":_2,"loisirs":_2,"money":_2,"net":_2,"org":_2,"ote":_2,"restaurant":_2,"resto":_2,"tourism":_2,"univ":_2}],"bm":_4,"bn":[1,{"com":_2,"edu":_2,"gov":_2,"net":_2,"org":_2,"co":_3}],"bo":[1,{"com":_2,"edu":_2,"gob":_2,"int":_2,"mil":_2,"net":_2,"org":_2,"tv":_2,"web":_2,"academia":_2,"agro":_2,"arte":_2,"blog":_2,"bolivia":_2,"ciencia":_2,"cooperativa":_2,"democracia":_2,"deporte":_2,"ecologia":_2,"economia":_2,"empresa":_2,"indigena":_2,"industria":_2,"info":_2,"medicina":_2,"movimiento":_2,"musica":_2,"natural":_2,"nombre":_2,"noticias":_2,"patria":_2,"plurinacional":_2,"politica":_2,"profesional":_2,"pueblo":_2,"revista":_2,"salud":_2,"tecnologia":_2,"tksat":_2,"transporte":_2,"wiki":_2}],"br":[1,{"9guacu":_2,"abc":_2,"adm":_2,"adv":_2,"agr":_2,"aju":_2,"am":_2,"anani":_2,"aparecida":_2,"api":_2,"app":_2,"arq":_2,"art":_2,"ato":_2,"b":_2,"barueri":_2,"belem":_2,"beLine truncated
return rules;
})();
+110
View File
@@ -0,0 +1,110 @@
import {
fastPathLookup,
IPublicSuffix,
ISuffixLookupOptions,
} from 'tldts-core';
import { exceptions, ITrie, rules } from './data/trie';
// Flags used to know if a rule is ICANN or Private
const enum RULE_TYPE {
ICANN = 1,
PRIVATE = 2,
}
interface IMatch {
index: number;
isIcann: boolean;
isPrivate: boolean;
}
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(
parts: string[],
trie: ITrie,
index: number,
allowedMask: number,
): IMatch | null {
let result: IMatch | null = null;
let node: ITrie | undefined = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === RULE_TYPE.ICANN,
isPrivate: node[0] === RULE_TYPE.PRIVATE,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ: { [label: string]: ITrie } = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index]!)
? succ[parts[index]!]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
export default function suffixLookup(
hostname: string,
options: ISuffixLookupOptions,
out: IPublicSuffix,
): void {
if (fastPathLookup(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask =
(options.allowPrivateDomains ? RULE_TYPE.PRIVATE : 0) |
(options.allowIcannDomains ? RULE_TYPE.ICANN : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(
hostnameParts,
exceptions,
hostnameParts.length - 1,
allowedMask,
);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(
hostnameParts,
rules,
hostnameParts.length - 1,
allowedMask,
);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = hostnameParts[hostnameParts.length - 1] ?? null;
}