Skip to content

Commit

Permalink
Fix merging of searchParams in create()/extend() (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
sholladay committed May 4, 2021
1 parent eefcde5 commit b3c9e88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions source/utils/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ export const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {

if (isObject((source as any).headers)) {
headers = mergeHeaders(headers, (source as any).headers);
returnValue.headers = headers;
}
}

returnValue.headers = headers;
}

return returnValue;
Expand Down
12 changes: 12 additions & 0 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,18 @@ test('ky.create() with deep array', async t => {
await server.close();
});

test('ky.create() does not mangle search params', async t => {
const server = await createHttpTestServer();
server.get('/', (request, response) => {
response.end(request.url);
});

const instance = ky.create({searchParams: {}});
t.is(await instance.get(server.url, {searchParams: {}}).text(), '/?');

await server.close();
});

test('ky.extend()', async t => {
const server = await createHttpTestServer();
server.get('/', (_request, response) => {
Expand Down

0 comments on commit b3c9e88

Please sign in to comment.