matchit icon indicating copy to clipboard operation
matchit copied to clipboard

Support escaping `:` and `*`

Open hgzimmerman opened this issue 3 years ago • 2 comments

I'm using this library by proxy of Axum, and ran into an issue in that the router would not accept path segments that contained multiple : characters, greeting me with the error: Invalid route "/Schemas/urn:ietf:params:scim:schemas:core:2.0:User": only one parameter is allowed per path segment, corresponding to the TooManyParams error variant defined in this crate.

Could either the syntax be altered to support escaping the : and * characters with a prefix like \, or have the insert method treat the whole path section as a literal if it doesn't start with a : or *, or add an .insert_components() function that takes a slice of enum Component<'a>{Literal(&'a str), Param, Wildcard, Separator} and uses that to determine the matching criteria?

hgzimmerman avatar Aug 28 '22 23:08 hgzimmerman

I think escaping with \ makes sense. /prefix:parameter is accepted by matchit, which makes the second option more difficult.

ibraheemdev avatar Sep 01 '22 16:09 ibraheemdev

Just opened this (and linked) from Axum. I would also like to propose using /{id} for path pattern matching, to align with the OpenAPI spec.

DavidSouther avatar Oct 07 '22 21:10 DavidSouther

With the release of 0.8, the route parameter syntax has changed to use {x} or {*x}. You can escape literal { and } characters with {{ and }} in static routes.

ibraheemdev avatar Mar 10 '24 21:03 ibraheemdev