fix v2.6.3 that did not sending query params (#1301)

This commit is contained in:
Jimmy Wärting 2021-09-21 16:42:50 +02:00 committed by GitHub
parent ace7536c95
commit 18193c5922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 14 deletions

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -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) => {