Host constraint breaks with 32 handlers
valeneiko opened this issue · 1 comments
valeneiko commented
If I add 32 handlers with host constraints, then none of the handlers will match and no errors are thrown.
const router = require('find-my-way')();
const N = 32;
for (let i = 0; i < N; i++) {
const host = `h${i.toString().padStart(2, '0')}`;
router.on('GET', '/', { constraints: { host } }, () => { });
}
const result = router.find('GET', '/', { host: 'h01' });
console.log(result); // --> null
If I change N
to 33
then error is thrown from the code below:
find-my-way/lib/handler-storage.js
Lines 50 to 52 in ca54d8d
mcollina commented
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.