Skip to content

Merging searchParams from instance and actual call is buggy or unintuitive #1554

Answered by Giotino
mirfilip asked this question in Q&A
Discussion options

You must be logged in to vote

It's not a bug.

The reason behind that behavior is that a quuery string (aka. search string) (what comes in an URI after the path between ? and #) it's not necessary a "list" of search params.
URLSearchParams is defined by WHATWG, but the query string can be whatever you want (eg. http://example.com/?randomString).

The only thing I think we could argue is what Got has to keep, the new search string or the old one, the actual behavior is due to the merge of the options and the prevalence of searchParams over the query string https://github.com/sindresorhus/got#url

BTW: if you use searchParams in both cases they should merge.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by szmarczak
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1554 on December 15, 2020 08:38.