diff --git a/CHANGELOG.md b/CHANGELOG.md index 671da7654..46eef0ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index c5edc7991..98cf5f4c5 100644 --- a/package.json +++ b/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", diff --git a/src/request.js b/src/request.js index 6fa8e77b6..3c27c81cf 100644 --- a/src/request.js +++ b/src/request.js @@ -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 diff --git a/test/test.js b/test/test.js index 9220cbd4a..9568489e3 100644 --- a/test/test.js +++ b/test/test.js @@ -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) => {