Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix v2.6.3 that did not send query params #1301

Merged
merged 1 commit into from Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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')
})
})

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for putting in a test to avoid future regressions 💐

This explains the mystery of octokit/rest.js#114 and semantic-release/github#415

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