Skip to content

Commit

Permalink
Fix merging of searchParams in ky.create()
Browse files Browse the repository at this point in the history
  • Loading branch information
sholladay committed May 4, 2021
1 parent 453846e commit 1493336
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/utils/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ 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 @@ -474,6 +474,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 1493336

Please sign in to comment.