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

cx.param into a string doesn't handle url-decoding #281

Open
nikomatsakis opened this issue Jun 20, 2019 · 5 comments
Open

cx.param into a string doesn't handle url-decoding #281

nikomatsakis opened this issue Jun 20, 2019 · 5 comments

Comments

@nikomatsakis
Copy link

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.

@bIgBV bIgBV self-assigned this Jul 18, 2019
@yoshuawuyts
Copy link
Member

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.

@secretfader
Copy link

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.

@kyrias
Copy link
Contributor

kyrias commented May 19, 2020

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().

@kyrias
Copy link
Contributor

kyrias commented May 19, 2020

Uh what, how did me commenting that unassign him?

@emmiegit
Copy link

emmiegit commented Apr 9, 2023

Is there a recommendation in the mean time for how to easily percent-decode parameters when fetching from Tide?

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

6 participants