{"name":"tldts","version":"5.3.2","keywords":["tld","sld","domain","subdomain","subdomain","hostname","browser","uri","url","domain name","public suffix","url parsing","typescript"],"author":{"name":"Rémi Berson"},"license":"MIT","_id":"tldts@5.3.2","contributors":[{"name":"Alexei","email":"alexeiatyahoodotcom@gmail.com"},{"name":"Alexey","email":"kureev-mail@ya.ru"},{"name":"Andrew","email":"chefandrew@seomoz.org"},{"name":"Johannes Ewald","email":"johannes.ewald@peerigon.com"},{"name":"Jérôme Desboeufs","email":"jerome.desboeufs@gmail.com"},{"name":"Kelly Campbell","email":"kelly.a.campbell@gmail.com"},{"name":"Kiko Beats","email":"josefrancisco.verdu@gmail.com"},{"name":"Kris Reeves","email":"krisreeves@searchfanatics.com"},{"name":"Krzysztof Jan Modras","email":"chrmod@chrmod.net"},{"name":"Olivier Melcher","email":"olivier.melcher@gmail.com"},{"name":"Rémi Berson","email":"remi.berson@pm.me"},{"name":"Saad Rashid","email":"srashid@lendinghome.com"},{"name":"Thomas Parisot","email":"hi@oncletom.io"},{"name":"Timo Tijhof","email":"krinklemail@gmail.com"},{"name":"Xavier Damman","email":"xdamman@gmail.com"},{"name":"Yehezkiel Syamsuhadi","email":"yehezkielbs@gmail.com"}],"homepage":"https://github.com/remusao/tldts#readme","bugs":{"url":"https://github.com/remusao/tldts/issues"},"bin":{"tldts":"bin/cli.js"},"dist":{"shasum":"d7e9b31b70b7d7687a16fe31a18ec2ca8a33f852","tarball":"http://registry-npm.ywwl.com/tldts/download/tldts-5.3.2.tgz","fileCount":18,"integrity":"sha512-R96Q0sJoD1vMYZ5YI0om32AZW2SYDxWfcg0111gnJYIvfyVgHOwyYj2dLFhpkPCSH7AwwUe0MmewmUrQhJXRjQ==","signatures":[{"sig":"MEQCIE1JMccd+kdAKmHmTR6/Kf+bpS+rwqVkLinIIcQohjocAiB1lep/pV9JOlo1aPavXCtdDigmmzdvqrtt3hyR4ShyHA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1300282,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOu6xCRA9TVsSAnZWagAA6g8QAJWNTXHyfIUWAbCjRO7v\nJYepGeFqfpGZIlpgL1H7i6sZdBQzSY334IfrMbuvbUT1ROFjP1/5rst8+U6G\nSRGoOb4u7GnnCju+hPS9IZebi3hHW5NK3h3ei0lSwNkGNiSnnXO/wVOyokr2\nC6+YVD/S7qFcJfOJ2Lr+UTXGiRJWx5E/9wf8XMvnO3cFqeaZkfFp6qCYdaTI\n5GWoJ9IxjsTCkym/WZ/e5lAv/1kWPnZ2WWmSec6YTxhcBJz9fmjqSR39KaLE\nQlOsjijld0twbtgrYUv3kN7b5rFBY6zYfWTwMsWSKj/tybvECuqMHw8E6QR2\np1GJAMa3hTezKyBE2TDXL+i+cyn45OceCnP3md2vSzVyxAyM+Y+9zW861Ywd\nsetVbbQpeclsNx0UGNBmb8UQOzxeuBUixPy38+9BTc0tmhyNf9D15vp7OAgb\nVUp8AdfUcVAquo2j5ZuZo+jpKtFlFdfpHbuApkdZiVkIEqIB2pZeiKdmseM/\n2VkoveWNyZ3uksMxxp8DY+A5OolqYKwZC1DoYYdfmCV7NHDdxXBuEDV9ggO6\nYEKIZBtoPowR1lhZbp4iZf/0qudnRxmyyFb1T+i1Emk/Am0PszlD8FzWbzlU\nk7exyL//htUN4h4MJuCTrJmoY+Nhp1VId0qPbMU/x9EhgVKJUMnB6gaJeDDS\nQ9qv\r\n=8ZfP\r\n-----END PGP SIGNATURE-----\r\n","size":260527,"noattachment":false,"key":"/tldts/-/tldts-5.3.2.tgz"},"main":"dist/cjs/index.js","types":"dist/types/index.d.ts","module":"dist/es6/index.js","gitHead":"29ad399169551d4c2a8eb366d7d73354b1b17a3e","scripts":{"lint":"tslint --config ../../tslint.json --project ./tsconfig.json","test":"jest --config ./jest.config.js --coverage ./test/","build":"tsc --build ./tsconfig.json","clean":"rimraf dist coverage","bundle":"rollup --config ./rollup.config.ts","prepack":"yarn run bundle","prebundle":"yarn run build"},"_npmUser":{"name":"remusao","email":"remi@cliqz.com"},"repository":{"url":"git+ssh://git@github.com/remusao/tldts.git","type":"git"},"_npmVersion":"lerna/3.16.4/node@v11.15.0+x64 (linux)","description":"Library to work against complex domain names, subdomains and URIs.","directories":{},"_nodeVersion":"11.15.0","dependencies":{"tldts-core":"^5.3.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.8.0","rimraf":"^2.6.3","rollup":"^1.17.0","tslint":"^5.18.0","ts-jest":"^24.0.2","typescript":"^3.5.2","@types/jest":"^24.0.15","@types/node":"^12.0.3","tldts-tests":"^5.3.2","tslint-config-prettier":"^1.18.0","rollup-plugin-sourcemaps":"^0.4.2","rollup-plugin-node-resolve":"^5.2.0","@ampproject/rollup-plugin-closure-compiler":"^0.10.0"},"_npmOperationalInternal":{"tmp":"tmp/tldts_5.3.2_1564143281258_0.298015250824347","host":"s3://npm-registry-packages"},"readme":"# tldts - Blazing Fast URL Parsing\n\n`tldts` is a JavaScript library to extract hostnames, domains, public suffixes, top-level domains and subdomains from URLs.\n\n**Features**:\n\n1. Tuned for **performance** (order of 0.1 to 1 μs per input)\n2. Handles both URLs and hostnames\n3. Full Unicode/IDNA support\n4. Support parsing email addresses\n5. Detect IPv4 and IPv6 addresses\n6. Continuously updated version of the public suffix list\n7. **TypeScript**, ships with `umd`, `esm`, `cjs` bundles and _type definitions_\n8. Small bundles and small memory footprint\n9. Battle tested: full test coverage and production use\n\n# Install\n\n```bash\nnpm install --save tldts\n```\n\n# Usage\n\nUsing the command-line interface:\n\n```js\n$ npx tldts 'http://www.writethedocs.org/conf/eu/2017/'\n{\n  \"domain\": \"writethedocs.org\",\n  \"domainWithoutSuffix\": \"writethedocs\",\n  \"hostname\": \"www.writethedocs.org\",\n  \"isIcann\": true,\n  \"isIp\": false,\n  \"isPrivate\": false,\n  \"publicSuffix\": \"org\",\n  \"subdomain\": \"www\"\n}\n```\n\nProgrammatically:\n\n```js\nconst { parse } = require('tldts');\n\n// Retrieving hostname related informations of a given URL\nparse('http://www.writethedocs.org/conf/eu/2017/');\n// { domain: 'writethedocs.org',\n//   domainWithoutSuffix: 'writethedocs',\n//   hostname: 'www.writethedocs.org',\n//   isIcann: true,\n//   isIp: false,\n//   isPrivate: false,\n//   publicSuffix: 'org',\n//   subdomain: 'www' }\n```\n\nModern _ES6 modules import_ is also supported:\n\n```js\nimport { parse } from 'tldts';\n```\n\nAlternatively, you can try it _directly in your browser_ here: https://npm.runkit.com/tldts\n\n# API\n\n- `tldts.parse(url | hostname, options)`\n- `tldts.getHostname(url | hostname, options)`\n- `tldts.getDomain(url | hostname, options)`\n- `tldts.getFullDomain(url | hostname, options)`\n- `tldts.getPublicSuffix(url | hostname, options)`\n- `tldts.getSubdomain(url, | hostname, options)`\n- `tldts.getDomainWithoutSuffix(url | hostname, options)`\n\nThe behavior of `tldts` can be customized using an `options` argument for all\nthe functions exposed as part of the public API. This is useful to both change\nthe behavior of the library as well as fine-tune the performance depending on\nyour inputs.\n\n```js\n{\n  // Use suffixes from ICANN section (default: true)\n  allowIcannDomains: boolean;\n  // Use suffixes from Private section (default: false)\n  allowPrivateDomains: boolean;\n  // Extract and validate hostname (default: true)\n  // When set to `false`, inputs will be considered valid hostnames.\n  extractHostname: boolean;\n  // Validate hostnames after parsing (default: true)\n  // If a hostname is not valid, not further processing is performed. When set\n  // to `false`, inputs to the library will be considered valid and parsing will\n  // proceed regardless.\n  validateHostname: boolean;\n  // Perform IP address detection (default: true).\n  detectIp: boolean;\n  // Detect IANA special-use domains (RFC 6761 et al.) and expose the result as\n  // `isSpecialUse` (default: false). Off by default so the common path does no\n  // extra work; the field stays `null` unless this is enabled.\n  detectSpecialUse: boolean;\n  // Assume that both URLs and hostnames can be given as input (default: true)\n  // If set to `false` we assume only URLs will be given as input, which\n  // speed-ups processing.\n  mixedInputs: boolean;\n  // Specifies extra valid suffixes (default: null)\n  validHosts: string[] | null;\n}\n```\n\nThe `parse` method returns handy **properties about a URL or a hostname**.\n\n```js\nconst tldts = require('tldts');\n\ntldts.parse('https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv');\n// { domain: 'amazonaws.com',\n//   domainWithoutSuffix: 'amazonaws',\n//   hostname: 'spark-public.s3.amazonaws.com',\n//   isIcann: true,\n//   isIp: false,\n//   isPrivate: false,\n//   publicSuffix: 'com',\n//   subdomain: 'spark-public.s3' }\n\ntldts.parse(\n  'https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv',\n  { allowPrivateDomains: true },\n);\n// { domain: 'spark-public.s3.amazonaws.com',\n//   domainWithoutSuffix: 'spark-public',\n//   hostname: 'spark-public.s3.amazonaws.com',\n//   isIcann: false,\n//   isIp: false,\n//   isPrivate: true,\n//   publicSuffix: 's3.amazonaws.com',\n//   subdomain: '' }\n\ntldts.parse('gopher://domain.unknown/');\n// { domain: 'domain.unknown',\n//   domainWithoutSuffix: 'domain',\n//   hostname: 'domain.unknown',\n//   isIcann: false,\n//   isIp: false,\n//   isPrivate: false,\n//   publicSuffix: 'unknown',\n//   subdomain: '' }\n\ntldts.parse('https://192.168.0.0'); // IPv4\n// { domain: null,\n//   domainWithoutSuffix: null,\n//   hostname: '192.168.0.0',\n//   isIcann: null,\n//   isIp: true,\n//   isPrivate: null,\n//   publicSuffix: null,\n//   subdomain: null }\n\ntldts.parse('https://[::1]'); // IPv6\n// { domain: null,\n//   domainWithoutSuffix: null,\n//   hostname: '::1',\n//   isIcann: null,\n//   isIp: true,\n//   isPrivate: null,\n//   publicSuffix: null,\n//   subdomain: null }\n\ntldts.parse('tldts@emailprovider.co.uk'); // email\n// { domain: 'emailprovider.co.uk',\n//   domainWithoutSuffix: 'emailprovider',\n//   hostname: 'emailprovider.co.uk',\n//   isIcann: true,\n//   isIp: false,\n//   isPrivate: false,\n//   publicSuffix: 'co.uk',\n//   subdomain: '' }\n```\n\n| Property Name         | Type   | Description                                     |\n| :-------------------- | :----- | :---------------------------------------------- |\n| `hostname`            | `str`  | `hostname` of the input extracted automatically |\n| `domain`              | `str`  | Domain (tld + sld)                              |\n| `domainWithoutSuffix` | `str`  | Domain without public suffix                    |\n| `subdomain`           | `str`  | Sub domain (what comes after `domain`)          |\n| `publicSuffix`        | `str`  | Public Suffix (tld) of `hostname`               |\n| `isIcann`             | `bool` | Does TLD come from ICANN part of the list       |\n| `isPrivate`           | `bool` | Does TLD come from Private part of the list     |\n| `isIP`                | `bool` | Is `hostname` an IP address?                    |\n| `isSpecialUse`        | `bool` | Is `hostname` an IANA special-use domain?       |\n\n## Special-use domains (RFC 6761 / IANA)\n\nSet `{ detectSpecialUse: true }` to flag reserved special-use names such as `localhost`, `*.test`, `*.local`, `*.onion`, and `home.arpa` via the `isSpecialUse` result field. `isIcann`/`isPrivate` don't identify these: most aren't in the Public Suffix List, and the few that are (e.g. `onion`, `home.arpa`) appear there as ordinary ICANN suffixes. The field is `null` unless the option is enabled, so the default path does no extra work:\n\n```js\nparse('http://printer.local/', { detectSpecialUse: true });\n// { ...\n//   isSpecialUse: true,\n//   publicSuffix: 'local',\n//   subdomain: '' }\n```\n\nThe list tracks the IANA [Special-Use Domain Names](https://www.iana.org/assignments/special-use-domain-names/) registry.\n\n## Single purpose methods\n\nThese methods are shorthands if you want to retrieve only a single value (and\nwill perform better than `parse` because less work will be needed).\n\n### getHostname(url | hostname, options?)\n\nReturns the hostname from a given string.\n\n```javascript\nconst { getHostname } = require('tldts');\n\ngetHostname('google.com'); // returns `google.com`\ngetHostname('fr.google.com'); // returns `fr.google.com`\ngetHostname('fr.google.google'); // returns `fr.google.google`\ngetHostname('foo.google.co.uk'); // returns `foo.google.co.uk`\ngetHostname('t.co'); // returns `t.co`\ngetHostname('fr.t.co'); // returns `fr.t.co`\ngetHostname(\n  'https://user:password@example.co.uk:8080/some/path?and&query#hash',\n); // returns `example.co.uk`\n```\n\n### getDomain(url | hostname, options?)\n\nReturns the fully qualified domain from a given string.\n\n```javascript\nconst { getDomain } = require('tldts');\n\ngetDomain('google.com'); // returns `google.com`\ngetDomain('fr.google.com'); // returns `google.com`\ngetDomain('fr.google.google'); // returns `google.google`\ngetDomain('foo.google.co.uk'); // returns `google.co.uk`\ngetDomain('t.co'); // returns `t.co`\ngetDomain('fr.t.co'); // returns `t.co`\ngetDomain('https://user:password@example.co.uk:8080/some/path?and&query#hash'); // returns `example.co.uk`\n```\n\n### getFullDomain(url | hostname, options?)\n\nReturns the full domain — the subdomain together with the registrable domain (as\nreturned by `getDomain(...)`), i.e. the whole hostname _including_ any subdomain —\nor `null` when the input has no registrable domain (IP address, single label,\nbare public suffix, …). The result is the normalized hostname (lower-cased,\ntrailing dot stripped); it is not a DNS-absolute name (no trailing root dot) and\nno IDNA/punycode conversion is performed.\n\n```javascript\nconst { getFullDomain } = require('tldts');\n\ngetFullDomain('google.com'); // returns `google.com`\ngetFullDomain('fr.google.com'); // returns `fr.google.com`\ngetFullDomain('foo.google.co.uk'); // returns `foo.google.co.uk`\ngetFullDomain('t.co'); // returns `t.co`\ngetFullDomain('fr.t.co'); // returns `fr.t.co`\ngetFullDomain('1.2.3.4'); // returns null (no registrable domain)\ngetFullDomain('localhost'); // returns null\n```\n\n### getDomainWithoutSuffix(url | hostname, options?)\n\nReturns the domain (as returned by `getDomain(...)`) without the public suffix part.\n\n```javascript\nconst { getDomainWithoutSuffix } = require('tldts');\n\ngetDomainWithoutSuffix('google.com'); // returns `google`\ngetDomainWithoutSuffix('fr.google.com'); // returns `google`\ngetDomainWithoutSuffix('fr.google.google'); // returns `google`\ngetDomainWithoutSuffix('foo.google.co.uk'); // returns `google`\ngetDomainWithoutSuffix('t.co'); // returns `t`\ngetDomainWithoutSuffix('fr.t.co'); // returns `t`\ngetDomainWithoutSuffix(\n  'https://user:password@example.co.uk:8080/some/path?and&query#hash',\n); // returns `example`\n```\n\n### getSubdomain(url | hostname, options?)\n\nReturns the complete subdomain for a given string.\n\n```javascript\nconst { getSubdomain } = require('tldts');\n\ngetSubdomain('google.com'); // returns ``\ngetSubdomain('fr.google.com'); // returns `fr`\ngetSubdomain('google.co.uk'); // returns ``\ngetSubdomain('foo.google.co.uk'); // returns `foo`\ngetSubdomain('moar.foo.google.co.uk'); // returns `moar.foo`\ngetSubdomain('t.co'); // returns ``\ngetSubdomain('fr.t.co'); // returns `fr`\ngetSubdomain(\n  'https://user:password@secure.example.co.uk:443/some/path?and&query#hash',\n); // returns `secure`\n```\n\n### getPublicSuffix(url | hostname, options?)\n\nReturns the [public suffix][] for a given string.\n\n```javascript\nconst { getPublicSuffix } = require('tldts');\n\ngetPublicSuffix('google.com'); // returns `com`\ngetPublicSuffix('fr.google.com'); // returns `com`\ngetPublicSuffix('google.co.uk'); // returns `co.uk`\ngetPublicSuffix('s3.amazonaws.com'); // returns `com`\ngetPublicSuffix('s3.amazonaws.com', { allowPrivateDomains: true }); // returns `s3.amazonaws.com`\ngetPublicSuffix('tld.is.unknown'); // returns `unknown`\n```\n\n# Troubleshooting\n\n## Retrieving subdomain of `localhost` and custom hostnames\n\n`tldts` methods `getDomain` and `getSubdomain` are designed to **work only with _known and valid_ TLDs**.\nThis way, you can trust what a domain is.\n\n`localhost` is a valid hostname but not a TLD. You can pass additional options to each method exposed by `tldts`:\n\n```js\nconst tldts = require('tldts');\n\ntldts.getDomain('localhost'); // returns null\ntldts.getSubdomain('vhost.localhost'); // returns null\n\ntldts.getDomain('localhost', { validHosts: ['localhost'] }); // returns 'localhost'\ntldts.getSubdomain('vhost.localhost', { validHosts: ['localhost'] }); // returns 'vhost'\n```\n\n## Updating the TLDs List\n\n`tldts` made the opinionated choice of shipping with a list of suffixes directly\nin its bundle. There is currently no mechanism to update the lists yourself, but\nwe make sure that the version shipped is always up-to-date.\n\nIf you keep `tldts` updated, the lists should be up-to-date as well!\n\n# Performance\n\n`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 }`).\n\nPlease see [this detailed comparison](./comparison/comparison.md) with other available libraries.\n\n## Contributors\n\n`tldts` is based upon the excellent `tld.js` library and would not exist without\nthe many contributors who worked on the project:\n<a href=\"graphs/contributors\"><img src=\"https://opencollective.com/tldjs/contributors.svg?width=890\" /></a>\n\nThis project would not be possible without the amazing Mozilla's\n[public suffix list][]. Thank you for your hard work!\n\n# License\n\n[MIT License](LICENSE).\n\n[badge-ci]: https://secure.travis-ci.org/remusao/tldts.svg?branch=master\n[badge-downloads]: https://img.shields.io/npm/dm/tldts.svg\n[public suffix list]: https://publicsuffix.org/list/\n[list the recent changes]: https://github.com/publicsuffix/list/commits/master\n[changes Atom Feed]: https://github.com/publicsuffix/list/commits/master.atom\n[public suffix]: https://publicsuffix.org/learn/\n","publish_time":1564143281360,"maintainers":[{"name":"remusao","email":"remi.berson@pm.me"}],"_cnpm_publish_time":1564143281360,"dist-tags":{"canary":"5.6.65-canary.808.f42b3ecaee33e5bde4c2ec1c731092a25f9c6a2f.0","latest":"7.6.0"}}