@types/node 20.11.17 → 20.11.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +1 -1
- node/net.d.ts +5 -0
- node/package.json +2 -2
- node/ts4.8/net.d.ts +5 -0
- node/ts4.8/url.d.ts +59 -42
- node/url.d.ts +59 -42
node/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated: Thu,
|
|
11
|
+
* Last updated: Thu, 15 Feb 2024 16:36:06 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
node/net.d.ts
CHANGED
|
@@ -736,6 +736,11 @@ declare module "net" {
|
|
|
736
736
|
*/
|
|
737
737
|
check(address: SocketAddress): boolean;
|
|
738
738
|
check(address: string, type?: IPVersion): boolean;
|
|
739
|
+
/**
|
|
740
|
+
* The list of rules added to the blocklist.
|
|
741
|
+
* @since v15.0.0, v14.18.0
|
|
742
|
+
*/
|
|
743
|
+
rules: readonly string[];
|
|
739
744
|
}
|
|
740
745
|
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
|
741
746
|
timeout?: number | undefined;
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "20.11.
|
|
3
|
+
"version": "20.11.19",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -224,6 +224,6 @@
|
|
|
224
224
|
"dependencies": {
|
|
225
225
|
"undici-types": "~5.26.4"
|
|
226
226
|
},
|
|
227
|
-
"typesPublisherContentHash": "
|
|
227
|
+
"typesPublisherContentHash": "e5351494b040e4613bdef02794923b8199853018b6e70876b889958da925d350",
|
|
228
228
|
"typeScriptVersion": "4.6"
|
|
229
229
|
}
|
node/ts4.8/net.d.ts
CHANGED
|
@@ -736,6 +736,11 @@ declare module "net" {
|
|
|
736
736
|
*/
|
|
737
737
|
check(address: SocketAddress): boolean;
|
|
738
738
|
check(address: string, type?: IPVersion): boolean;
|
|
739
|
+
/**
|
|
740
|
+
* The list of rules added to the blocklist.
|
|
741
|
+
* @since v15.0.0, v14.18.0
|
|
742
|
+
*/
|
|
743
|
+
rules: readonly string[];
|
|
739
744
|
}
|
|
740
745
|
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
|
741
746
|
timeout?: number | undefined;
|
node/ts4.8/url.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ```js
|
|
6
6
|
* import url from 'node:url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.11.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module "url" {
|
|
11
11
|
import { Blob as NodeBlob } from "node:buffer";
|
|
@@ -74,7 +74,7 @@ declare module "url" {
|
|
|
74
74
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
|
75
75
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
|
76
76
|
/**
|
|
77
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
77
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
78
78
|
*
|
|
79
79
|
* ```js
|
|
80
80
|
* const url = require('node:url');
|
|
@@ -100,33 +100,33 @@ declare module "url" {
|
|
|
100
100
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
101
101
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
102
102
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
103
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
103
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
104
104
|
* * `urlObject.slashes` property is true;
|
|
105
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
106
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
107
|
-
* and appended to `result`followed by the literal string `@`.
|
|
105
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
106
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
107
|
+
* and appended to `result` followed by the literal string `@`.
|
|
108
108
|
* * If the `urlObject.host` property is `undefined` then:
|
|
109
109
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
110
110
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
111
111
|
* an `Error` is thrown.
|
|
112
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
112
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
113
113
|
* * The literal string `:` is appended to `result`, and
|
|
114
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
115
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
114
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
115
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
116
116
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
117
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
117
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
118
118
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
119
119
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
120
120
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
121
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
122
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
121
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
122
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
123
123
|
* * Otherwise, if `urlObject.search` is a string:
|
|
124
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
124
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
125
125
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
126
126
|
* * The value of `urlObject.search` is appended to `result`.
|
|
127
127
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
128
128
|
* * If the `urlObject.hash` property is a string:
|
|
129
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
129
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
130
130
|
* character, the literal string `#` is appended to `result`.
|
|
131
131
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
132
132
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -138,18 +138,18 @@ declare module "url" {
|
|
|
138
138
|
*/
|
|
139
139
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
140
140
|
/**
|
|
141
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
141
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
142
142
|
*
|
|
143
143
|
* ```js
|
|
144
|
-
* const url = require('url');
|
|
144
|
+
* const url = require('node:url');
|
|
145
145
|
* url.format({
|
|
146
146
|
* protocol: 'https',
|
|
147
147
|
* hostname: 'example.com',
|
|
148
148
|
* pathname: '/some/path',
|
|
149
149
|
* query: {
|
|
150
150
|
* page: 1,
|
|
151
|
-
* format: 'json'
|
|
152
|
-
* }
|
|
151
|
+
* format: 'json',
|
|
152
|
+
* },
|
|
153
153
|
* });
|
|
154
154
|
*
|
|
155
155
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -164,33 +164,33 @@ declare module "url" {
|
|
|
164
164
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
165
165
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
166
166
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
167
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
167
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
168
168
|
* * `urlObject.slashes` property is true;
|
|
169
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
170
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
171
|
-
* and appended to `result`followed by the literal string `@`.
|
|
169
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
170
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
171
|
+
* and appended to `result` followed by the literal string `@`.
|
|
172
172
|
* * If the `urlObject.host` property is `undefined` then:
|
|
173
173
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
174
174
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
175
175
|
* an `Error` is thrown.
|
|
176
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
176
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
177
177
|
* * The literal string `:` is appended to `result`, and
|
|
178
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
179
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
178
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
179
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
180
180
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
181
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
181
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
182
182
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
183
183
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
184
184
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
185
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
186
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
185
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
186
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
187
187
|
* * Otherwise, if `urlObject.search` is a string:
|
|
188
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
188
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
189
189
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
190
190
|
* * The value of `urlObject.search` is appended to `result`.
|
|
191
191
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
192
192
|
* * If the `urlObject.hash` property is a string:
|
|
193
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
193
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
194
194
|
* character, the literal string `#` is appended to `result`.
|
|
195
195
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
196
196
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -345,9 +345,26 @@ declare module "url" {
|
|
|
345
345
|
*/
|
|
346
346
|
function urlToHttpOptions(url: URL): ClientRequestArgs;
|
|
347
347
|
interface URLFormatOptions {
|
|
348
|
+
/**
|
|
349
|
+
* `true` if the serialized URL string should include the username and password, `false` otherwise.
|
|
350
|
+
* @default true
|
|
351
|
+
*/
|
|
348
352
|
auth?: boolean | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* `true` if the serialized URL string should include the fragment, `false` otherwise.
|
|
355
|
+
* @default true
|
|
356
|
+
*/
|
|
349
357
|
fragment?: boolean | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* `true` if the serialized URL string should include the search query, `false` otherwise.
|
|
360
|
+
* @default true
|
|
361
|
+
*/
|
|
350
362
|
search?: boolean | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
|
|
365
|
+
* being Punycode encoded.
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
351
368
|
unicode?: boolean | undefined;
|
|
352
369
|
}
|
|
353
370
|
/**
|
|
@@ -357,7 +374,7 @@ declare module "url" {
|
|
|
357
374
|
*
|
|
358
375
|
* In accordance with browser conventions, all properties of `URL` objects
|
|
359
376
|
* are implemented as getters and setters on the class prototype, rather than as
|
|
360
|
-
* data properties on the object itself. Thus, unlike `legacy urlObject`
|
|
377
|
+
* data properties on the object itself. Thus, unlike `legacy urlObject`s,
|
|
361
378
|
* using the `delete` keyword on any properties of `URL` objects (e.g. `delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still
|
|
362
379
|
* return `true`.
|
|
363
380
|
* @since v7.0.0, v6.13.0
|
|
@@ -381,7 +398,7 @@ declare module "url" {
|
|
|
381
398
|
* console.log(otherBlob.size);
|
|
382
399
|
* ```
|
|
383
400
|
*
|
|
384
|
-
* The data stored by the registered `Blob` will be retained in memory until`URL.revokeObjectURL()` is called to remove it.
|
|
401
|
+
* The data stored by the registered `Blob` will be retained in memory until `URL.revokeObjectURL()` is called to remove it.
|
|
385
402
|
*
|
|
386
403
|
* `Blob` objects are registered within the current thread. If using Worker
|
|
387
404
|
* Threads, `Blob` objects registered within one Worker will not be available
|
|
@@ -397,7 +414,7 @@ declare module "url" {
|
|
|
397
414
|
* @experimental
|
|
398
415
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
399
416
|
*/
|
|
400
|
-
static revokeObjectURL(
|
|
417
|
+
static revokeObjectURL(id: string): void;
|
|
401
418
|
/**
|
|
402
419
|
* Checks if an `input` relative to the `base` can be parsed to a `URL`.
|
|
403
420
|
*
|
|
@@ -412,7 +429,7 @@ declare module "url" {
|
|
|
412
429
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
|
413
430
|
*/
|
|
414
431
|
static canParse(input: string, base?: string): boolean;
|
|
415
|
-
constructor(input: string, base?: string | URL);
|
|
432
|
+
constructor(input: string | { toString: () => string }, base?: string | URL);
|
|
416
433
|
/**
|
|
417
434
|
* Gets and sets the fragment portion of the URL.
|
|
418
435
|
*
|
|
@@ -541,14 +558,14 @@ declare module "url" {
|
|
|
541
558
|
* // Prints https://example.org/abcdef?123
|
|
542
559
|
* ```
|
|
543
560
|
*
|
|
544
|
-
* Invalid URL characters included in the value assigned to the `pathname`property are `percent-encoded`. The selection of which characters
|
|
561
|
+
* Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
|
|
545
562
|
* to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
546
563
|
*/
|
|
547
564
|
pathname: string;
|
|
548
565
|
/**
|
|
549
566
|
* Gets and sets the port portion of the URL.
|
|
550
567
|
*
|
|
551
|
-
* The port value may be a number or a string containing a number in the range`0` to `65535` (inclusive). Setting the value to the default port of the`URL` objects given `protocol` will
|
|
568
|
+
* The port value may be a number or a string containing a number in the range `0` to `65535` (inclusive). Setting the value to the default port of the `URL` objects given `protocol` will
|
|
552
569
|
* result in the `port` value becoming
|
|
553
570
|
* the empty string (`''`).
|
|
554
571
|
*
|
|
@@ -688,7 +705,7 @@ declare module "url" {
|
|
|
688
705
|
* // Prints https://123:xyz@example.com/
|
|
689
706
|
* ```
|
|
690
707
|
*
|
|
691
|
-
* Any invalid URL characters appearing in the value assigned the `username`property will be `percent-encoded`. The selection of which
|
|
708
|
+
* Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
|
|
692
709
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
693
710
|
*/
|
|
694
711
|
username: string;
|
|
@@ -716,7 +733,7 @@ declare module "url" {
|
|
|
716
733
|
toJSON(): string;
|
|
717
734
|
}
|
|
718
735
|
/**
|
|
719
|
-
* The `URLSearchParams` API provides read and write access to the query of a`URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
736
|
+
* The `URLSearchParams` API provides read and write access to the query of a `URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
720
737
|
* four following constructors.
|
|
721
738
|
* The `URLSearchParams` class is also available on the global object.
|
|
722
739
|
*
|
|
@@ -774,14 +791,14 @@ declare module "url" {
|
|
|
774
791
|
append(name: string, value: string): void;
|
|
775
792
|
/**
|
|
776
793
|
* If `value` is provided, removes all name-value pairs
|
|
777
|
-
* where name is `name` and value is `value
|
|
794
|
+
* where name is `name` and value is `value`.
|
|
778
795
|
*
|
|
779
796
|
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
780
797
|
*/
|
|
781
798
|
delete(name: string, value?: string): void;
|
|
782
799
|
/**
|
|
783
800
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
784
|
-
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`.
|
|
801
|
+
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array` is the `name`, the second item of the `Array` is the `value`.
|
|
785
802
|
*
|
|
786
803
|
* Alias for `urlSearchParams[@@iterator]()`.
|
|
787
804
|
*/
|
|
@@ -802,7 +819,7 @@ declare module "url" {
|
|
|
802
819
|
* @param thisArg To be used as `this` value for when `fn` is called
|
|
803
820
|
*/
|
|
804
821
|
forEach<TThis = this>(
|
|
805
|
-
|
|
822
|
+
fn: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void,
|
|
806
823
|
thisArg?: TThis,
|
|
807
824
|
): void;
|
|
808
825
|
/**
|
|
@@ -817,7 +834,7 @@ declare module "url" {
|
|
|
817
834
|
*/
|
|
818
835
|
getAll(name: string): string[];
|
|
819
836
|
/**
|
|
820
|
-
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
837
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
|
821
838
|
*
|
|
822
839
|
* If `value` is provided, returns `true` when name-value pair with
|
|
823
840
|
* same `name` and `value` exists.
|
node/url.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ```js
|
|
6
6
|
* import url from 'node:url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.11.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module "url" {
|
|
11
11
|
import { Blob as NodeBlob } from "node:buffer";
|
|
@@ -74,7 +74,7 @@ declare module "url" {
|
|
|
74
74
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
|
75
75
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
|
76
76
|
/**
|
|
77
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
77
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
78
78
|
*
|
|
79
79
|
* ```js
|
|
80
80
|
* const url = require('node:url');
|
|
@@ -100,33 +100,33 @@ declare module "url" {
|
|
|
100
100
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
101
101
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
102
102
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
103
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
103
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
104
104
|
* * `urlObject.slashes` property is true;
|
|
105
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
106
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
107
|
-
* and appended to `result`followed by the literal string `@`.
|
|
105
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
106
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
107
|
+
* and appended to `result` followed by the literal string `@`.
|
|
108
108
|
* * If the `urlObject.host` property is `undefined` then:
|
|
109
109
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
110
110
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
111
111
|
* an `Error` is thrown.
|
|
112
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
112
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
113
113
|
* * The literal string `:` is appended to `result`, and
|
|
114
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
115
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
114
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
115
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
116
116
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
117
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
117
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
118
118
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
119
119
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
120
120
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
121
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
122
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
121
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
122
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
123
123
|
* * Otherwise, if `urlObject.search` is a string:
|
|
124
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
124
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
125
125
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
126
126
|
* * The value of `urlObject.search` is appended to `result`.
|
|
127
127
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
128
128
|
* * If the `urlObject.hash` property is a string:
|
|
129
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
129
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
130
130
|
* character, the literal string `#` is appended to `result`.
|
|
131
131
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
132
132
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -138,18 +138,18 @@ declare module "url" {
|
|
|
138
138
|
*/
|
|
139
139
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
140
140
|
/**
|
|
141
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
141
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
142
142
|
*
|
|
143
143
|
* ```js
|
|
144
|
-
* const url = require('url');
|
|
144
|
+
* const url = require('node:url');
|
|
145
145
|
* url.format({
|
|
146
146
|
* protocol: 'https',
|
|
147
147
|
* hostname: 'example.com',
|
|
148
148
|
* pathname: '/some/path',
|
|
149
149
|
* query: {
|
|
150
150
|
* page: 1,
|
|
151
|
-
* format: 'json'
|
|
152
|
-
* }
|
|
151
|
+
* format: 'json',
|
|
152
|
+
* },
|
|
153
153
|
* });
|
|
154
154
|
*
|
|
155
155
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -164,33 +164,33 @@ declare module "url" {
|
|
|
164
164
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
165
165
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
166
166
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
167
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
167
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
168
168
|
* * `urlObject.slashes` property is true;
|
|
169
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
170
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
171
|
-
* and appended to `result`followed by the literal string `@`.
|
|
169
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
170
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
171
|
+
* and appended to `result` followed by the literal string `@`.
|
|
172
172
|
* * If the `urlObject.host` property is `undefined` then:
|
|
173
173
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
174
174
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
175
175
|
* an `Error` is thrown.
|
|
176
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
176
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
177
177
|
* * The literal string `:` is appended to `result`, and
|
|
178
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
179
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
178
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
179
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
180
180
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
181
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
181
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
182
182
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
183
183
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
184
184
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
185
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
186
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
185
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
186
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
187
187
|
* * Otherwise, if `urlObject.search` is a string:
|
|
188
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
188
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
189
189
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
190
190
|
* * The value of `urlObject.search` is appended to `result`.
|
|
191
191
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
192
192
|
* * If the `urlObject.hash` property is a string:
|
|
193
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
193
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
194
194
|
* character, the literal string `#` is appended to `result`.
|
|
195
195
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
196
196
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -345,9 +345,26 @@ declare module "url" {
|
|
|
345
345
|
*/
|
|
346
346
|
function urlToHttpOptions(url: URL): ClientRequestArgs;
|
|
347
347
|
interface URLFormatOptions {
|
|
348
|
+
/**
|
|
349
|
+
* `true` if the serialized URL string should include the username and password, `false` otherwise.
|
|
350
|
+
* @default true
|
|
351
|
+
*/
|
|
348
352
|
auth?: boolean | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* `true` if the serialized URL string should include the fragment, `false` otherwise.
|
|
355
|
+
* @default true
|
|
356
|
+
*/
|
|
349
357
|
fragment?: boolean | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* `true` if the serialized URL string should include the search query, `false` otherwise.
|
|
360
|
+
* @default true
|
|
361
|
+
*/
|
|
350
362
|
search?: boolean | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
|
|
365
|
+
* being Punycode encoded.
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
351
368
|
unicode?: boolean | undefined;
|
|
352
369
|
}
|
|
353
370
|
/**
|
|
@@ -357,7 +374,7 @@ declare module "url" {
|
|
|
357
374
|
*
|
|
358
375
|
* In accordance with browser conventions, all properties of `URL` objects
|
|
359
376
|
* are implemented as getters and setters on the class prototype, rather than as
|
|
360
|
-
* data properties on the object itself. Thus, unlike `legacy urlObject`
|
|
377
|
+
* data properties on the object itself. Thus, unlike `legacy urlObject`s,
|
|
361
378
|
* using the `delete` keyword on any properties of `URL` objects (e.g. `delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still
|
|
362
379
|
* return `true`.
|
|
363
380
|
* @since v7.0.0, v6.13.0
|
|
@@ -381,7 +398,7 @@ declare module "url" {
|
|
|
381
398
|
* console.log(otherBlob.size);
|
|
382
399
|
* ```
|
|
383
400
|
*
|
|
384
|
-
* The data stored by the registered `Blob` will be retained in memory until`URL.revokeObjectURL()` is called to remove it.
|
|
401
|
+
* The data stored by the registered `Blob` will be retained in memory until `URL.revokeObjectURL()` is called to remove it.
|
|
385
402
|
*
|
|
386
403
|
* `Blob` objects are registered within the current thread. If using Worker
|
|
387
404
|
* Threads, `Blob` objects registered within one Worker will not be available
|
|
@@ -397,7 +414,7 @@ declare module "url" {
|
|
|
397
414
|
* @experimental
|
|
398
415
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
399
416
|
*/
|
|
400
|
-
static revokeObjectURL(
|
|
417
|
+
static revokeObjectURL(id: string): void;
|
|
401
418
|
/**
|
|
402
419
|
* Checks if an `input` relative to the `base` can be parsed to a `URL`.
|
|
403
420
|
*
|
|
@@ -412,7 +429,7 @@ declare module "url" {
|
|
|
412
429
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
|
413
430
|
*/
|
|
414
431
|
static canParse(input: string, base?: string): boolean;
|
|
415
|
-
constructor(input: string, base?: string | URL);
|
|
432
|
+
constructor(input: string | { toString: () => string }, base?: string | URL);
|
|
416
433
|
/**
|
|
417
434
|
* Gets and sets the fragment portion of the URL.
|
|
418
435
|
*
|
|
@@ -541,14 +558,14 @@ declare module "url" {
|
|
|
541
558
|
* // Prints https://example.org/abcdef?123
|
|
542
559
|
* ```
|
|
543
560
|
*
|
|
544
|
-
* Invalid URL characters included in the value assigned to the `pathname`property are `percent-encoded`. The selection of which characters
|
|
561
|
+
* Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
|
|
545
562
|
* to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
546
563
|
*/
|
|
547
564
|
pathname: string;
|
|
548
565
|
/**
|
|
549
566
|
* Gets and sets the port portion of the URL.
|
|
550
567
|
*
|
|
551
|
-
* The port value may be a number or a string containing a number in the range`0` to `65535` (inclusive). Setting the value to the default port of the`URL` objects given `protocol` will
|
|
568
|
+
* The port value may be a number or a string containing a number in the range `0` to `65535` (inclusive). Setting the value to the default port of the `URL` objects given `protocol` will
|
|
552
569
|
* result in the `port` value becoming
|
|
553
570
|
* the empty string (`''`).
|
|
554
571
|
*
|
|
@@ -688,7 +705,7 @@ declare module "url" {
|
|
|
688
705
|
* // Prints https://123:xyz@example.com/
|
|
689
706
|
* ```
|
|
690
707
|
*
|
|
691
|
-
* Any invalid URL characters appearing in the value assigned the `username`property will be `percent-encoded`. The selection of which
|
|
708
|
+
* Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
|
|
692
709
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
693
710
|
*/
|
|
694
711
|
username: string;
|
|
@@ -716,7 +733,7 @@ declare module "url" {
|
|
|
716
733
|
toJSON(): string;
|
|
717
734
|
}
|
|
718
735
|
/**
|
|
719
|
-
* The `URLSearchParams` API provides read and write access to the query of a`URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
736
|
+
* The `URLSearchParams` API provides read and write access to the query of a `URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
720
737
|
* four following constructors.
|
|
721
738
|
* The `URLSearchParams` class is also available on the global object.
|
|
722
739
|
*
|
|
@@ -774,14 +791,14 @@ declare module "url" {
|
|
|
774
791
|
append(name: string, value: string): void;
|
|
775
792
|
/**
|
|
776
793
|
* If `value` is provided, removes all name-value pairs
|
|
777
|
-
* where name is `name` and value is `value
|
|
794
|
+
* where name is `name` and value is `value`.
|
|
778
795
|
*
|
|
779
796
|
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
780
797
|
*/
|
|
781
798
|
delete(name: string, value?: string): void;
|
|
782
799
|
/**
|
|
783
800
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
784
|
-
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`.
|
|
801
|
+
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array` is the `name`, the second item of the `Array` is the `value`.
|
|
785
802
|
*
|
|
786
803
|
* Alias for `urlSearchParams[@@iterator]()`.
|
|
787
804
|
*/
|
|
@@ -802,7 +819,7 @@ declare module "url" {
|
|
|
802
819
|
* @param thisArg To be used as `this` value for when `fn` is called
|
|
803
820
|
*/
|
|
804
821
|
forEach<TThis = this>(
|
|
805
|
-
|
|
822
|
+
fn: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void,
|
|
806
823
|
thisArg?: TThis,
|
|
807
824
|
): void;
|
|
808
825
|
/**
|
|
@@ -817,7 +834,7 @@ declare module "url" {
|
|
|
817
834
|
*/
|
|
818
835
|
getAll(name: string): string[];
|
|
819
836
|
/**
|
|
820
|
-
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
837
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
|
821
838
|
*
|
|
822
839
|
* If `value` is provided, returns `true` when name-value pair with
|
|
823
840
|
* same `name` and `value` exists.
|