psl
- Version 1.15.0
- Published
- 712 kB
- 1 dependency
- MIT license
Install
npm i psl
yarn add psl
pnpm add psl
Overview
Domain name parser based on the Public Suffix List
Index
Functions
function get
get: (domain: string) => string | null;
Get the base domain for full domain name
function isValid
isValid: (domain: string) => boolean;
Check whether the given domain belongs to a known public suffix
function parse
parse: (input: string) => ParsedDomain | ErrorResult<keyof errorCodes>;
Parse a domain name and return its components
Enums
enum errorCodes
const enum errorCodes { DOMAIN_TOO_SHORT = 'Domain name too short', DOMAIN_TOO_LONG = 'Domain name too long. It should be no more than 255 chars.', LABEL_STARTS_WITH_DASH = 'Domain name label can not start with a dash.', LABEL_ENDS_WITH_DASH = 'Domain name label can not end with a dash.', LABEL_TOO_LONG = 'Domain name label should be at most 63 chars long.', LABEL_TOO_SHORT = 'Domain name label should be at least 1 character long.', LABEL_INVALID_CHARS = 'Domain name label can only contain alphanumeric characters or dashes.',}
Error codes and descriptions for domain name parsing errors
member DOMAIN_TOO_LONG
DOMAIN_TOO_LONG = 'Domain name too long. It should be no more than 255 chars.'
member DOMAIN_TOO_SHORT
DOMAIN_TOO_SHORT = 'Domain name too short'
member LABEL_ENDS_WITH_DASH
LABEL_ENDS_WITH_DASH = 'Domain name label can not end with a dash.'
member LABEL_INVALID_CHARS
LABEL_INVALID_CHARS = 'Domain name label can only contain alphanumeric characters or dashes.'
member LABEL_STARTS_WITH_DASH
LABEL_STARTS_WITH_DASH = 'Domain name label can not start with a dash.'
member LABEL_TOO_LONG
LABEL_TOO_LONG = 'Domain name label should be at most 63 chars long.'
member LABEL_TOO_SHORT
LABEL_TOO_SHORT = 'Domain name label should be at least 1 character long.'
Type Aliases
type ErrorResult
type ErrorResult<T extends keyof errorCodes> = { input: string; error: { code: T; message: errorCodes[T]; };};
Result returned when a given domain name was not parsable (not exported)
type ParsedDomain
type ParsedDomain = { input: string; tld: string | null; sld: string | null; domain: string | null; subdomain: string | null; listed: boolean;};
Package Files (1)
Dependencies (1)
Dev Dependencies (10)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/psl
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/psl)
- HTML<a href="https://www.jsdocs.io/package/psl"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2428 ms. - Missing or incorrect documentation? Open an issue for this package.