{"name":"parse-domain","version":"8.3.0","keywords":["domain","url","sub-domain","tld","parse","sanitize","top-level"],"author":{"name":"peerigon","email":"developers@peerigon.com"},"license":"MIT","_id":"parse-domain@8.3.0","maintainers":[{"name":"peeri","email":"hello@peerigon.com"}],"homepage":"https://github.com/peerigon/parse-domain#readme","bugs":{"url":"https://github.com/peerigon/parse-domain/issues"},"bin":{"parse-domain-update":"bin/update.js"},"dist":{"shasum":"ec24e57e7676d65d9404cb22bfa516682a67e3e5","tarball":"http://registry-npm.ywwl.com/parse-domain/download/parse-domain-8.3.0.tgz","fileCount":89,"integrity":"sha512-oOjqUI93wiFHJlywlOKU9FEw60Q0LMy8S1s/AhnVhCB9LZkwIsCIZfqujeJ16u7rRzLdTEY2OpxlGRhLdnNNYA==","signatures":[{"sig":"MEUCIAsIyM5IhMYQkR7Vv8eqYJUQFRALsgiRe/XZT2JdazFmAiEAuLjPgP9eGGyrFerX14TVACmybvT3yxJW2twFMf8zWWY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/parse-domain@8.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":200258,"size":66390,"noattachment":false,"key":"/parse-domain/-/parse-domain-8.3.0.tgz"},"main":"./dist/main.js","type":"module","types":"./dist/main.d.ts","gitHead":"763b07457baf2646b0ac80ea53f668ea59f0f922","scripts":{"node":"node --no-warnings --loader ts-node/esm/transpile-only","test":"run-p test:*","build":"run-s build:*","prepare":"run-p prepare:*","release":"semantic-release","build:tsc":"tsc -p ./tsconfig.build.json","test:lint":"eslint --max-warnings 0 --cache .","test:suite":"vitest run --coverage","test:types":"tsc --noEmit","test:format":"prettier --check .","build:update":"./bin/update.js","build:cleanup":"rimraf dist","prepare:build":"npm run build","prepare:husky":"husky","update:psl-fixture":"npm run node -- ./src/scripts/update-psl-fixture.ts","update:dependencies":"updtr"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:575cb586-72a6-473a-a597-d7e8a02adba2"}},"repository":{"url":"git+https://github.com/peerigon/parse-domain.git","type":"git"},"_npmVersion":"11.11.0","description":"Splits a hostname into subdomains, domain and (effective) top-level domains","directories":{},"lint-staged":{"*.{json,css,md,yml,yaml}":"prettier --write","*.{ts,tsx,js,cjs,mjs,jsx}":["eslint --cache --fix","prettier --write"],".github/workflows/*.{yml,yaml}":["pin-github-action --allow-empty","prettier --write"]},"sideEffects":false,"_nodeVersion":"22.21.1","dependencies":{"is-ip":"^5.0.1"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"nock":"^14.0.10","husky":"^9.1.7","updtr":"^4.1.0","eslint":"9.38.0","rimraf":"^6.1.0","vitest":"^4.0.6","ts-node":"^10.9.2","prettier":"^3.6.2","typescript":"^5.9.3","@types/node":"^24.10.0","lint-staged":"^16.2.6","npm-run-all":"^4.1.5","semantic-release":"^25.0.1","@peerigon/configs":"^11.0.2","pin-github-action":"^3.4.0","@vitest/coverage-v8":"^4.0.6"},"_npmOperationalInternal":{"tmp":"tmp/parse-domain_8.3.0_1772327253437_0.46316025751686807","host":"s3://npm-registry-packages-npm-production"},"readme":"# parse-domain\n\n**Splits a hostname into subdomains, domain and (effective) top-level domains.**\n\n[![Version on NPM](https://img.shields.io/npm/v/parse-domain?style=for-the-badge)](https://www.npmjs.com/package/parse-domain)\n[![Semantically released](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge)](https://github.com/semantic-release/semantic-release)\n[![Monthly downloads on NPM](https://img.shields.io/npm/dm/parse-domain?style=for-the-badge)](https://www.npmjs.com/package/parse-domain)<br>\n[![NPM Bundle size minified](https://img.shields.io/bundlephobia/min/parse-domain?style=for-the-badge)](https://bundlephobia.com/result?p=parse-domain)\n[![NPM Bundle size minified and gzipped](https://img.shields.io/bundlephobia/minzip/parse-domain?style=for-the-badge)](https://bundlephobia.com/result?p=parse-domain)<br>\n[![License](https://img.shields.io/npm/l/parse-domain?style=for-the-badge)](./LICENSE)\n\nSince domain name registrars organize their namespaces in different ways, it's not straight-forward to split a hostname into subdomains, the domain and top-level domains. In order to do that **parse-domain** uses a [large list of known top-level domains](https://publicsuffix.org/list/public_suffix_list.dat) from [publicsuffix.org](https://publicsuffix.org/):\n\n```javascript\nimport { parseDomain, ParseResultType } from \"parse-domain\";\n\nconst parseResult = parseDomain(\n  // This should be a string with basic latin letters only.\n  // More information below.\n  \"www.some.example.co.uk\",\n);\n\n// Check if the domain is listed in the public suffix list\nif (parseResult.type === ParseResultType.Listed) {\n  const { subDomains, domain, topLevelDomains } = parseResult;\n\n  console.log(subDomains); // [\"www\", \"some\"]\n  console.log(domain); // \"example\"\n  console.log(topLevelDomains); // [\"co\", \"uk\"]\n} else {\n  // Read more about other parseResult types below...\n}\n```\n\nThis package has been designed for modern Node and browser environments with ECMAScript modules support. It assumes an ES2015 environment with [`Symbol()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL) and [`TextDecoder()`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) globally available. You need to transpile it down to ES5 (e.g. by using [Babel](https://babeljs.io/)) if you need to support older environments.\n\nThe list of top-level domains is stored in a [trie](https://en.wikipedia.org/wiki/Trie) data structure and serialization format to ensure the fastest lookup and the smallest possible library size.\n\n<br />\n\n## Installation\n\n```sh\nnpm install parse-domain\n```\n\nThis package is also published to [JSR](https://jsr.io/@peerigon/parse-domain):\n\n```sh\ndeno add jsr:@peerigon/parse-domain\n```\n\n## Updates\n\n💡 **Please note:** [publicsuffix.org](https://publicsuffix.org/) is updated several times per month. This package comes with a prebuilt list that has been downloaded at the time of `npm publish`. In order to get an up-to-date list, you should run `npx parse-domain-update` everytime you start or build your application. This will download the latest list from `https://publicsuffix.org/list/public_suffix_list.dat`.\n\nJSR packages don't support npm-style `bin` entries, so the script is published under the `./update` export instead. The script writes to a path relative to its own location, so it only works once the package has been resolved into a local `node_modules` directory (e.g. by enabling [`nodeModulesDir`](https://docs.deno.com/runtime/fundamentals/configuration/#node-modules-dir) in `deno.json`) — running it directly off a `jsr:` specifier fails because Deno doesn't expose a local path for remote-cached modules:\n\n```jsonc\n// deno.json\n{ \"nodeModulesDir\": \"auto\" }\n```\n\n```sh\ndeno add jsr:@peerigon/parse-domain\ndeno run --allow-net --allow-write ./node_modules/@peerigon/parse-domain/src/bin/update.ts\n```\n\n<br />\n\n## Expected input\n\n**⚠️ [`parseDomain`](#api-js-parseDomain) does not parse whole URLs**. You should only pass the [puny-encoded](https://en.wikipedia.org/wiki/Punycode) hostname section of the URL:\n\n| ❌ Wrong                                       | ✅ Correct           |\n| ---------------------------------------------- | -------------------- |\n| `https://user@www.example.com:8080/path?query` | `www.example.com`    |\n| `münchen.de`                                   | `xn--mnchen-3ya.de`  |\n| `食狮.com.cn?query`                            | `xn--85x722f.com.cn` |\n\nThere is the utility function [`fromUrl`](#api-js-fromUrl) which tries to extract the hostname from a (partial) URL and puny-encodes it:\n\n```javascript\nimport { toUnicode } from \"punycode\";\nimport { fromUrl, parseDomain } from \"parse-domain\";\n\nconst { subDomains, domain, topLevelDomains } = parseDomain(\n  fromUrl(\"https://www.münchen.de?query\"),\n);\n\nconsole.log(subDomains); // [\"www\"]\nconsole.log(domain); // \"xn--mnchen-3ya\"\nconsole.log(topLevelDomains); // [\"de\"]\n\n// You can use the 'punycode' NPM package to decode the domain again\nconsole.log(toUnicode(domain)); // \"münchen\"\n```\n\n[`fromUrl`](#api-js-fromUrl) parses the URL using [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL). Depending on your target environments you need to make sure that there is a [polyfill](https://www.npmjs.com/package/whatwg-url) for it. It's globally available in [all modern browsers](https://caniuse.com/#feat=url) (no IE) and in [Node v10](https://nodejs.org/api/url.html#url_class_url).\n\n## Expected output\n\nWhen parsing a hostname there are 5 possible results:\n\n- invalid\n- it is an ip address\n- it is formally correct and the domain is\n  - reserved\n  - not listed in the public suffix list\n  - listed in the public suffix list\n\n[`parseDomain`](#api-js-parseDomain) returns a [`ParseResult`](#api-ts-ParseResult) with a `type` property that allows to distinguish these cases.\n\n### 👉 Invalid domains\n\nThe given input is first validated against [RFC 3696](https://datatracker.ietf.org/doc/html/rfc3696#section-2) (the domain labels are limited to basic latin letters, numbers and hyphens). If the validation fails, `parseResult.type` will be `ParseResultType.Invalid`:\n\n```javascript\nimport { parseDomain, ParseResultType } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"münchen.de\");\n\nconsole.log(parseResult.type === ParseResultType.Invalid); // true\n```\n\nCheck out the [API](#api-ts-ValidationError) if you need more information about the validation error.\n\nIf you don't want the characters to be validated (e.g. because you need to allow underscores in hostnames), there's also a more relaxed validation mode (according to [RFC 2181](https://www.rfc-editor.org/rfc/rfc2181#section-11)).\n\n```javascript\nimport { parseDomain, ParseResultType, Validation } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"_jabber._tcp.gmail.com\", {\n  validation: Validation.Lax,\n});\n\nconsole.log(parseResult.type === ParseResultType.Listed); // true\n```\n\nSee also [#134](https://github.com/peerigon/parse-domain/issues/134) for the discussion.\n\n### 👉 IP addresses\n\nIf the given input is an IP address, `parseResult.type` will be `ParseResultType.Ip`:\n\n```javascript\nimport { parseDomain, ParseResultType } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"192.168.2.1\");\n\nconsole.log(parseResult.type === ParseResultType.Ip); // true\nconsole.log(parseResult.ipVersion); // 4\n```\n\nIt's debatable if a library for parsing domains should also accept IP addresses. In fact, you could argue that [`parseDomain`](#api-js-parseDomain) should reject an IP address as invalid. While this is true from a technical point of view, we decided to report IP addresses in a special way because we assume that a lot of people are using this library to make sense from an arbitrary hostname (see [#102](https://github.com/peerigon/parse-domain/issues/102)).\n\n### 👉 Reserved domains\n\nThere are 5 top-level domains that are not listed in the public suffix list but reserved according to [RFC 6761](https://tools.ietf.org/html/rfc6761) and [RFC 6762](https://tools.ietf.org/html/rfc6762):\n\n- `localhost`\n- `local`\n- `example`\n- `invalid`\n- `test`\n\nIn these cases, `parseResult.type` will be `ParseResultType.Reserved`:\n\n```javascript\nimport { parseDomain, ParseResultType } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"pecorino.local\");\n\nconsole.log(parseResult.type === ParseResultType.Reserved); // true\nconsole.log(parseResult.labels); // [\"pecorino\", \"local\"]\n```\n\n### 👉 Domains that are not listed\n\nIf the given hostname is valid, but not listed in the downloaded public suffix list, `parseResult.type` will be `ParseResultType.NotListed`:\n\n```javascript\nimport { parseDomain, ParseResultType } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"this.is.not-listed\");\n\nconsole.log(parseResult.type === ParseResultType.NotListed); // true\nconsole.log(parseResult.labels); // [\"this\", \"is\", \"not-listed\"]\n```\n\nIf a domain is not listed, it can be caused by an outdated list. Make sure to [update the list once in a while](#installation).\n\n⚠️ **Do not treat parseDomain as authoritative answer.** It cannot replace a real DNS lookup to validate if a given domain is known in a certain network.\n\n### 👉 Effective top-level domains\n\nTechnically, the term _top-level domain_ describes the very last domain in a hostname (`uk` in `example.co.uk`). Most people, however, use the term _top-level domain_ for the _public suffix_ which is a namespace [\"under which Internet users can directly register names\"](https://publicsuffix.org/).\n\nSome examples for public suffixes:\n\n- `com` in `example.com`\n- `co.uk` in `example.co.uk`\n- `co` in `example.co`\n- but also `com.co` in `example.com.co`\n\nIf the hostname is listed in the public suffix list, the `parseResult.type` will be `ParseResultType.Listed`:\n\n```javascript\nimport { parseDomain, ParseResultType } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"example.co.uk\");\n\nconsole.log(parseResult.type === ParseResultType.Listed); // true\nconsole.log(parseResult.labels); // [\"example\", \"co\", \"uk\"]\n```\n\nNow `parseResult` will also provide a `subDomains`, `domain` and `topLevelDomains` property:\n\n```javascript\nconst { subDomains, domain, topLevelDomains } = parseResult;\n\nconsole.log(subDomains); // []\nconsole.log(domain); // \"example\"\nconsole.log(topLevelDomains); // [\"co\", \"uk\"]\n```\n\n### 👉 Switch over `parseResult.type` to distinguish between different parse results\n\nWe recommend switching over the `parseResult.type`:\n\n```javascript\nswitch (parseResult.type) {\n  case ParseResultType.Listed: {\n    const { hostname, topLevelDomains } = parseResult;\n\n    console.log(`${hostname} belongs to ${topLevelDomains.join(\".\")}`);\n    break;\n  }\n  case ParseResultType.Reserved:\n  case ParseResultType.NotListed: {\n    const { hostname } = parseResult;\n\n    console.log(`${hostname} is a reserved or unknown domain`);\n    break;\n  }\n  default:\n    throw new Error(`${hostname} is an ip address or invalid domain`);\n}\n```\n\n### ⚠️ Effective TLDs !== TLDs acknowledged by ICANN\n\nWhat's surprising to a lot of people is that the definition of public suffix means that regular user domains can become effective top-level domains:\n\n```javascript\nconst { subDomains, domain, topLevelDomains } = parseDomain(\"parse-domain.github.io\");\n\nconsole.log(subDomains); // []\nconsole.log(domain); // \"parse-domain\"\nconsole.log(topLevelDomains); // [\"github\", \"io\"] 🤯\n```\n\nIn this case, `github.io` is nothing else than a private domain name registrar. `github.io` is the _effective_ top-level domain and browsers are treating it like that (e.g. for setting [`document.domain`](https://developer.mozilla.org/en-US/docs/Web/API/Document/domain)).\n\nIf you want to deviate from the browser's understanding of a top-level domain and you're only interested in top-level domains acknowledged by [ICANN](https://en.wikipedia.org/wiki/ICANN), there's an `icann` property:\n\n```javascript\nconst parseResult = parseDomain(\"parse-domain.github.io\");\nconst { subDomains, domain, topLevelDomains } = parseResult.icann;\n\nconsole.log(subDomains); // [\"parse-domain\"]\nconsole.log(domain); // \"github\"\nconsole.log(topLevelDomains); // [\"io\"]\n```\n\n### ⚠️ `domain` can also be `undefined`\n\n```javascript\nconst { subDomains, domain, topLevelDomains } = parseDomain(\"co.uk\");\n\nconsole.log(subDomains); // []\nconsole.log(domain); // undefined\nconsole.log(topLevelDomains); // [\"co\", \"uk\"]\n```\n\n### ⚠️ `\"\"` is a valid (but reserved) domain\n\nThe empty string `\"\"` represents the [DNS root](https://en.wikipedia.org/wiki/DNS_root_zone) and is considered to be valid. `parseResult.type` will be `ParseResultType.Reserved` in that case:\n\n```javascript\nconst { type, subDomains, domain, topLevelDomains } = parseDomain(\"\");\n\nconsole.log(type === ParseResultType.Reserved); // true\nconsole.log(subDomains); // []\nconsole.log(domain); // undefined\nconsole.log(topLevelDomains); // []\n```\n\n## API\n\n🧩 = JavaScript export<br>\n🧬 = TypeScript export\n\n<h3 id=\"api-js-parseDomain\">\n🧩 <code>export parseDomain(hostname: string | typeof <a href=\"#api-js-NO_HOSTNAME\">NO_HOSTNAME</a>, options?: <a href=\"#api-ts-ParseDomainOptions\">ParseDomainOptions</a>): <a href=\"#api-ts-ParseResult\">ParseResult</a></code>\n</h3>\n\nTakes a hostname (e.g. `\"www.example.com\"`) and returns a [`ParseResult`](#api-ts-ParseResult). The hostname must only contain basic latin letters, digits, hyphens and dots. International hostnames must be puny-encoded. Does not throw an error, even with invalid input.\n\n```javascript\nimport { parseDomain } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"www.example.com\");\n```\n\nUse `Validation.Lax` if you want to allow all characters:\n\n```javascript\nimport { parseDomain, Validation } from \"parse-domain\";\n\nconst parseResult = parseDomain(\"_jabber._tcp.gmail.com\", {\n  validation: Validation.Lax,\n});\n```\n\n<h3 id=\"api-js-fromUrl\">\n🧩 <code>export fromUrl(input: string): string | typeof <a href=\"#api-js-NO_HOSTNAME\">NO_HOSTNAME</a></code>\n</h3>\n\nTakes a URL-like string and tries to extract the hostname. Requires the global [`URL` constructor](https://developer.mozilla.org/en-US/docs/Web/API/URL) to be available on the platform. Returns the [`NO_HOSTNAME`](#api-js-NO_HOSTNAME) symbol if the input was not a string or the hostname could not be extracted. Take a look [at the test suite](/src/from-url.test.ts) for some examples. Does not throw an error, even with invalid input.\n\n<h3 id=\"api-js-NO_HOSTNAME\">\n🧩 <code>export NO_HOSTNAME: unique symbol</code>\n</h3>\n\n`NO_HOSTNAME` is a symbol that is returned by [`fromUrl`](#api-js-fromUrl) when it was not able to extract a hostname from the given string. When passed to [`parseDomain`](#api-js-parseDomain), it will always yield a [`ParseResultInvalid`](#api-ts-ParseResultInvalid).\n\n<h3 id=\"api-ts-ParseDomainOptions\">\n🧬 <code>export type ParseDomainOptions</code>\n</h3>\n\n```ts\nexport type ParseDomainOptions = {\n  /** If no validation is specified, Validation.Strict will be used. */\n  validation?: Validation;\n};\n```\n\n<h3 id=\"api-js-Validation\">\n🧩 <code>export Validation</code>\n</h3>\n\nAn object that holds all possible [Validation](#api-ts-Validation) `validation` values:\n\n```javascript\nexport const Validation = {\n  /**\n   * Allows any octets as labels but still restricts the length of labels and\n   * the overall domain.\n   *\n   * @see https://www.rfc-editor.org/rfc/rfc2181#section-11\n   */\n  Lax: \"LAX\",\n\n  /**\n   * Only allows ASCII letters, digits and hyphens (aka LDH), forbids hyphens at\n   * the beginning or end of a label and requires top-level domain names not to\n   * be all-numeric.\n   *\n   * This is the default if no validation is configured.\n   *\n   * @see https://datatracker.ietf.org/doc/html/rfc3696#section-2\n   */\n  Strict: \"STRICT\",\n};\n```\n\n<h3 id=\"api-ts-Validation\">\n🧬 <code>export Validation</code>\n</h3>\n\nThis type represents all possible `validation` values.\n\n<h3 id=\"api-ts-ParseResult\">\n🧬 <code>export ParseResult</code>\n</h3>\n\nA `ParseResult` is either a [`ParseResultInvalid`](#api-ts-ParseResultInvalid), [`ParseResultIp`](#api-ts-ParseResultIp), [`ParseResultReserved`](#api-ts-ParseResultReserved), [`ParseResultNotListed`](#api-ts-ParseResultNotListed) or [`ParseResultListed`](#api-ts-ParseResultListed).\n\nAll parse results have a `type` property that is either `\"INVALID\"`, `\"IP\"`,`\"RESERVED\"`,`\"NOT_LISTED\"`or`\"LISTED\"`. Use the exported [ParseResultType](#api-js-ParseResultType) to check for the type instead of checking against string literals.\n\nAll parse results also have a `hostname` property that provides access to the sanitized hostname that was passed to [`parseDomain`](#api-js-parseDomain).\n\n<h3 id=\"api-js-ParseResultType\">\n🧩 <code>export ParseResultType</code>\n</h3>\n\nAn object that holds all possible [ParseResult](#api-ts-ParseResult) `type` values:\n\n```javascript\nconst ParseResultType = {\n  Invalid: \"INVALID\",\n  Ip: \"IP\",\n  Reserved: \"RESERVED\",\n  NotListed: \"NOT_LISTED\",\n  Listed: \"LISTED\",\n};\n```\n\n<h3 id=\"api-ts-ParseResultType\">\n🧬 <code>export ParseResultType</code>\n</h3>\n\nThis type represents all possible [ParseResult](#api-ts-ParseResult) `type` values.\n\n<h3 id=\"api-ts-ParseResultInvalid\">\n🧬 <code>export ParseResultInvalid</code>\n</h3>\n\nDescribes the shape of the parse result that is returned when the given hostname does not adhere to [RFC 1034](https://tools.ietf.org/html/rfc1034):\n\n- The hostname is not a string\n- The hostname is longer than 253 characters\n- A domain label is shorter than 1 character\n- A domain label is longer than 63 characters\n- A domain label contains a character that is not a basic latin character, digit or hyphen\n\n```ts\ntype ParseResultInvalid = {\n  type: ParseResultType.INVALID;\n  hostname: string | typeof NO_HOSTNAME;\n  errors: Array<ValidationError>;\n};\n```\n\n<h3 id=\"api-ts-ValidationError\">\n🧬 <code>export ValidationError</code>\n</h3>\n\nDescribes the shape of a validation error as returned by [`parseDomain`](#api-js-parseDomain)\n\n```ts\ntype ValidationError = {\n  type: ValidationErrorType;\n  message: string;\n  column: number;\n};\n```\n\n<h3 id=\"api-js-ValidationErrorType\">\n🧩 <code>export ValidationErrorType</code>\n</h3>\n\nAn object that holds all possible [ValidationError](#api-ts-ValidationError) `type` values:\n\n```javascript\nconst ValidationErrorType = {\n  NoHostname: \"NO_HOSTNAME\",\n  DomainMaxLength: \"DOMAIN_MAX_LENGTH\",\n  LabelMinLength: \"LABEL_MIN_LENGTH\",\n  LabelMaxLength: \"LABEL_MAX_LENGTH\",\n  LabelInvalidCharacter: \"LABEL_INVALID_CHARACTER\",\n  LastLabelInvalid: \"LAST_LABEL_INVALID\",\n};\n```\n\n<h3 id=\"api-ts-ValidationErrorType\">\n🧬 <code>export ValidationErrorType</code>\n</h3>\n\nThis type represents all possible `type` values of a [ValidationError](#api-ts-ValidationError).\n\n<h3 id=\"api-ts-ParseResultIp\">\n🧬 <code>export ParseResultIp</code>\n</h3>\n\nThis type describes the shape of the parse result that is returned when the given hostname was an IPv4 or IPv6 address.\n\n```ts\ntype ParseResultIp = {\n  type: ParseResultType.Ip;\n  hostname: string;\n  ipVersion: 4 | 6;\n};\n```\n\nAccording to [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3.2.2), IPv6 addresses need to be surrounded by `[` and `]` in URLs. [`parseDomain`](#api-js-parseDomain) accepts both IPv6 address with and without square brackets:\n\n```js\n// Recognized as IPv4 address\nparseDomain(\"192.168.0.1\");\n// Both are recognized as proper IPv6 addresses\nparseDomain(\"::\");\nparseDomain(\"[::]\");\n```\n\n<h3 id=\"api-ts-ParseResultReserved\">\n🧬 <code>export ParseResultReserved</code>\n</h3>\n\nThis type describes the shape of the parse result that is returned when the given hostname\n\n- is the root domain (the empty string `\"\"`)\n- belongs to the top-level domain `localhost`, `local`, `example`, `invalid` or `test`\n\n```ts\ntype ParseResultReserved = {\n  type: ParseResultType.Reserved;\n  hostname: string;\n  labels: Array<string>;\n};\n```\n\n⚠️ Reserved IPs, such as `127.0.0.1`, will not be reported as reserved, but as <a href=\"#-export-parseresultip\">`ParseResultIp`</a>. See [#117](https://github.com/peerigon/parse-domain/issues/117).\n\n<h3 id=\"api-ts-ParseResultNotListed\">\n🧬 <code>export ParseResultNotListed</code>\n</h3>\n\nDescribes the shape of the parse result that is returned when the given hostname is valid and does not belong to a reserved top-level domain, but is not listed in the downloaded public suffix list.\n\n```ts\ntype ParseResultNotListed = {\n  type: ParseResultType.NotListed;\n  hostname: string;\n  labels: Array<string>;\n};\n```\n\n<h3 id=\"api-ts-ParseResultListed\">\n🧬 <code>export ParseResultListed</code>\n</h3>\n\nDescribes the shape of the parse result that is returned when the given hostname belongs to a top-level domain that is listed in the public suffix list.\n\n```ts\ntype ParseResultListed = {\n  type: ParseResultType.Listed;\n  hostname: string;\n  labels: Array<string>;\n  subDomains: Array<string>;\n  domain: string | undefined;\n  topLevelDomains: Array<string>;\n  icann: {\n    subDomains: Array<string>;\n    domain: string | undefined;\n    topLevelDomains: Array<string>;\n  };\n};\n```\n\n## License\n\nMIT\n\n## Sponsors\n\n[<img src=\"https://assets.peerigon.com/peerigon/logo/peerigon-logo-flat-spinat.png\" width=\"150\" />](https://peerigon.com)\n","publish_time":1772327253609,"_cnpm_publish_time":1772327253609,"dist-tags":{"beta":"3.0.0-beta.10","latest":"8.4.0"}}