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
The regexparam library allows for passing RegExp through parse. I think it would be a useful feature to be able to use custom regular expressions for routes.
If it doesn't match, it will continue on to the 404 page.
This uses a named capture group so it could be a direct drop in for "/:id".
Alternatively, a normal regex could be used:
/^[/](\d+)$/// Then consumed like:constparams=useParams();constid=params[1];
This allows for lifting validation out of routes.
Patterns like route prefixes (/@:username) and multiple params in a single segment (/:id-:opt) becomes possible.
And since it builds upon functionality that is already here, it won't cost much to implement.
The text was updated successfully, but these errors were encountered:
The
regexparam
library allows for passingRegExp
throughparse
. I think it would be a useful feature to be able to use custom regular expressions for routes.For example:
id
will match anything. But if we know that an ID will only be digits, it would be nice to use a regex to validate it:If it doesn't match, it will continue on to the 404 page.
This uses a named capture group so it could be a direct drop in for
"/:id"
.Alternatively, a normal regex could be used:
This allows for lifting validation out of routes.
Patterns like route prefixes (
/@:username
) and multiple params in a single segment (/:id-:opt
) becomes possible.And since it builds upon functionality that is already here, it won't cost much to implement.
The text was updated successfully, but these errors were encountered: