Skip to content

Panic when inserting routes without leading slash #82

@ck961018

Description

@ck961018

Description

  • Pass: Inserting "{foo}/" then "foo/".
  • Panic: Inserting "foo/" then "{foo}/".

Reproduction

#[test]
fn local_test() {
    InsertTest(vec![("{foo}/", Ok(())), ("foo/", Ok(()))]).run(); // ok
    InsertTest(vec![("foo/", Ok(())), ("{foo}/", Ok(()))]).run() // panic
}

Investigation

// tree.rs
if common_remaining[common_prefix - 1] != b'/'
    && node.suffix_wild_child_in_segment()
{
    return Err(InsertError::conflict(&route, remaining, node));
}

common_prefix is 0 when routes do not have a leading slash,

Question

With a leading slash, this will not be a problem.
But i found some routes in test do not have the leading slash.
Is matchit intended to support routes without the leading slash?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions