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

Incorrect parametric brother route set up. #222

Closed
ivan-tymoshenko opened this issue Dec 23, 2021 · 2 comments
Closed

Incorrect parametric brother route set up. #222

ivan-tymoshenko opened this issue Dec 23, 2021 · 2 comments

Comments

@ivan-tymoshenko
Copy link
Collaborator

Sometimes it sets a non-nearest parametric brother route. Static route /text/hello will have /:c as a parametric brother, but should have text/:e/test.

It's not the same issue with (#221)

router.on('GET', '/text/hello', () => {})
router.on('GET', '/text/:e/test', () => {})
router.on('GET', '/:c', () => {})

assert.equal(router.find('GET', '/text/hellos/test'), null) // shouldn't be null
@mcollina
Copy link
Collaborator

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@ivan-tymoshenko
Copy link
Collaborator Author

If you set up routes in a different order this will work

router.on('GET', '/:c', () => {})
router.on('GET', '/text/hello', () => {})
router.on('GET', '/text/:e/test', () => {})

assert.deepEqual(router.find('GET', '/text/hellos/test').params, { e: 'hellos' })

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