UNPKG

1.05 kBTypeScriptView Raw
1// Type definitions for psl 1.1
2// Project: https://github.com/wrangr/psl#readme
3// Definitions by: BendingBender <https://github.com/BendingBender>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.1
6
7export as namespace psl;
8
9export function parse(domain: string): ParsedDomain | ParseError;
10
11export function get(domain: null | undefined): null;
12export function get(domain: string): string | null;
13
14export function isValid(domain: string): boolean;
15
16export interface ParsedDomain {
17 tld: string | null;
18 sld: string | null;
19 domain: string | null;
20 subdomain: string | null;
21 listed: boolean;
22 input: string;
23 error: undefined;
24}
25
26export interface ParseError {
27 input: string;
28 error: {
29 code:
30 | 'DOMAIN_TOO_SHORT'
31 | 'DOMAIN_TOO_LONG'
32 | 'LABEL_STARTS_WITH_DASH'
33 | 'LABEL_ENDS_WITH_DASH'
34 | 'LABEL_TOO_LONG'
35 | 'LABEL_TOO_SHORT'
36 | 'LABEL_INVALID_CHARS';
37 message: string;
38 };
39}