koajs / router

Router middleware for Koa. Maintained by @forwardemail and @ladjs.
MIT License
849 stars 174 forks source link

better to check path before register #147

Closed wengeezhang closed 2 years ago

wengeezhang commented 2 years ago

if you add handler like this:

router.get((ctx, next) => {})

you'll get an error like this:

Uncaught TypeError: Unexpected CHAR at 1, expected END

The error message is less helpful for user to find the bug.

so it's better to check path before call register. if path not provide, just provide a clear error message like this:

Error: You have to provide a path for get
wengeezhang commented 2 years ago

please check pr #148

titanism commented 2 years ago

We have just published @koajs/router v11.0.0 which resolves this issue. This is mirrored to koa-router as well.

https://github.com/koajs/router/releases/tag/v11.0.0

This project is maintained by Forward Email and Lad.