got.mergeOptions isn't merging instances of URLSearchParams. According to the README is should merge them.
It looks like later instances of URLSearchParams just overwrite earlier values. (see code sample)
It should merge the two URLSearchParams instances.
const got = require('got');
got.mergeOptions({ searchParams: new URLSearchParams({ foo: 1 }) }, { searchParams: new URLSearchParams({ bar: 2 }) });
// => { ... searchParams: URLSearchParams { 'bar' => '2' } }
I think some code got deleted in https://github.com/sindresorhus/got/pull/921.
merge.ts got moved https://github.com/sindresorhus/got/pull/921/files#diff-5e2f9cb0db248d822e1b167d5ccf8e07. Before the move it had code to deal with instances of URLSearchParams:
https://github.com/sindresorhus/got/blob/9f4fe33585bf89de37f61ff5614435105be28f64/source/merge.ts#L13-L21
After the move it's missing the code to handle URLSearchParams: https://github.com/szmarczak/got/blob/a7e73f2fe89b1eca00d2f8fff71dffb2caf68c16/source/utils/merge.ts
There were no tests for that functionality, so I guess I did remove that innocent piece of code.
I'll fix this on Monday, currently I'm not at home.
Most helpful comment
There were no tests for that functionality, so I guess I did remove that innocent piece of code.
I'll fix this on Monday, currently I'm not at home.