Skip to content

Commit f56b0c6

Browse files
authored
fix(URL): prefer built in URL version when available and fallback to whatwg (#1352)
* fix(URL): prefer built in URL version when available and fallback to whatwg * bump minor
1 parent b5417ae commit f56b0c6

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-fetch",
3-
"version": "2.6.5",
3+
"version": "2.6.6",
44
"description": "A light-weight module that brings window.fetch to node.js",
55
"main": "lib/index.js",
66
"browser": "./browser.js",

src/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Headers, { exportNodeCompatibleHeaders } from './headers.js';
1414
import Body, { clone, extractContentType, getTotalBytes } from './body';
1515

1616
const INTERNALS = Symbol('Request internals');
17-
const URL = whatwgUrl.URL;
17+
const URL = Url.URL || whatwgUrl.URL;
1818

1919
// fix an issue where "format", "parse" aren't a named export for node <10
2020
const parse_url = Url.parse;

test/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -2875,4 +2875,11 @@ describe('issue #1290', function() {
28752875
});
28762876
});
28772877
});
2878+
2879+
// #1342
2880+
it('should not throw with a valid URL', () => {
2881+
const url = 'https://r2---sn-n4v7sney.example.com';
2882+
new Request(url);
2883+
});
2884+
28782885
});

0 commit comments

Comments
 (0)