js_from_routes icon indicating copy to clipboard operation
js_from_routes copied to clipboard

Query parameter keys are deep converted to snake_case unexpectedly

Open marcowindt opened this issue 1 year ago • 0 comments

  • [x] I have tried upgrading by running bundle update js_from_routes.
  • [x] I have read the troubleshooting section before opening an issue.

Description 📖

When doing a request with query parameters, the keys are always case converted to snake_case. I.e. unless a URLSearchParams object is passed.

https://github.com/ElMassimo/js_from_routes/blob/7e708ebfdfa6c47634b86a0a0e77db0f0359101b/packages/core/src/urls.ts#L62-L66

Which resulted in a bug in one of our applications.

Work around for now is to pass a URLSearchParams object (or JSON.stringify(value) if possible for you), but can this perhaps be changed to use the default Config.serializeData function or a different config?

Reproduction/Logs 🐞📜

For example when doing

return await myJsFromRoutes.list({ query: { foo: { barOs: [] } } });

Will make a request as follows

path/to/my-route?foo=%7B%bar_os%22:[]%7D

Happy to contribute if agreed upon a solution, thanks!

marcowindt avatar May 22 '24 15:05 marcowindt