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

Define two routes on one single param prefix #28

Open
maybephilipp opened this issue Jun 9, 2024 · 3 comments · May be fixed by #29
Open

Define two routes on one single param prefix #28

maybephilipp opened this issue Jun 9, 2024 · 3 comments · May be fixed by #29

Comments

@maybephilipp
Copy link

maybephilipp commented Jun 9, 2024

Hello! Thank you for this package!

I have an issue defining two subpaths for single-wildcarded route prefix:

const socialTypeWildGroup = authRouteGroup.newGroup('/:socialType')

socialTypeWildGroup.delete('/foo', async (ctx) => {})
socialTypeWildGroup.get('/bar', async (ctx) => {})

The router throws: Error: wildcard route ':socialType' conflicts with existing children in path '/api/auth/:socialType/bar'

What am I doing wrong?

@maybephilipp
Copy link
Author

UPD:

So the issue is because I had routes defined in the following order:

GET /twitter/authenticate
GET /:socialType/callback

In my point of view the logic must be the following: if there is exact match - use it, otherwise - use wildcard.

I've investigated the root cause of it and updated implementation to support such cases. I will open a PR soon.

The following issue seems to be the same kind of issue: #19

@maybephilipp
Copy link
Author

@steambap Please review this PR at your convenience. Let me know if you have any concerns/additions. I will publish & use my own version for now. Thanks!

@maybephilipp
Copy link
Author

For anyone who want to try the version of pkg with the fix, install: @ogc/koa-tree-router

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

Successfully merging a pull request may close this issue.

2 participants
@maybephilipp and others