-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add Support for Parameter Suffixes #61
Conversation
2aa0ba7
to
efb488e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've been looking forward to this.
I have a case in which I'd like to use this for two file suffixes, one of which is a prefix of the other. It appears to fail as follows:
#[test]
fn wildcard_suffix2() {
MatchTest {
routes: vec![
"/{foo}.ts",
"/{foo}.tst",
],
matches: vec![
("/bar.ts", "/{foo}.ts", p! {}),
("/bar.tst", "/{foo}.tst", p! {}),
],
}
.run();
}
---- wildcard_suffix2 stdout ----
thread 'wildcard_suffix2' panicked at tests/match.rs:78:13:
assertion `left == right` failed: /{foo}.tst
left: Err(Conflict { with: "/{foo}.ts" })
right: Ok(())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Yeah that seems reasonable, I think we can support it. |
79b0067
to
709a95f
Compare
I updated the implementation to support overlapping suffixes, such as |
dee1bd3
to
00fcc28
Compare
00fcc28
to
3ce31bc
Compare
Adds support for parameters with static suffixes. For example,
/{foo}.png
.The implementation allows parameters with and without suffixes to co-exist. For example,
/foo
,/{foo}.jpg
, and/{foo}.png
are not considered overlapping. This works by adding another layer to the tree after parameter nodes, representing suffixes before the next route segment. The appropriate suffix is determined using a linear search.Additionally, the restriction of a single parameter per route segment still remains. This means
/{foo}.{bar}
is not supported. Arbitrary parameters without a/
anchor can become quite complicated in terms of backtracking (similar to #41 (comment)), so multiple parameters are unlikely to be supported.Resolves #17.