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

Router switch can't pass down query string (and other special parts) #1575

Closed
siku2 opened this issue Sep 20, 2020 · 1 comment · Fixed by #1791
Closed

Router switch can't pass down query string (and other special parts) #1575

siku2 opened this issue Sep 20, 2020 · 1 comment · Fixed by #1791
Labels
A-yew-router Area: The yew-router crate bug

Comments

@siku2
Copy link
Member

siku2 commented Sep 20, 2020

Best explained by looking at the following example:

#[derive(Clone, Debug, Switch)]
pub enum PostsRoute {
    #[to = "/{}"]
    Id(u64),
    #[to = "/?page={}"]
    ListPage(u64),
    #[to = "/"]
    List,
}

#[derive(Clone, Debug, Switch)]
pub enum AppRoute {
    #[to = "/posts{*}"]
    Posts(PostsRoute),
}

This feels like it should work. In fact, one of the example in yew-router uses this exact pattern (BRoute is used like PostsRoute here).

The route "/posts/?page=5" will still match PostsRoute::List instead of PostsRoute::ListPage(5) because "?page=5" isn't passed down. PostsRoute only ever receives "/".

This is because {*} stops capturing as soon as it sees " #&?=".
This behaviour is certainly desired when capturing simple values like strings but in this case it's rather unfortunate.

I don't have a proposal to offer because there will be significant changes to the router anyway and this issue should be considered in the new design.

@siku2 siku2 added bug A-yew-router Area: The yew-router crate labels Sep 20, 2020
@thedodd
Copy link
Contributor

thedodd commented Oct 9, 2020

I find myself in need of this at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew-router Area: The yew-router crate bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants