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

Suggest using the URLSearchParams built-in #37

Closed
tredondo opened this issue Apr 6, 2022 · 4 comments
Closed

Suggest using the URLSearchParams built-in #37

tredondo opened this issue Apr 6, 2022 · 4 comments

Comments

@tredondo
Copy link
Contributor

tredondo commented Apr 6, 2022

The URL standard includes the URLSearchParams interface which in many cases should be able to replace this module. @sindresorhus is also considering suggesting it in his query-string module README.

This module has 10M weekly downloads. It would really help mentioning the built-in, to help avoid cargo cult usage of this module when not necessary.

The twice as popular querystring package deprecated itself in favor of URLSearchParams.

@jimmywarting
Copy link

jimmywarting commented Apr 6, 2022

agree, this lib don't even support double entity like foo=1&foo=2
something that URLSearchParams can do for you...

this lib almost the the same thing as this, but with much more code...

Object.fromEntries(new URLSearchParams('?foo=bar')) 
`?${new URLSearchParams({foo: 'bar'})}`

@lpinca
Copy link
Member

lpinca commented Apr 6, 2022

this lib almost the the same thing as this, but with much more code...

This module was built years ago when URLSearchParams was not supported everywhere. This module works in IE6. Also this module is deadly simple by design.

Unlike alternatives like qs or query-string this module is around 400 bytes when minified and gzipped.

I agree that it would be better to use URLSearchParams when possible, but I do not think that using this small library is a problem. Developers should evaluate for themselves.

@lpinca
Copy link
Member

lpinca commented Apr 6, 2022

Feel free to open a PR with the suggestion.

@tredondo
Copy link
Contributor Author

tredondo commented Apr 6, 2022

Great, see #38.

@lpinca lpinca closed this as completed in ae1ed11 Apr 7, 2022
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