@whatwg-node/node-fetch 0.7.6-alpha-20241227133443-491da4e9c34920079611c68a2aa3b9613ac93caa → 0.7.6-alpha-20250102090222-b3df3a37f8f87ca84ae46c16473ebd0dcf369462
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/URL.js +3 -70
- package/cjs/URLSearchParams.js +1 -117
- package/esm/URL.js +3 -69
- package/esm/URLSearchParams.js +1 -115
- package/package.json +1 -3
- package/typings/URL.d.cts +3 -16
- package/typings/URL.d.ts +3 -16
- package/typings/URLSearchParams.d.cts +4 -21
- package/typings/URLSearchParams.d.ts +4 -21
package/cjs/URL.js
CHANGED
@@ -1,83 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PonyfillURL = void 0;
|
4
|
-
const tslib_1 = require("tslib");
|
5
4
|
const buffer_1 = require("buffer");
|
6
5
|
const crypto_1 = require("crypto");
|
7
|
-
|
8
|
-
|
9
|
-
const URLSearchParams_js_1 = require("./URLSearchParams.js");
|
10
|
-
fast_url_parser_1.default.queryString = fast_querystring_1.default;
|
11
|
-
const IPV6_REGEX = /^(?:(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,1}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})?::)(?:\/(?:0?0?[0-9]|0?[1-9][0-9]|1[01][0-9]|12[0-8]))?)$/;
|
12
|
-
class PonyfillURL extends fast_url_parser_1.default {
|
13
|
-
constructor(url, base) {
|
14
|
-
super();
|
15
|
-
if (url.startsWith('data:')) {
|
16
|
-
this.protocol = 'data:';
|
17
|
-
this.pathname = url.slice('data:'.length);
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
this.parse(url, false);
|
21
|
-
// `fast-url-parser` incorrectly removes `[IPV6]` in the hostname
|
22
|
-
// Then `hostname` doesn't include `[` and `]` for IPv6 URLs
|
23
|
-
// This breaks implementations that rely on `hostname` to include `[` and `]`
|
24
|
-
if ((url.startsWith('http://[') || url.startsWith('https://[')) &&
|
25
|
-
IPV6_REGEX.test(this.hostname)) {
|
26
|
-
this.hostname = `[${this.hostname}]`;
|
27
|
-
}
|
28
|
-
// `fast-url-parser` incorrectly handle URLs with ports without pathnames correctly like
|
29
|
-
// `http://localhost:8080?foo=bar` -> `http://localhost/:8080?foo=bar`
|
30
|
-
if (url.includes(`${this.hostname}:`) && !this.port && this.pathname.startsWith('/:')) {
|
31
|
-
this.port = this.pathname.slice(2);
|
32
|
-
this.pathname = '/';
|
33
|
-
this.host = `${this.hostname}:${this.port}`;
|
34
|
-
}
|
35
|
-
if (base) {
|
36
|
-
const baseParsed = typeof base === 'string' ? new PonyfillURL(base) : base;
|
37
|
-
this.protocol ||= baseParsed.protocol;
|
38
|
-
this.host ||= baseParsed.host;
|
39
|
-
this.pathname ||= baseParsed.pathname;
|
40
|
-
this.port ||= baseParsed.port;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
get origin() {
|
44
|
-
return `${this.protocol}//${this.hostname}${this.port ? `:${this.port}` : ''}`;
|
45
|
-
}
|
46
|
-
_searchParams;
|
47
|
-
get searchParams() {
|
48
|
-
if (!this._searchParams) {
|
49
|
-
this._searchParams = new URLSearchParams_js_1.PonyfillURLSearchParams(this.query);
|
50
|
-
}
|
51
|
-
return this._searchParams;
|
52
|
-
}
|
53
|
-
get username() {
|
54
|
-
return this.auth?.split(':')[0] || '';
|
55
|
-
}
|
56
|
-
set username(value) {
|
57
|
-
this.auth = `${value}:${this.password}`;
|
58
|
-
}
|
59
|
-
get password() {
|
60
|
-
return this.auth?.split(':')[1] || '';
|
61
|
-
}
|
62
|
-
set password(value) {
|
63
|
-
this.auth = `${this.username}:${value}`;
|
64
|
-
}
|
65
|
-
toString() {
|
66
|
-
if (this._searchParams) {
|
67
|
-
this.search = this._searchParams.toString();
|
68
|
-
}
|
69
|
-
return this.format();
|
70
|
-
}
|
71
|
-
toJSON() {
|
72
|
-
return this.toString();
|
73
|
-
}
|
6
|
+
class PonyfillURL extends URL {
|
7
|
+
// This part is only needed to handle `PonyfillBlob` objects
|
74
8
|
static blobRegistry = new Map();
|
75
9
|
static createObjectURL(blob) {
|
76
10
|
const blobUrl = `blob:whatwgnode:${(0, crypto_1.randomUUID)()}`;
|
77
11
|
this.blobRegistry.set(blobUrl, blob);
|
78
12
|
return blobUrl;
|
79
13
|
}
|
80
|
-
static
|
14
|
+
static revokeObjectURL(url) {
|
81
15
|
if (!this.blobRegistry.has(url)) {
|
82
16
|
URL.revokeObjectURL(url);
|
83
17
|
}
|
@@ -88,6 +22,5 @@ class PonyfillURL extends fast_url_parser_1.default {
|
|
88
22
|
static getBlobFromURL(url) {
|
89
23
|
return (this.blobRegistry.get(url) || (0, buffer_1.resolveObjectURL)(url));
|
90
24
|
}
|
91
|
-
[Symbol.toStringTag] = 'URL';
|
92
25
|
}
|
93
26
|
exports.PonyfillURL = PonyfillURL;
|
package/cjs/URLSearchParams.js
CHANGED
@@ -1,120 +1,4 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PonyfillURLSearchParams = void 0;
|
4
|
-
|
5
|
-
const fast_querystring_1 = tslib_1.__importDefault(require("fast-querystring"));
|
6
|
-
const IteratorObject_js_1 = require("./IteratorObject.js");
|
7
|
-
function isURLSearchParams(value) {
|
8
|
-
return value?.entries != null;
|
9
|
-
}
|
10
|
-
class PonyfillURLSearchParams {
|
11
|
-
params;
|
12
|
-
constructor(init) {
|
13
|
-
if (init) {
|
14
|
-
if (typeof init === 'string') {
|
15
|
-
this.params = fast_querystring_1.default.parse(init);
|
16
|
-
}
|
17
|
-
else if (Array.isArray(init)) {
|
18
|
-
this.params = {};
|
19
|
-
for (const [key, value] of init) {
|
20
|
-
this.params[key] = value;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
else if (isURLSearchParams(init)) {
|
24
|
-
this.params = {};
|
25
|
-
for (const [key, value] of init.entries()) {
|
26
|
-
this.params[key] = value;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
else {
|
30
|
-
this.params = init;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
else {
|
34
|
-
this.params = {};
|
35
|
-
}
|
36
|
-
}
|
37
|
-
append(name, value) {
|
38
|
-
const existingValue = this.params[name];
|
39
|
-
const finalValue = existingValue ? `${existingValue},${value}` : value;
|
40
|
-
this.params[name] = finalValue;
|
41
|
-
}
|
42
|
-
delete(name) {
|
43
|
-
delete this.params[name];
|
44
|
-
}
|
45
|
-
get(name) {
|
46
|
-
const value = this.params[name];
|
47
|
-
if (Array.isArray(value)) {
|
48
|
-
return value[0] || null;
|
49
|
-
}
|
50
|
-
return value || null;
|
51
|
-
}
|
52
|
-
getAll(name) {
|
53
|
-
const value = this.params[name];
|
54
|
-
if (!Array.isArray(value)) {
|
55
|
-
return value ? [value] : [];
|
56
|
-
}
|
57
|
-
return value;
|
58
|
-
}
|
59
|
-
has(name) {
|
60
|
-
return name in this.params;
|
61
|
-
}
|
62
|
-
set(name, value) {
|
63
|
-
this.params[name] = value;
|
64
|
-
}
|
65
|
-
sort() {
|
66
|
-
const sortedKeys = Object.keys(this.params).sort();
|
67
|
-
const sortedParams = {};
|
68
|
-
for (const key of sortedKeys) {
|
69
|
-
sortedParams[key] = this.params[key];
|
70
|
-
}
|
71
|
-
this.params = sortedParams;
|
72
|
-
}
|
73
|
-
toString() {
|
74
|
-
return fast_querystring_1.default.stringify(this.params);
|
75
|
-
}
|
76
|
-
*_keys() {
|
77
|
-
for (const key in this.params) {
|
78
|
-
yield key;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
keys() {
|
82
|
-
return new IteratorObject_js_1.PonyfillIteratorObject(this._keys(), 'URLSearchParamsIterator');
|
83
|
-
}
|
84
|
-
*_entries() {
|
85
|
-
for (const key of this.keys()) {
|
86
|
-
const value = this.params[key];
|
87
|
-
if (Array.isArray(value)) {
|
88
|
-
for (const item of value) {
|
89
|
-
yield [key, item];
|
90
|
-
}
|
91
|
-
}
|
92
|
-
else {
|
93
|
-
yield [key, value];
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
entries() {
|
98
|
-
return new IteratorObject_js_1.PonyfillIteratorObject(this._entries(), 'URLSearchParamsIterator');
|
99
|
-
}
|
100
|
-
*_values() {
|
101
|
-
for (const [, value] of this) {
|
102
|
-
yield value;
|
103
|
-
}
|
104
|
-
}
|
105
|
-
values() {
|
106
|
-
return new IteratorObject_js_1.PonyfillIteratorObject(this._values(), 'URLSearchParamsIterator');
|
107
|
-
}
|
108
|
-
[Symbol.iterator]() {
|
109
|
-
return this.entries();
|
110
|
-
}
|
111
|
-
forEach(callback) {
|
112
|
-
for (const [key, value] of this) {
|
113
|
-
callback(value, key, this);
|
114
|
-
}
|
115
|
-
}
|
116
|
-
get size() {
|
117
|
-
return Object.keys(this.params).length;
|
118
|
-
}
|
119
|
-
}
|
120
|
-
exports.PonyfillURLSearchParams = PonyfillURLSearchParams;
|
4
|
+
exports.PonyfillURLSearchParams = globalThis.URLSearchParams;
|
package/esm/URL.js
CHANGED
@@ -1,79 +1,14 @@
|
|
1
1
|
import { resolveObjectURL } from 'buffer';
|
2
2
|
import { randomUUID } from 'crypto';
|
3
|
-
|
4
|
-
|
5
|
-
import { PonyfillURLSearchParams } from './URLSearchParams.js';
|
6
|
-
FastUrl.queryString = FastQuerystring;
|
7
|
-
const IPV6_REGEX = /^(?:(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,1}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})?::)(?:\/(?:0?0?[0-9]|0?[1-9][0-9]|1[01][0-9]|12[0-8]))?)$/;
|
8
|
-
export class PonyfillURL extends FastUrl {
|
9
|
-
constructor(url, base) {
|
10
|
-
super();
|
11
|
-
if (url.startsWith('data:')) {
|
12
|
-
this.protocol = 'data:';
|
13
|
-
this.pathname = url.slice('data:'.length);
|
14
|
-
return;
|
15
|
-
}
|
16
|
-
this.parse(url, false);
|
17
|
-
// `fast-url-parser` incorrectly removes `[IPV6]` in the hostname
|
18
|
-
// Then `hostname` doesn't include `[` and `]` for IPv6 URLs
|
19
|
-
// This breaks implementations that rely on `hostname` to include `[` and `]`
|
20
|
-
if ((url.startsWith('http://[') || url.startsWith('https://[')) &&
|
21
|
-
IPV6_REGEX.test(this.hostname)) {
|
22
|
-
this.hostname = `[${this.hostname}]`;
|
23
|
-
}
|
24
|
-
// `fast-url-parser` incorrectly handle URLs with ports without pathnames correctly like
|
25
|
-
// `http://localhost:8080?foo=bar` -> `http://localhost/:8080?foo=bar`
|
26
|
-
if (url.includes(`${this.hostname}:`) && !this.port && this.pathname.startsWith('/:')) {
|
27
|
-
this.port = this.pathname.slice(2);
|
28
|
-
this.pathname = '/';
|
29
|
-
this.host = `${this.hostname}:${this.port}`;
|
30
|
-
}
|
31
|
-
if (base) {
|
32
|
-
const baseParsed = typeof base === 'string' ? new PonyfillURL(base) : base;
|
33
|
-
this.protocol ||= baseParsed.protocol;
|
34
|
-
this.host ||= baseParsed.host;
|
35
|
-
this.pathname ||= baseParsed.pathname;
|
36
|
-
this.port ||= baseParsed.port;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
get origin() {
|
40
|
-
return `${this.protocol}//${this.hostname}${this.port ? `:${this.port}` : ''}`;
|
41
|
-
}
|
42
|
-
_searchParams;
|
43
|
-
get searchParams() {
|
44
|
-
if (!this._searchParams) {
|
45
|
-
this._searchParams = new PonyfillURLSearchParams(this.query);
|
46
|
-
}
|
47
|
-
return this._searchParams;
|
48
|
-
}
|
49
|
-
get username() {
|
50
|
-
return this.auth?.split(':')[0] || '';
|
51
|
-
}
|
52
|
-
set username(value) {
|
53
|
-
this.auth = `${value}:${this.password}`;
|
54
|
-
}
|
55
|
-
get password() {
|
56
|
-
return this.auth?.split(':')[1] || '';
|
57
|
-
}
|
58
|
-
set password(value) {
|
59
|
-
this.auth = `${this.username}:${value}`;
|
60
|
-
}
|
61
|
-
toString() {
|
62
|
-
if (this._searchParams) {
|
63
|
-
this.search = this._searchParams.toString();
|
64
|
-
}
|
65
|
-
return this.format();
|
66
|
-
}
|
67
|
-
toJSON() {
|
68
|
-
return this.toString();
|
69
|
-
}
|
3
|
+
export class PonyfillURL extends URL {
|
4
|
+
// This part is only needed to handle `PonyfillBlob` objects
|
70
5
|
static blobRegistry = new Map();
|
71
6
|
static createObjectURL(blob) {
|
72
7
|
const blobUrl = `blob:whatwgnode:${randomUUID()}`;
|
73
8
|
this.blobRegistry.set(blobUrl, blob);
|
74
9
|
return blobUrl;
|
75
10
|
}
|
76
|
-
static
|
11
|
+
static revokeObjectURL(url) {
|
77
12
|
if (!this.blobRegistry.has(url)) {
|
78
13
|
URL.revokeObjectURL(url);
|
79
14
|
}
|
@@ -84,5 +19,4 @@ export class PonyfillURL extends FastUrl {
|
|
84
19
|
static getBlobFromURL(url) {
|
85
20
|
return (this.blobRegistry.get(url) || resolveObjectURL(url));
|
86
21
|
}
|
87
|
-
[Symbol.toStringTag] = 'URL';
|
88
22
|
}
|
package/esm/URLSearchParams.js
CHANGED
@@ -1,115 +1 @@
|
|
1
|
-
|
2
|
-
import { PonyfillIteratorObject } from './IteratorObject.js';
|
3
|
-
function isURLSearchParams(value) {
|
4
|
-
return value?.entries != null;
|
5
|
-
}
|
6
|
-
export class PonyfillURLSearchParams {
|
7
|
-
params;
|
8
|
-
constructor(init) {
|
9
|
-
if (init) {
|
10
|
-
if (typeof init === 'string') {
|
11
|
-
this.params = FastQuerystring.parse(init);
|
12
|
-
}
|
13
|
-
else if (Array.isArray(init)) {
|
14
|
-
this.params = {};
|
15
|
-
for (const [key, value] of init) {
|
16
|
-
this.params[key] = value;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
else if (isURLSearchParams(init)) {
|
20
|
-
this.params = {};
|
21
|
-
for (const [key, value] of init.entries()) {
|
22
|
-
this.params[key] = value;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
this.params = init;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
else {
|
30
|
-
this.params = {};
|
31
|
-
}
|
32
|
-
}
|
33
|
-
append(name, value) {
|
34
|
-
const existingValue = this.params[name];
|
35
|
-
const finalValue = existingValue ? `${existingValue},${value}` : value;
|
36
|
-
this.params[name] = finalValue;
|
37
|
-
}
|
38
|
-
delete(name) {
|
39
|
-
delete this.params[name];
|
40
|
-
}
|
41
|
-
get(name) {
|
42
|
-
const value = this.params[name];
|
43
|
-
if (Array.isArray(value)) {
|
44
|
-
return value[0] || null;
|
45
|
-
}
|
46
|
-
return value || null;
|
47
|
-
}
|
48
|
-
getAll(name) {
|
49
|
-
const value = this.params[name];
|
50
|
-
if (!Array.isArray(value)) {
|
51
|
-
return value ? [value] : [];
|
52
|
-
}
|
53
|
-
return value;
|
54
|
-
}
|
55
|
-
has(name) {
|
56
|
-
return name in this.params;
|
57
|
-
}
|
58
|
-
set(name, value) {
|
59
|
-
this.params[name] = value;
|
60
|
-
}
|
61
|
-
sort() {
|
62
|
-
const sortedKeys = Object.keys(this.params).sort();
|
63
|
-
const sortedParams = {};
|
64
|
-
for (const key of sortedKeys) {
|
65
|
-
sortedParams[key] = this.params[key];
|
66
|
-
}
|
67
|
-
this.params = sortedParams;
|
68
|
-
}
|
69
|
-
toString() {
|
70
|
-
return FastQuerystring.stringify(this.params);
|
71
|
-
}
|
72
|
-
*_keys() {
|
73
|
-
for (const key in this.params) {
|
74
|
-
yield key;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
keys() {
|
78
|
-
return new PonyfillIteratorObject(this._keys(), 'URLSearchParamsIterator');
|
79
|
-
}
|
80
|
-
*_entries() {
|
81
|
-
for (const key of this.keys()) {
|
82
|
-
const value = this.params[key];
|
83
|
-
if (Array.isArray(value)) {
|
84
|
-
for (const item of value) {
|
85
|
-
yield [key, item];
|
86
|
-
}
|
87
|
-
}
|
88
|
-
else {
|
89
|
-
yield [key, value];
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
entries() {
|
94
|
-
return new PonyfillIteratorObject(this._entries(), 'URLSearchParamsIterator');
|
95
|
-
}
|
96
|
-
*_values() {
|
97
|
-
for (const [, value] of this) {
|
98
|
-
yield value;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
values() {
|
102
|
-
return new PonyfillIteratorObject(this._values(), 'URLSearchParamsIterator');
|
103
|
-
}
|
104
|
-
[Symbol.iterator]() {
|
105
|
-
return this.entries();
|
106
|
-
}
|
107
|
-
forEach(callback) {
|
108
|
-
for (const [key, value] of this) {
|
109
|
-
callback(value, key, this);
|
110
|
-
}
|
111
|
-
}
|
112
|
-
get size() {
|
113
|
-
return Object.keys(this.params).length;
|
114
|
-
}
|
115
|
-
}
|
1
|
+
export const PonyfillURLSearchParams = globalThis.URLSearchParams;
|
package/package.json
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.7.6-alpha-
|
3
|
+
"version": "0.7.6-alpha-20250102090222-b3df3a37f8f87ca84ae46c16473ebd0dcf369462",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
7
|
-
"@kamilkisiela/fast-url-parser": "^1.1.4",
|
8
7
|
"@whatwg-node/disposablestack": "^0.0.5",
|
9
8
|
"busboy": "^1.6.0",
|
10
|
-
"fast-querystring": "^1.1.1",
|
11
9
|
"tslib": "^2.6.3"
|
12
10
|
},
|
13
11
|
"repository": {
|
package/typings/URL.d.cts
CHANGED
@@ -1,20 +1,7 @@
|
|
1
|
-
import FastUrl from '@kamilkisiela/fast-url-parser';
|
2
1
|
import { PonyfillBlob } from './Blob.cjs';
|
3
|
-
|
4
|
-
|
5
|
-
constructor(url: string, base?: string | URL);
|
6
|
-
get origin(): string;
|
7
|
-
private _searchParams?;
|
8
|
-
get searchParams(): PonyfillURLSearchParams;
|
9
|
-
get username(): string;
|
10
|
-
set username(value: string);
|
11
|
-
get password(): string;
|
12
|
-
set password(value: string);
|
13
|
-
toString(): string;
|
14
|
-
toJSON(): string;
|
15
|
-
private static blobRegistry;
|
2
|
+
export declare class PonyfillURL extends URL {
|
3
|
+
static blobRegistry: Map<string, Blob | PonyfillBlob>;
|
16
4
|
static createObjectURL(blob: Blob): string;
|
17
|
-
static
|
5
|
+
static revokeObjectURL(url: string): void;
|
18
6
|
static getBlobFromURL(url: string): Blob | PonyfillBlob | undefined;
|
19
|
-
[Symbol.toStringTag]: string;
|
20
7
|
}
|
package/typings/URL.d.ts
CHANGED
@@ -1,20 +1,7 @@
|
|
1
|
-
import FastUrl from '@kamilkisiela/fast-url-parser';
|
2
1
|
import { PonyfillBlob } from './Blob.js';
|
3
|
-
|
4
|
-
|
5
|
-
constructor(url: string, base?: string | URL);
|
6
|
-
get origin(): string;
|
7
|
-
private _searchParams?;
|
8
|
-
get searchParams(): PonyfillURLSearchParams;
|
9
|
-
get username(): string;
|
10
|
-
set username(value: string);
|
11
|
-
get password(): string;
|
12
|
-
set password(value: string);
|
13
|
-
toString(): string;
|
14
|
-
toJSON(): string;
|
15
|
-
private static blobRegistry;
|
2
|
+
export declare class PonyfillURL extends URL {
|
3
|
+
static blobRegistry: Map<string, Blob | PonyfillBlob>;
|
16
4
|
static createObjectURL(blob: Blob): string;
|
17
|
-
static
|
5
|
+
static revokeObjectURL(url: string): void;
|
18
6
|
static getBlobFromURL(url: string): Blob | PonyfillBlob | undefined;
|
19
|
-
[Symbol.toStringTag]: string;
|
20
7
|
}
|
@@ -1,21 +1,4 @@
|
|
1
|
-
export declare
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
delete(name: string): void;
|
6
|
-
get(name: string): string | null;
|
7
|
-
getAll(name: string): string[];
|
8
|
-
has(name: string): boolean;
|
9
|
-
set(name: string, value: string): void;
|
10
|
-
sort(): void;
|
11
|
-
toString(): string;
|
12
|
-
_keys(): IterableIterator<string>;
|
13
|
-
keys(): URLSearchParamsIterator<string>;
|
14
|
-
_entries(): IterableIterator<[string, string]>;
|
15
|
-
entries(): URLSearchParamsIterator<[string, string]>;
|
16
|
-
_values(): IterableIterator<string>;
|
17
|
-
values(): URLSearchParamsIterator<string>;
|
18
|
-
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
19
|
-
forEach(callback: (value: string, key: string, parent: URLSearchParams) => void): void;
|
20
|
-
get size(): number;
|
21
|
-
}
|
1
|
+
export declare const PonyfillURLSearchParams: {
|
2
|
+
new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
|
3
|
+
prototype: URLSearchParams;
|
4
|
+
};
|
@@ -1,21 +1,4 @@
|
|
1
|
-
export declare
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
delete(name: string): void;
|
6
|
-
get(name: string): string | null;
|
7
|
-
getAll(name: string): string[];
|
8
|
-
has(name: string): boolean;
|
9
|
-
set(name: string, value: string): void;
|
10
|
-
sort(): void;
|
11
|
-
toString(): string;
|
12
|
-
_keys(): IterableIterator<string>;
|
13
|
-
keys(): URLSearchParamsIterator<string>;
|
14
|
-
_entries(): IterableIterator<[string, string]>;
|
15
|
-
entries(): URLSearchParamsIterator<[string, string]>;
|
16
|
-
_values(): IterableIterator<string>;
|
17
|
-
values(): URLSearchParamsIterator<string>;
|
18
|
-
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
19
|
-
forEach(callback: (value: string, key: string, parent: URLSearchParams) => void): void;
|
20
|
-
get size(): number;
|
21
|
-
}
|
1
|
+
export declare const PonyfillURLSearchParams: {
|
2
|
+
new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
|
3
|
+
prototype: URLSearchParams;
|
4
|
+
};
|