@whatwg-node/node-fetch 0.7.5-alpha-20241210190244-f8654a00cd5b6a4eda10e114502523848eaec29f → 0.7.5-alpha-20241210210919-680ecc3291b1c6c284e87af6977d8a107e1ec8cc
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.
- package/cjs/URL.js +4 -1
- package/cjs/fetchNodeHttp.js +2 -1
- package/esm/URL.js +4 -1
- package/esm/fetchNodeHttp.js +2 -1
- package/package.json +1 -1
package/cjs/URL.js
CHANGED
@@ -8,6 +8,7 @@ const fast_querystring_1 = tslib_1.__importDefault(require("fast-querystring"));
|
|
8
8
|
const fast_url_parser_1 = tslib_1.__importDefault(require("@kamilkisiela/fast-url-parser"));
|
9
9
|
const URLSearchParams_js_1 = require("./URLSearchParams.js");
|
10
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]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?[0-9]|0?[1-9][0-9]|1[01][0-9]|12[0-8]))?)$/;
|
11
12
|
class PonyfillURL extends fast_url_parser_1.default {
|
12
13
|
constructor(url, base) {
|
13
14
|
super();
|
@@ -17,7 +18,9 @@ class PonyfillURL extends fast_url_parser_1.default {
|
|
17
18
|
return;
|
18
19
|
}
|
19
20
|
this.parse(url, false);
|
20
|
-
|
21
|
+
// `fast-url-parser` cannot handle ipv6 hosts correctly
|
22
|
+
if ((url.startsWith('http://[') || url.startsWith('https://[')) &&
|
23
|
+
IPV6_REGEX.test(this.hostname)) {
|
21
24
|
this.hostname = `[${this.hostname}]`;
|
22
25
|
}
|
23
26
|
if (base) {
|
package/cjs/fetchNodeHttp.js
CHANGED
@@ -33,7 +33,8 @@ function fetchNodeHttp(fetchRequest) {
|
|
33
33
|
nodeHeaders['accept-encoding'] = 'gzip, deflate, br';
|
34
34
|
}
|
35
35
|
let nodeRequest;
|
36
|
-
if (
|
36
|
+
// Skip using parsed URL if it's an IPv6 address (starting with brackets)
|
37
|
+
if (fetchRequest.parsedUrl && !fetchRequest.parsedUrl.hostname.startsWith('[')) {
|
37
38
|
nodeRequest = requestFn({
|
38
39
|
auth: fetchRequest.parsedUrl.username
|
39
40
|
? `${fetchRequest.parsedUrl.username}:${fetchRequest.parsedUrl.password}`
|
package/esm/URL.js
CHANGED
@@ -4,6 +4,7 @@ import FastQuerystring from 'fast-querystring';
|
|
4
4
|
import FastUrl from '@kamilkisiela/fast-url-parser';
|
5
5
|
import { PonyfillURLSearchParams } from './URLSearchParams.js';
|
6
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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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]))?)$/;
|
7
8
|
export class PonyfillURL extends FastUrl {
|
8
9
|
constructor(url, base) {
|
9
10
|
super();
|
@@ -13,7 +14,9 @@ export class PonyfillURL extends FastUrl {
|
|
13
14
|
return;
|
14
15
|
}
|
15
16
|
this.parse(url, false);
|
16
|
-
|
17
|
+
// `fast-url-parser` cannot handle ipv6 hosts correctly
|
18
|
+
if ((url.startsWith('http://[') || url.startsWith('https://[')) &&
|
19
|
+
IPV6_REGEX.test(this.hostname)) {
|
17
20
|
this.hostname = `[${this.hostname}]`;
|
18
21
|
}
|
19
22
|
if (base) {
|
package/esm/fetchNodeHttp.js
CHANGED
@@ -30,7 +30,8 @@ export function fetchNodeHttp(fetchRequest) {
|
|
30
30
|
nodeHeaders['accept-encoding'] = 'gzip, deflate, br';
|
31
31
|
}
|
32
32
|
let nodeRequest;
|
33
|
-
if (
|
33
|
+
// Skip using parsed URL if it's an IPv6 address (starting with brackets)
|
34
|
+
if (fetchRequest.parsedUrl && !fetchRequest.parsedUrl.hostname.startsWith('[')) {
|
34
35
|
nodeRequest = requestFn({
|
35
36
|
auth: fetchRequest.parsedUrl.username
|
36
37
|
? `${fetchRequest.parsedUrl.username}:${fetchRequest.parsedUrl.password}`
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.7.5-alpha-
|
3
|
+
"version": "0.7.5-alpha-20241210210919-680ecc3291b1c6c284e87af6977d8a107e1ec8cc",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|