delvedor/find-my-way

Incorrect parametric brother route set up.

ivan-tymoshenko opened this issue · 2 comments

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

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

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' })