Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed May 12, 2020
1 parent 7edcb94 commit 4724a0d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,6 @@ export default class Request extends Duplex implements RequestEvents<Request> {
options.url.search = options.searchParams.toString();
}

// Trigger search params normalization
if (options.url.search) {
options.url.search = decodeURIComponent(options.url.search.toString());
}

// Protocol check
if (protocol !== 'http:' && protocol !== 'https:') {
throw new UnsupportedProtocolError(options as NormalizedOptions);
Expand Down Expand Up @@ -1069,9 +1064,8 @@ export default class Request extends Duplex implements RequestEvents<Request> {
const redirectBuffer = Buffer.from(response.headers.location, 'binary').toString();

// Handles invalid URLs. See https://github.com/sindresorhus/got/issues/604
const redirectUrl = new URL(redirectBuffer, url);
const redirectUrl = new URL(decodeURI(redirectBuffer), url);
const redirectString = redirectUrl.toString();
decodeURI(redirectString);

// Redirecting to a different site, clear sensitive data.
if (redirectUrl.hostname !== url.hostname) {
Expand Down
2 changes: 1 addition & 1 deletion test/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test('throws an error if the protocol is not specified', async t => {
});
});

test('properly encodes search params', withServer, async (t, server, got) => {
test('properly encodes query string', withServer, async (t, server, got) => {
server.get('/', echoUrl);

const path = '?test=http://example.com?foo=bar';
Expand Down

0 comments on commit 4724a0d

Please sign in to comment.