Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend using URLSearchParams instead in the readme? #200

Closed
jimmywarting opened this issue Aug 8, 2019 · 2 comments
Closed

Recommend using URLSearchParams instead in the readme? #200

jimmywarting opened this issue Aug 8, 2019 · 2 comments

Comments

@jimmywarting
Copy link

I propose that ppl start using URLSearchParams instead of query-string.

Why?

  • URLSearchParams is available in Deno, browsers and also Node. so you would be less dependent on something that is a node only feature.
  • URLSearchParams follows a spec. i suppose more ppl knows how URLSearchParams works. and don't have to learn how a node specific lib works
  • querystring will mix the value between string and arrays giving you an inconsistent api.
    this is a footgun where you can shoot yourself if you try to parse query strings and you would expect everything to be an object and clients adds more params to the url
const obj = querystring.parse('a=a1&b=b1&b=b2') // { a: 'a1', b: ['b1', 'b2'] }

i suspect node would never have gone to implementing query-string if URLSearchParams was first implemented. There is a new trend that ppl and Node wants to follow the spec more and more, ppl wants to be able to write cross platform applications and that involves using technology that is available in all environments. some developers don't want to use module x cuz it's too dependent on Node

@sindresorhus
Copy link
Owner

You seem to be confusing this with the Node.js built-in module called querystring (note the lack of a dash).

I would happily accept a PR that mentions URLSearchParams as an alternative, but it's not a replacement for many as this module is much more flexible.

@tredondo
Copy link

tredondo commented Apr 6, 2022

For those landing here from a search, #307 is the newer issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants