You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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');constKoa=require('koa');constapp=newKoa();constrouter=newCottage();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 errorrouter.use((ctx)=>{console.log(Date.now(),'wildcard',ctx.url);ctx.body='wildcard';});app.use(router.callback());app.listen(8080);
Navigating to /a returns a
Navigating to /ab returns Not Found
Navigating to /b returns wildcard
Environment
Cottage: v3.1.3 (npm latest)
The text was updated successfully, but these errors were encountered:
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
/a
returnsa
/ab
returnsNot Found
/b
returnswildcard
Environment
Cottage: v3.1.3 (npm latest)
The text was updated successfully, but these errors were encountered: