From: Matyáš Racek Date: Tue, 9 Jul 2024 07:59:50 +0000 (+0200) Subject: docs: mention an edge case with mutliple optional params in the docs (#2192) X-Git-Tag: v4.4.1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=305299ff88a0e0421a1bfec630ce20b09b7c17f4;p=thirdparty%2Fvuejs%2Frouter.git docs: mention an edge case with mutliple optional params in the docs (#2192) * docs: mention an edge case with mutliple optional params in the docs See #2190 for more info. * Update packages/docs/guide/essentials/route-matching-syntax.md --------- Co-authored-by: Eduardo San Martin Morote --- diff --git a/packages/docs/guide/essentials/route-matching-syntax.md b/packages/docs/guide/essentials/route-matching-syntax.md index e110f8f5..7508993b 100644 --- a/packages/docs/guide/essentials/route-matching-syntax.md +++ b/packages/docs/guide/essentials/route-matching-syntax.md @@ -114,6 +114,13 @@ const routes = [ Note that `*` technically also marks a parameter as optional but `?` parameters cannot be repeated. +If the route segment contains more than **just an optional parameter**, it won't match a path **without the trailing slash**. For example: + +- `/users/:uid?-:name?` won't match `/users`, only `/users/-` or even `/users/-/` +- `/users/:uid(\\d+)?:name? won't match `/users`, only `/users/`, `/users/2`, `/users/2/`, etc + +You can play around with the matching syntax [in the playground](https://paths.esm.dev/?p=AAMsIPQg4AoKzidgQFoEXAmw-IEBBRYYOE0SkABTASiz1qgBpgQA1QTsFjAb3h2onsmlAmGIFsCXjXh4AIA.&t=/users/2/#) + ## Debugging If you need to dig how your routes are transformed into a regex to understand why a route isn't being matched or, to report a bug, you can use the [path ranker tool](https://paths.esm.dev/?p=AAMeJSyAwR4UbFDAFxAcAGAIJXMAAA..#). It supports sharing your routes through the URL.