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

Duplicate named parameters in route #34

Open
Tracked by #28
gameldar opened this issue Aug 13, 2019 · 0 comments · May be fixed by #39
Open
Tracked by #28

Duplicate named parameters in route #34

gameldar opened this issue Aug 13, 2019 · 0 comments · May be fixed by #39

Comments

@gameldar
Copy link

You can currently define duplicate named parameters in the route with the last one resolved being the end value. E.g. given the following:

#[test]
fn duplicate_key() {
    let mut router = Router::new();

    router.add("/foo/:bar/*bar", "test".to_string());
    let m = router.recognize("/foo/blah/this/is/the/rest").unwrap();
    assert_eq!(*m.handler, "test".to_string());
    assert_eq!(m.params, params("bar", "blah"));
}

this fails with:

thread 'duplicate_key' panicked at 'assertion failed: `(left == right)`
  left: `Params { map: {"bar": "this/is/the/rest"} }`,
 right: `Params { map: {"bar": "blah"} }`', src\lib.rs:339:5

This should probably be prevented when the route is created - given that you can define nameless parameters I can't see a reason for needing to have duplicate names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant