The Wayback Machine - https://web.archive.org/web/20201207165406/https://github.com/pillarjs/path-to-regexp/issues/235
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

How to match /foo/create OR /foo/:id? #235

Open
realnot opened this issue Nov 30, 2020 · 1 comment
Open

How to match /foo/create OR /foo/:id? #235

realnot opened this issue Nov 30, 2020 · 1 comment
Labels

Comments

@realnot
Copy link

@realnot realnot commented Nov 30, 2020

I would like to match both urls as title. If :id is not passed as parameter, then match create. I tried something similar: (:id?|create) without success. I would like to match the following urls:

/foo/123/ (the :id param can be alphanumeric)
/foo/create/

/foo/123/create <-- not valid
/foo/create/123 <-- not valid

@realnot realnot changed the title How to match /foo/create and /foo/:id? How to match /foo/create OR /foo/:id? Nov 30, 2020
@blakeembrey
Copy link
Member

@blakeembrey blakeembrey commented Dec 1, 2020

You can pass an array of paths. You cannot put a param inside a matching group. For example, ['/foo/create', '/foo/:id'].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.