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

Allow + quantifier into path pattern #2134

Closed
lazdmx opened this issue May 23, 2014 · 3 comments
Closed

Allow + quantifier into path pattern #2134

lazdmx opened this issue May 23, 2014 · 3 comments

Comments

@lazdmx
Copy link

lazdmx commented May 23, 2014

Idea is simple. Addressable resources in hierarchy may have url like /a/b/c/..... So I can GET /a/b or GET /a but cannot GET /a/c. To handle it I simply define path by regexp and it works well, but I think that + quantifier will help to save a couple of lines of code.

That is I would define path like this /:id+ and if it applied to path /a/b/c then req.params.id should have [ 'a', 'b', 'c' ]

My suggestion is to add + quantifier that allow to define

@dougwilson
Copy link
Contributor

You will need to file an issue at https://github.com/component/path-to-regexp which is the engine we use.

@lazdmx
Copy link
Author

lazdmx commented May 23, 2014

I thought about it before issue a ticket, but this task cannot be completed only by regexp, since regexp may only match a group but group must be processed ( splitted ) elsewhere.

But it seems like implementation implies changes in architecture, so maybe you should consider it in next release and do not use only regexp-based match but more featured engine and provide even more places where custom logic can be bound.

@dougwilson
Copy link
Contributor

From what I understood from your initial post RegExp can, but re-reading your post I realize I don't know what you're asking anyway. Are you saying you want a way to enforce some kind of ordering? Like you want to match /1/2/3 but not /1/3 since they are not sequential?

Anyway, we provide a way to implement your own custom logic: app.use(). You can do whatever routing and patch matching you want in there.

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

No branches or pull requests

2 participants