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