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 () {
var router = new Router()
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:
[ 'acl',
'bind',
'checkout',
'connect',
'copy',
'delete',
'get',
'head',
'link',
'lock',
'm-search',
'merge',
'mkactivity',
'mkcalendar',
'mkcol',
'move',
'notify',
'options',
'patch',
'post',
'propfind',
'proppatch',
'purge',
'put',
'rebind',
'report',
'search',
'subscribe',
'trace',
'unbind',
'unlink',
'unlock',
'unsubscribe' ]
Not sure if this is a new things in node 6, I'm running
6.1.0, but the corehttp.methodsinclude the httpBINDmethod. When we loop the methods we end up overridingfunction.bindon 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:
.bindI 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: