koajs / router

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

Improve path checking before route registration #155

Closed peterver closed 2 years ago

peterver commented 2 years ago

Checklist

fixes: #147, #148

peterver commented 2 years ago

@wengeezhang @etroynov kindly review once you find some time in your busy schedules

etroynov commented 2 years ago

@3imed-jaberi @niftylettuce can you review it?

etroynov commented 2 years ago

I also recommend you change the title, because someone may not understand that PR is about a specific issue.

It could be something like: Improve path checking before route registration

and add in description: fix for issue #147 - it will link your PR with this issue

p.s thx for your help.

peterver commented 2 years ago

I also recommend you change the title, because someone may not understand that PR is about a specific issue.

It could be something like: Improve path checking before route registration

and add in description: fix for issue #147 - it will link your PR with this issue

p.s thx for your help.

@etroynov should be done, I've also improved on the verb specific test by running it against all methods exported in the methods module used by the router, let me know if you agree with that approach. Ps: No worries, happy to help :)

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.

peterver commented 2 years ago

You could probably move those checks to a function isValidPath instead but otherwise looks alright. 👍🏻

@SagnikPradhan Agree :). I'll take a look either tonight or tomorrow to move those bits into utility functions, there's some other parts of the validation which could use some abstraction to ensure code readability, of course I'll write some tests for any PR I open, thanks for the tip :).

peterver 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.

@titanism awesome! I'll regularly check in and chip in where possible, we're heavy users of koa and koa-router and would want to help maintain :)