Got: mergeOptions isn't merging URLSearchParams instances

Created on 4 Jan 2020  Â·  1Comment  Â·  Source: sindresorhus/got

Describe the bug

  • Node.js version: -
  • OS & version: -

got.mergeOptions isn't merging instances of URLSearchParams. According to the README is should merge them.

Actual behavior

It looks like later instances of URLSearchParams just overwrite earlier values. (see code sample)

Expected behavior

It should merge the two URLSearchParams instances.

Code to reproduce

const got = require('got');
got.mergeOptions({ searchParams: new URLSearchParams({ foo: 1 }) }, { searchParams: new URLSearchParams({ bar: 2 }) });
// => { ... searchParams: URLSearchParams { 'bar' => '2' } }

Checklist

  • [x] I have read the documentation.
  • [x] I have tried my code with the latest version of Node.js and Got.

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

bug regression ✭ help wanted ✭

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings