delvedor/find-my-way

Incorrect switch to parametric brother route

ivan-tymoshenko opened this issue · 1 comments

When the node switches to the parametric brother node, the path doesn't change correctly. This can lead to such errors. When only the first route is registered, the execution goes without switches and is executed correctly, but if two routes are registered, after switching it will match not the parameter 1111, but the entire path prefix1111.

const assert = require('assert')
const router = require('find-my-way')()

router.on('GET', '/prefix-:id', () => {})

assert.notEqual(router.find('GET', 'prefix1111'), null)

router.on('GET', '/prefix-111', () => {})

assert.equal(router.find('GET', 'prefix1111'), null) // shouldn't be null

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