You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should be considered conflicting. The only way out is to prioritize either prefixes or suffixes, or to prioritize the longer/shorter prefix/suffix and conflict or fallback in the case that they are equal, neither of which seems more intuitive than the other.
/prefix{wild} and prefix{wild}suffix
/{wild}suffix and prefix{wild}suffix
This case is a little more nuanced and only ambiguous if the prefixes or suffixes match. It seems reasonable to prefer the second route in both cases, but this may be difficult to implement. It also becomes more unintuitive with mixed length prefixes/suffixes, e.g.
/prefixsuffi{x} and prefix{s}uffix
/{p}refixsuffix and prefix{s}uffix
So I think these should also be considered conflicting. Disallowing ambiguous routes within a segment should make the routing rules intuitive and easy to document overall.
The text was updated successfully, but these errors were encountered:
Work in progress on this branch that implements the new rules:
A given list of overlapping route segments can include, in order of priority,
Any number of static segments (/a, /b, ..).
One of the following:
Any number of parameters with suffixes (/{x}a, /{x}b, ..), prioritizing the longest suffix.
Any number of parameters with prefixes (/a{x}, /b{x}, ..), prioritizing the longest prefix.
A single parameter with both a prefix and a suffix (/a{x}b).
A single parameter without a suffix or prefix (/{x}).
In short, any prefix conflicts with a suffix, and vice versa. However, there are a number of different cases to check when inserting and the code also has to be restructured a little bit to keep track of parent and sibling nodes while inserting.
Pointed out in tokio-rs/axum#3140. Quoting from there:
I think there are three cases to consider:
/prefix{wild}
and{wild}suffix
This should be considered conflicting. The only way out is to prioritize either prefixes or suffixes, or to prioritize the longer/shorter prefix/suffix and conflict or fallback in the case that they are equal, neither of which seems more intuitive than the other.
/prefix{wild}
andprefix{wild}suffix
/{wild}suffix
andprefix{wild}suffix
This case is a little more nuanced and only ambiguous if the prefixes or suffixes match. It seems reasonable to prefer the second route in both cases, but this may be difficult to implement. It also becomes more unintuitive with mixed length prefixes/suffixes, e.g.
/prefixsuffi{x}
andprefix{s}uffix
/{p}refixsuffix
andprefix{s}uffix
So I think these should also be considered conflicting. Disallowing ambiguous routes within a segment should make the routing rules intuitive and easy to document overall.
The text was updated successfully, but these errors were encountered: