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
Not sure if this is a new things in node 6, I'm running 6.1.0, but the core http.methods include the http BIND method. When we loop the methods we end up overriding function.bind on the router instance causing weird behavior. The test that broke was as follows:
it('should reject missing callback',function(){varrouter=newRouter()assert.throws(router.bind(router,{},{}),/argument callback is required/)})
The intent here is obvious, but it ended up calling the method setup here.
There are three solutions I can see:
Filter out known bad names (aka blacklist)
Only generate known good methods (aka whitelist)
Document the fact that we overrode .bind
I can make a PR either way but wanted to open the discussion first.
Also for reference, here is the list I got by logging the methods array:
So since I noticed this from a 5.x release back in January, I've through a bunch about it, because it affects this module and Express itself. I think that if we want to continue to do router[method] style, the methods should be a static list, not dynamic, and we should have an additional API that takes a method name so people can use any method they want to use as well. This would also have the benefit for things like TypeScript and JSDoc comments to actually function with the methods, since they won't be auto-generated.
Not sure if this is a new things in node 6, I'm running
6.1.0
, but the corehttp.methods
include the httpBIND
method. When we loop the methods we end up overridingfunction.bind
on the router instance causing weird behavior. The test that broke was as follows:The intent here is obvious, but it ended up calling the method setup here.
There are three solutions I can see:
.bind
I can make a PR either way but wanted to open the discussion first.
Also for reference, here is the list I got by logging the methods array:
The text was updated successfully, but these errors were encountered: