-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
What's the recommended way to handle path parameters that may contain slashes?
For example, we have a /docs/ path in our app that contains nested paths or arbitrary length. For example:
/docs/foo
/docs/foo/
/docs/foo/bar
/docs/foo/bar/baz
We can match these paths in regexparam using /docs/* which works fine if all we want to do is match the path without extracting the param value, but if we want to extract that param:
- Using a
*parameter name is weird DX because it requires usingparams['*']syntax instead of the more familiarparams.restsyntax. This also makes IDE autocomplete problematic; in VSCode, autocomplete won't work when you typeparams.so it's harder for developers to discover that param, although if you know to typeparams.['then it may work. (BTW, worse autocomplete was a tradeoffs of changing fromwildto*for the wildcard parameter name.) - I must manually strip trailing slashes, which makes the behavior of wildcard params different from all other params where slashes are automatically stripped by default.
Is there a solution for slashful params other than building our own Regex? (Where we'll also lose the nice DX and autocomplete because TS literal types won't work with regexes)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels