solid-router icon indicating copy to clipboard operation
solid-router copied to clipboard

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

Open N0tExisting opened this issue 3 years ago • 3 comments

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/>} />

N0tExisting avatar Jun 17 '22 15:06 N0tExisting

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'] }} />

orenelbaum avatar Dec 07 '22 13:12 orenelbaum

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

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

JorrenH avatar Jan 20 '23 16:01 JorrenH

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.

fabiospampinato avatar Mar 12 '23 14:03 fabiospampinato