Skip to content

Commit

Permalink
fix v2.6.3 that did not sending query params (#1301)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmywarting committed Sep 21, 2021
1 parent ace7536 commit 18193c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,10 @@ Changelog

# 2.x release

## v2.6.4

- Hotfix: fix v2.6.3 that did not sending query params

## v2.6.3

- Fix: properly encode url with unicode characters
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "node-fetch",
"version": "2.6.3",
"version": "2.6.4",
"description": "A light-weight module that brings window.fetch to node.js",
"main": "lib/index.js",
"browser": "./browser.js",
Expand Down
14 changes: 1 addition & 13 deletions src/request.js
Expand Up @@ -33,19 +33,7 @@ function parseURL(urlStr) {
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
*/
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
const url = new URL(urlStr);

return {
path: url.pathname,
pathname: url.pathname,
hostname: url.hostname,
protocol: url.protocol,
port: url.port,
hash: url.hash,
search: url.search,
query: url.query,
href: url.href,
}
urlStr = new URL(urlStr).toString()
}

// Fallback to old implementation for arbitrary URLs
Expand Down
9 changes: 9 additions & 0 deletions test/test.js
Expand Up @@ -2847,6 +2847,15 @@ describe('external encoding', () => {
});

describe('issue #1290', function() {

it('should keep query params', function() {
return fetch(`${base}inspect?month=2021-09`)
.then(res => res.json())
.then(json => {
expect(json.url).to.equal('/inspect?month=2021-09')
})
})

it('should handle escaped unicode in URLs', () => {
const url = `${base}issues/1290/%E3%81%B2%E3%82%89%E3%81%8C%E3%81%AA`;
return fetch(url).then((res) => {
Expand Down

0 comments on commit 18193c5

Please sign in to comment.