1 | declare module 'url' {
|
2 | import { ClientRequestArgs } from 'node:http';
|
3 | import { ParsedUrlQuery, ParsedUrlQueryInput } from 'querystring';
|
4 |
|
5 |
|
6 | interface UrlObject {
|
7 | auth?: string | null | undefined;
|
8 | hash?: string | null | undefined;
|
9 | host?: string | null | undefined;
|
10 | hostname?: string | null | undefined;
|
11 | href?: string | null | undefined;
|
12 | pathname?: string | null | undefined;
|
13 | protocol?: string | null | undefined;
|
14 | search?: string | null | undefined;
|
15 | slashes?: boolean | null | undefined;
|
16 | port?: string | number | null | undefined;
|
17 | query?: string | null | ParsedUrlQueryInput | undefined;
|
18 | }
|
19 |
|
20 |
|
21 | interface Url {
|
22 | auth: string | null;
|
23 | hash: string | null;
|
24 | host: string | null;
|
25 | hostname: string | null;
|
26 | href: string;
|
27 | path: string | null;
|
28 | pathname: string | null;
|
29 | protocol: string | null;
|
30 | search: string | null;
|
31 | slashes: boolean | null;
|
32 | port: string | null;
|
33 | query: string | null | ParsedUrlQuery;
|
34 | }
|
35 |
|
36 | interface UrlWithParsedQuery extends Url {
|
37 | query: ParsedUrlQuery;
|
38 | }
|
39 |
|
40 | interface UrlWithStringQuery extends Url {
|
41 | query: string | null;
|
42 | }
|
43 |
|
44 |
|
45 | function parse(urlStr: string): UrlWithStringQuery;
|
46 |
|
47 | function parse(urlStr: string, parseQueryString: false | undefined, slashesDenoteHost?: boolean): UrlWithStringQuery;
|
48 |
|
49 | function parse(urlStr: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
50 |
|
51 | function parse(urlStr: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
52 |
|
53 | function format(URL: URL, options?: URLFormatOptions): string;
|
54 |
|
55 | function format(urlObject: UrlObject | string): string;
|
56 |
|
57 | function resolve(from: string, to: string): string;
|
58 |
|
59 | function domainToASCII(domain: string): string;
|
60 | function domainToUnicode(domain: string): string;
|
61 |
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 | function fileURLToPath(url: string | URL): string;
|
68 |
|
69 | |
70 |
|
71 |
|
72 |
|
73 |
|
74 | function pathToFileURL(url: string): URL;
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | function urlToHttpOptions(url: URL): ClientRequestArgs;
|
102 |
|
103 | interface URLFormatOptions {
|
104 | auth?: boolean | undefined;
|
105 | fragment?: boolean | undefined;
|
106 | search?: boolean | undefined;
|
107 | unicode?: boolean | undefined;
|
108 | }
|
109 |
|
110 | class URL {
|
111 | constructor(input: string, base?: string | URL);
|
112 | hash: string;
|
113 | host: string;
|
114 | hostname: string;
|
115 | href: string;
|
116 | readonly origin: string;
|
117 | password: string;
|
118 | pathname: string;
|
119 | port: string;
|
120 | protocol: string;
|
121 | search: string;
|
122 | readonly searchParams: URLSearchParams;
|
123 | username: string;
|
124 | toString(): string;
|
125 | toJSON(): string;
|
126 | }
|
127 |
|
128 | class URLSearchParams implements Iterable<[string, string]> {
|
129 | constructor(init?: URLSearchParams | string | Record<string, string | ReadonlyArray<string>> | Iterable<[string, string]> | ReadonlyArray<[string, string]>);
|
130 | readonly size: number;
|
131 | append(name: string, value: string): void;
|
132 | delete(name: string): void;
|
133 | entries(): IterableIterator<[string, string]>;
|
134 | forEach(callback: (value: string, name: string, searchParams: URLSearchParams) => void, thisArg?: any): void;
|
135 | get(name: string): string | null;
|
136 | getAll(name: string): string[];
|
137 | has(name: string): boolean;
|
138 | keys(): IterableIterator<string>;
|
139 | set(name: string, value: string): void;
|
140 | sort(): void;
|
141 | toString(): string;
|
142 | values(): IterableIterator<string>;
|
143 | [Symbol.iterator](): IterableIterator<[string, string]>;
|
144 | }
|
145 |
|
146 | import { URL as _URL, URLSearchParams as _URLSearchParams } from 'url';
|
147 | global {
|
148 | interface URLSearchParams extends _URLSearchParams {}
|
149 | interface URL extends _URL {}
|
150 | interface Global {
|
151 | URL: typeof _URL;
|
152 | URLSearchParams: typeof _URLSearchParams;
|
153 | }
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 | var URL:
|
160 |
|
161 | typeof globalThis extends { onmessage: any, URL: infer URL }
|
162 | ? URL
|
163 | : typeof _URL;
|
164 | |
165 |
|
166 |
|
167 |
|
168 |
|
169 | var URLSearchParams:
|
170 |
|
171 | typeof globalThis extends { onmessage: any, URLSearchParams: infer URLSearchParams }
|
172 | ? URLSearchParams
|
173 | : typeof _URLSearchParams;
|
174 | }
|
175 | }
|
176 | declare module 'node:url' {
|
177 | export * from 'url';
|
178 | }
|