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
Optional group with param compile #142
Comments
No, it's not possible like that. You can't embed params inside a matching group, it's a regexp expected inside there. It could be possible to consider this in future releases, but right now the only way to do it is to create two separate paths and use an array or use a regexp. |
Another idea would be to introduce nested groups that support paths instead of regexps and may solve a couple of other issues people are struggling with also. Something like:
The parts inside |
Fair enough, thanks for replying. Yeah, introducing First extract groups then perform usual regex conversion to whatever is inside |
Actually with version 0.1.7 this has worked. Check here: http://forbeslindesay.github.io/express-route-tester/ |
@delijah I'm not sure anyone is arguing against that, but 0.1.x had a host of other bugs that resulted from being able to write paths like this. It was never an official feature, there was a lot of things you could do with it because it was extremely lax. |
Any progress on this? |
@delijah The best way to get progress on this is to submit a PR. I don't think the feature is particularly clear on possible edge cases right now (probably clearer once someone implements it) and it will need enough test coverage to ensure it works correctly. |
I tried implementing this, but one unclear feature is how |
@blakeembrey For the path |
@Tofandel That example is the really only the tip of the iceberg, what about I think I can make an attempt now that we refactored the parser though, and for now make the assumption OP does - if the first isn’t filled then nested gets ignored. |
Regarding nesting it would work as you'd expect
That's really all the edge cases I see |
Cool, feel free to submit a PR! Maybe some more will come up when you try implementing it, I recall running into issues when I actually tried to code it but that was also over two years back now. |
are you need |
No, I don't need it |
There are some issues: #95, #106 but I'm not sure if that is the same case.
I want to achieve something like optional group matching based on presence of a parameter and being able to compile path back.
I'd like to define a path like:
And the first segment will be returned only if
:one
parameter is present:Ideally I'd like to have some nested groups:
Is this even possible using this library?
The text was updated successfully, but these errors were encountered: