-
Notifications
You must be signed in to change notification settings - Fork 368
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
Do not match certain words as parameters with path-to-regexp #268
Comments
Does “the best regex trick” work for your needs? I think it would express your example as |
+1 here. I'm facing the same issue right now. |
If someone wants to propose expanding the existing syntax to support this, I'm happy to review. Otherwise I'd suggest maybe filing a ticket with the libraries using this package to support this feature. It's definitely easier than trying to construct a negative regex. For example, in something like Express you can have middleware that runs and write a line of code that says |
I have a route
/:parameter
and if someone pings that route I should serve him certain page (React App)So what I need is some kind of regexp that wont match certain words...
Regular expression should be
^(?!.*(foobar1|\/foobar2)).*$
https://pshrmn.github.io/route-tester/#/ I've used this tool for testing and entered various combinations, such as
/parameter(?!.*(foobar1|\/foobar2))
but no luck...So test case should be
if path is
/foobar3
it should return pageif path is
/foobar2
or/foobar3
it should returnnull
The text was updated successfully, but these errors were encountered: