Skip to content

Duplicate named parameters in route #34

@gameldar

Description

@gameldar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions