-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Regex in path? #391
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
Comments
Nope. Just make three routes that use the same handler. |
Hm, this is an old issue, but in my current team we have this issue:
or
The first one works, but not providing a meaningful path for packages/components relying on the path hierarchy, for example If the path had regex support, we could solve this in a better way (with correct hierarchy) |
@ryanflorence sorry for mentioning you here. But as this thread is closed I just wanted you to notice it again or maybe reopen it. There are things that can be done easily by regex and to so with current wildcard used in I guess you're aware of this but let me know if we need a list of things that current wildcard system fails to do and regex can. If we try to expand its functionality as discussed here #142 we'll end up reinventing regex. I think best would be to support regex just like Django does for example: https://docs.djangoproject.com/en/1.10/topics/http/urls/ |
For me too, dealing with The most interesting part is, as far as I can see, that EDIT: Something like this #4900 might do? The tests pass and it works in my cases, not sure if it's okay for other dependent packages, like the native routing for example. |
react router 4 support regex paths, eg: <Route exact path="/commit/:git_commit([0-9a-fA-f]{40})" component={ViewCommit} /> |
I don't think it does support Regex, the link above requires payment, and I only see A React Router 4 solution using string paths and a Regexp in the <Switch>
{ ...other routes }
<Route
path="/:slug"
exact
strict
render={({ match }) => {
if (!/^[A-Za-z0-9]{6}$/.test(match.params.slug)) {
return <NotFound />;
}
return <CommitmentPage />;
}}
/>
<Route component={NotFound} />
</Switch> Here |
React Router 4 does support regex. He provided an example apart from the link. |
Ah oops nice one, the |
Related to remix-run#391 and this example remix-run#391 (comment)
* Example with regex in path Related to #391 and this example #391 (comment) * Add comment to better explain how regexes work with path
This wiki supports hierarchy b/w articles. For example, an article 'ab/cd' is under the 'ab' article conceptually. For this purpose, article id need to be able to include slash. References: - remix-run/react-router#391 (comment) - https://stackoverflow.com/questions/10020099/express-js-routing-optional-spat-param/14481168#comment49246489_29549148
This wiki supports hierarchy b/w articles. For example, an article 'ab/cd' is under the 'ab' article conceptually. For this purpose, article id need to be able to include slash. References: - remix-run/react-router#391 (comment) - https://stackoverflow.com/questions/10020099/express-js-routing-optional-spat-param/14481168#comment49246489_29549148
@timdorr Can we please remove the shameless ad up there with paywalled article on egghead? |
Hi, any option for negative regexp. I have 2 routes I've tried this: |
@Mindaugas-Jacionis I guess it is not the solution you wanted but will work.
When you place it like this in the switch component, the |
Hello,
Is there a provision for something like
<Route name="EventListing" path={/\/(movies|concerts|plays)/} handler={EventsList} />
?The text was updated successfully, but these errors were encountered: