1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export interface URLRecord {
|
12 | scheme: string;
|
13 | username: string;
|
14 | password: string;
|
15 | host: string | number | IPv6Address | null;
|
16 | port: number | null;
|
17 | path: string[];
|
18 | query: string | null;
|
19 | fragment: string | null;
|
20 | cannotBeABaseURL?: boolean | undefined;
|
21 | }
|
22 |
|
23 |
|
24 | export type IPv6Address = [number, number, number, number, number, number, number, number];
|
25 |
|
26 |
|
27 | export class URL {
|
28 | constructor(url: string, base?: string | URL);
|
29 |
|
30 | get href(): string;
|
31 | set href(V: string);
|
32 |
|
33 | get origin(): string;
|
34 |
|
35 | get protocol(): string;
|
36 | set protocol(V: string);
|
37 |
|
38 | get username(): string;
|
39 | set username(V: string);
|
40 |
|
41 | get password(): string;
|
42 | set password(V: string);
|
43 |
|
44 | get host(): string;
|
45 | set host(V: string);
|
46 |
|
47 | get hostname(): string;
|
48 | set hostname(V: string);
|
49 |
|
50 | get port(): string;
|
51 | set port(V: string);
|
52 |
|
53 | get pathname(): string;
|
54 | set pathname(V: string);
|
55 |
|
56 | get search(): string;
|
57 | set search(V: string);
|
58 |
|
59 | get searchParams(): URLSearchParams;
|
60 |
|
61 | get hash(): string;
|
62 | set hash(V: string);
|
63 |
|
64 | toJSON(): string;
|
65 |
|
66 | readonly [Symbol.toStringTag]: "URL";
|
67 | }
|
68 |
|
69 | /** https://url.spec.whatwg.org/#interface-urlsearchparams */
|
70 | export class URLSearchParams {
|
71 | constructor(
|
72 | init?:
|
73 | | ReadonlyArray<readonly [name: string, value: string]>
|
74 | | Iterable<readonly [name: string, value: string]>
|
75 | | { readonly [name: string]: string }
|
76 | | string,
|
77 | );
|
78 |
|
79 | append(name: string, value: string): void;
|
80 | delete(name: string): void;
|
81 | get(name: string): string | null;
|
82 | getAll(name: string): string[];
|
83 | has(name: string): boolean;
|
84 | set(name: string, value: string): void;
|
85 | sort(): void;
|
86 |
|
87 | keys(): IterableIterator<string>;
|
88 | values(): IterableIterator<string>;
|
89 | entries(): IterableIterator<[name: string, value: string]>;
|
90 | forEach<THIS_ARG = void>(
|
91 | callback: (this: THIS_ARG, value: string, name: string, searchParams: this) => void,
|
92 | thisArg?: THIS_ARG,
|
93 | ): void;
|
94 |
|
95 | readonly [Symbol.toStringTag]: "URLSearchParams";
|
96 | [Symbol.iterator](): IterableIterator<[name: string, value: string]>;
|
97 | }
|
98 |
|
99 | /** https://url.spec.whatwg.org/#concept-url-parser */
|
100 | export function parseURL(
|
101 | input: string,
|
102 | options?: { readonly baseURL?: string | undefined; readonly encodingOverride?: string | undefined },
|
103 | ): URLRecord | null;
|
104 |
|
105 | /** https://url.spec.whatwg.org/#concept-basic-url-parser */
|
106 | export function basicURLParse(
|
107 | input: string,
|
108 | options?: {
|
109 | baseURL?: string | undefined;
|
110 | encodingOverride?: string | undefined;
|
111 | url?: URLRecord | undefined;
|
112 | stateOverride?: StateOverride | undefined;
|
113 | },
|
114 | ): URLRecord | null;
|
115 |
|
116 | /** https://url.spec.whatwg.org/#scheme-start-state */
|
117 | export type StateOverride =
|
118 | | "scheme start"
|
119 | | "scheme"
|
120 | | "no scheme"
|
121 | | "special relative or authority"
|
122 | | "path or authority"
|
123 | | "relative"
|
124 | | "relative slash"
|
125 | | "special authority slashes"
|
126 | | "special authority ignore slashes"
|
127 | | "authority"
|
128 | | "host"
|
129 | | "hostname"
|
130 | | "port"
|
131 | | "file"
|
132 | | "file slash"
|
133 | | "file host"
|
134 | | "path start"
|
135 | | "path"
|
136 | | "cannot-be-a-base-URL path"
|
137 | | "query"
|
138 | | "fragment";
|
139 |
|
140 | /** https://url.spec.whatwg.org/#concept-url-serializer */
|
141 | export function serializeURL(urlRecord: URLRecord, excludeFragment?: boolean): string;
|
142 |
|
143 | /** https://url.spec.whatwg.org/#concept-host-serializer */
|
144 | export function serializeHost(host: string | number | IPv6Address): string;
|
145 |
|
146 | /** https://url.spec.whatwg.org/#serialize-an-integer */
|
147 | export function serializeInteger(number: number): string;
|
148 |
|
149 | /** https://html.spec.whatwg.org#ascii-serialisation-of-an-origin */
|
150 | export function serializeURLOrigin(urlRecord: URLRecord): string;
|
151 |
|
152 | /** https://url.spec.whatwg.org/#set-the-username */
|
153 | export function setTheUsername(urlRecord: URLRecord, username: string): void;
|
154 |
|
155 | /** https://url.spec.whatwg.org/#set-the-password */
|
156 | export function setThePassword(urlRecord: URLRecord, password: string): void;
|
157 |
|
158 | /** https://url.spec.whatwg.org/#cannot-have-a-username-password-port */
|
159 | export function cannotHaveAUsernamePasswordPort(urlRecord: URLRecord): boolean;
|
160 |
|
161 | /** https://url.spec.whatwg.org/#percent-decode */
|
162 | export function percentDecode(buffer: Extract<NodeJS.TypedArray, ArrayLike<number>>): Buffer;
|