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

Optional matching? #19

Open
esDotDev opened this issue Apr 14, 2021 · 5 comments
Open

Optional matching? #19

esDotDev opened this issue Apr 14, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@esDotDev
Copy link

esDotDev commented Apr 14, 2021

Curious if there is a way to define '/user/:id' so that it will match /user /user/ and /user/1 ?

Similarly, could we define billing/:foo/:bar so that only :foo is required and bar is optional?

@shovelmn12
Copy link

you can do it by setting prefix to true...

what we need is a 'any' match for example: /path/to.* so everything that starts with /path/to go there...

@leonsenft
Copy link
Owner

No, this package doesn't currently support optional parameters, although it seems like a reasonable feature.

As a workaround you could potentially just define multiple matchers per route (or multiple routes) to support this.

@leonsenft leonsenft added the enhancement New feature or request label May 7, 2021
@leonsenft
Copy link
Owner

you can do it by setting prefix to true...

I don't think that would meet the requirements requested here. That approach means something like /user/anything would match as well, which is probably not desired.

@esDotDev
Copy link
Author

esDotDev commented May 7, 2021

Right, the "aliases" approach is basically how we deal with this now, so you would need to define a path value of:
["user", "user/", "user/:id"]

This request is basically asking to not have to do that, but instead some streamlined syntax to express this.

@clragon
Copy link

clragon commented May 15, 2022

are there any changes we will eventually get this feature?

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

No branches or pull requests

4 participants