-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Current behavior
Registering a middleware with a given path (for example /a) and a wildcard path (*) on the same Router instance will cause the wildcard middleware handler to not be called if the path we navigate to starts with the given path (for example /b will work, but /ab will return a 404 page).
Using a param handler instead of a wildcard middleware (.get('/:param', () => {...})) results in the same behavior.
Expected behavior
The wildcard middleware handler should be called if the path doesn't match.
Reproduction
const {Cottage} = require('cottage');
const Koa = require('koa');
const app = new Koa();
const router = new Cottage();
router.use('/a', (ctx) => {
console.log(Date.now(), 'a', ctx.url);
ctx.body = 'a';
});
// Path is implicitly '*'
// Replacing this with `router.get('/:param', ...)` also results in an error
router.use((ctx) => {
console.log(Date.now(), 'wildcard', ctx.url);
ctx.body = 'wildcard';
});
app.use(router.callback());
app.listen(8080);- Navigating to
/areturnsa - Navigating to
/abreturnsNot Found - Navigating to
/breturnswildcard
Environment
Cottage: v3.1.3 (npm latest)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels