Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature ✨]: Support tagged template literals for multiple paths #127

Open
N0tExisting opened this issue Jun 17, 2022 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@N0tExisting
Copy link

N0tExisting commented Jun 17, 2022

With the introduction of having multiple paths for one route, it might be useful to have a way to have an option in an arbitrary place in a path eg. using tagged template literals like so:

<Route path={path`example/${["foo", "bar"]}/thing?`} element={<Example/>} />
@ryansolid ryansolid added the enhancement New feature or request label Nov 21, 2022
@orenelbaum
Copy link
Contributor

orenelbaum commented Dec 7, 2022

Maybe it would make more sense to use some special pattern for this?
Maybe '/example/(foo|bar)/thing?'.
Another option:
<Route path="/example/:name/thing?" allowedParams={{ name: ['foo', 'bar'] }} />

@JorrenH
Copy link
Contributor

JorrenH commented Jan 20, 2023

@orenelbaum your last suggestion is now possible with #227 using the following:

<Route path="/example/:fooBar/thing?" matchFilters={{ fooBar: ['foo', 'bar'] }} element={<Example/>} />

@fabiospampinato
Copy link

fabiospampinato commented Mar 12, 2023

Maybe '/example/(foo|bar)/thing?'.

/example/(foo|bar)/thing? would be a valid Express path by the way, if the router switched to that this would work out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants