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

Dioxus router removes hash segments #1994

Closed
3 tasks
ealmloff opened this issue Feb 29, 2024 · 3 comments · Fixed by #2320
Closed
3 tasks

Dioxus router removes hash segments #1994

ealmloff opened this issue Feb 29, 2024 · 3 comments · Fixed by #2320
Assignees
Labels
bug Something isn't working router Related to the router implementation web relating to the web renderer for dioxus

Comments

@ealmloff
Copy link
Member

Problem

The dioxus router removes any hash segments when parsing the route.

Steps To Reproduce

Steps to reproduce the behavior:

Expected behavior

The hash segment should remain

Environment:

  • Dioxus version: master
  • Rust version: nightly
  • OS info: Linux
  • App platform: web

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@ealmloff ealmloff added bug Something isn't working web relating to the web renderer for dioxus router Related to the router implementation labels Feb 29, 2024
@SET001
Copy link
Contributor

SET001 commented Mar 1, 2024

URL fragments might have query-string format.

here is an example URL from google oauth docs -https://oauth2.example.com/callback#access_token=4/P7q7W91&token_type=Bearer&expires_in=3600 How this should be parsed?

I image route definition similar to this:

#[route("/callback#:fragment")]

and then fragment should be something that implements FromQuery? Right?

@ealmloff
Copy link
Member Author

ealmloff commented Mar 1, 2024

URL fragments might have query-string format.

here is an example URL from google oauth docs -https://oauth2.example.com/callback#access_token=4/P7q7W91&token_type=Bearer&expires_in=3600 How this should be parsed?

I image route definition similar to this:

#[route("/callback#:fragment")]

and then fragment should be something that implements FromQuery? Right?

That route definition looks correct. Fragments may look like a query, but we don't want to force them to look like a traditional query segment (name=bla&surname=bla). We can use a trait with an identical signature to FromQuery called FromFragment or just accept T: FromStr<Err = core::convert::Infallible> instead of FromQuery and FromFragment

@kalzoo
Copy link

kalzoo commented Mar 27, 2024

Just a note: this bug prevents the use of the OAuth2 Implicit Grant flow with some providers. That includes Google as @SET001 mentioned, and also AWS: https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html.

Implicit grant flow returns tokens in the fragment; auth code flow returns them in the query string. I tried this workaround in the hope that the first render would take place before the fragment was removed by Dioxus, but no luck:

    use web_sys::window;
    let hash = window().unwrap().location().hash().unwrap();
    let params_parsed: HashMap<String, String> = serde_urlencoded::from_str(&hash).unwrap();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working router Related to the router implementation web relating to the web renderer for dioxus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants