Wildcard node should be checked for constraints
ivan-tymoshenko opened this issue · 1 comments
ivan-tymoshenko commented
If a wildcard node does not pass constraints check we will return the default route even if there is another wildcard node that matches constraints.
There is a test for this case:
test('Wildcard node with constraints', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.fail('we should not be here, the url is: ' + req.url)
}
})
findMyWay.on('GET', '*', (req, res, params) => {
t.equal(params['*'], '/foo1/foo3')
})
findMyWay.on('GET', '/foo1/*', { host: 'fastify.io' }, (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})
findMyWay.on('GET', '/foo1/foo2', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})
findMyWay.lookup(
{ method: 'GET', url: '/foo1/foo3', headers: {} },
null
)
})
ivan-tymoshenko commented
I will fix it when I have some time. I just leave it here to remember.