Skip to content

Commit 18193c5

Browse files
authored
fix v2.6.3 that did not sending query params (#1301)
1 parent ace7536 commit 18193c5

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Changelog
55

66
# 2.x release
77

8+
## v2.6.4
9+
10+
- Hotfix: fix v2.6.3 that did not sending query params
11+
812
## v2.6.3
913

1014
- Fix: properly encode url with unicode characters

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.3",
3+
"version": "2.6.4",
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-13
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,7 @@ function parseURL(urlStr) {
3333
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
3434
*/
3535
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
36-
const url = new URL(urlStr);
37-
38-
return {
39-
path: url.pathname,
40-
pathname: url.pathname,
41-
hostname: url.hostname,
42-
protocol: url.protocol,
43-
port: url.port,
44-
hash: url.hash,
45-
search: url.search,
46-
query: url.query,
47-
href: url.href,
48-
}
36+
urlStr = new URL(urlStr).toString()
4937
}
5038

5139
// Fallback to old implementation for arbitrary URLs

test/test.js

+9
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,15 @@ describe('external encoding', () => {
28472847
});
28482848

28492849
describe('issue #1290', function() {
2850+
2851+
it('should keep query params', function() {
2852+
return fetch(`${base}inspect?month=2021-09`)
2853+
.then(res => res.json())
2854+
.then(json => {
2855+
expect(json.url).to.equal('/inspect?month=2021-09')
2856+
})
2857+
})
2858+
28502859
it('should handle escaped unicode in URLs', () => {
28512860
const url = `${base}issues/1290/%E3%81%B2%E3%82%89%E3%81%8C%E3%81%AA`;
28522861
return fetch(url).then((res) => {

0 commit comments

Comments
 (0)