tide
tide copied to clipboard
`cx.param` into a string doesn't handle url-decoding
When using cx.param
to extract strings, I expected it to handle URL decoding for me. However, it did not. I would up writing some fairly complex code to deal with this. In general, I would expect this to be the default, with some way to request the "raw string" if I really wanted to get that, but at least there should be some super ergonomic way to "url-decode" your request parameters.
Question
Is this by design? Am I overlooking a simple way to do url-decoding?
Additional context
This is part of a flashcard app. The incoming request parameters are sometimes in other languages, so they are url-encoded utf-8.
Notes from triage: we should probably introduce a new API using https://docs.rs/serde_qs/0.5.0/serde_qs/ for this:
let params: MyType = cx.query();
Similar to how our current cx.body_json
method currently works.
When I wrote the Context
extension, serde_qs
had outstanding bugs that were unresolved for longer than preferred. It looks like those have now been cleared up.
I wonder if we can resolve at least a portion of this issue by updating to that library.
serde_qs
would be neat for query()
, but it would not work for param()
as they have different encoding rules. Importantly, +
should be decoded to space in query()
, but should be left alone for param()
.
Uh what, how did me commenting that unassign him?
Is there a recommendation in the mean time for how to easily percent-decode parameters when fetching from Tide?