Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Apr 1, 2020
1 parent 394c834 commit 025f4f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,13 @@ export default class Request extends Duplex implements RequestEvents<Request> {
options.url = new URL(`http://unix${options.url.pathname}${options.url.search}`);
}

if (options.url.search) {
const triggerSearchParams = '_GOT_INTERNAL_TRIGGER_NORMALIZATION';

options.url.searchParams.append(triggerSearchParams, '');
options.url.searchParams.delete(triggerSearchParams);
}

if (protocol !== 'http:' && protocol !== 'https:') {
throw new UnsupportedProtocolError(options as NormalizedOptions);
}
Expand Down
8 changes: 8 additions & 0 deletions test/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,11 @@ test('does not throw on frozen options', withServer, async (t, server, got) => {

t.is(body, '/');
});

test('normalizes search params included in input', t => {
const {url} = got.mergeOptions({
url: new URL('https://example.com/?a=b c')
});

t.is(url.search, '?a=b+c');
});

0 comments on commit 025f4f2

Please sign in to comment.