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

URLSearchParams #13

Open
jamiebuilds opened this issue Jun 7, 2024 · 3 comments
Open

URLSearchParams #13

jamiebuilds opened this issue Jun 7, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jamiebuilds
Copy link

The current name is a bit unfortunate for this, but it would be nice if this library was generic over both FormData and URLSearchParams so you could do this:

let url = new URL("https://example.com?items.0=foo&items.1=bar")
let values = decode(url.searchParams)
// { items: ["foo", "bar"] }

You may then also want to support some more of the syntaxes commonly used in search params. See https://www.npmjs.com/package/qs for some examples

@fabian-hiller fabian-hiller self-assigned this Jun 7, 2024
@fabian-hiller fabian-hiller added the enhancement New feature or request label Jun 7, 2024
@fabian-hiller
Copy link
Owner

Thank you for creating this issue. This is already on my todo list, but it will probably be a while before I find the time to work on it, as I am currently focused on Valibot.

@sacrosanctic
Copy link
Contributor

@fabian-hiller

I am actually already using this for both searchParams and formData, its a bit of a hack at the moment where I convert searchParams into formData with a for loop.

If you can point me in the right direction, can create a PR with a provide implementation of it

@fabian-hiller
Copy link
Owner

We should probably work on a native decode-params library with a similar API and implementation as decode-formdate. We can work together if you are interested.

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

No branches or pull requests

3 participants