diff --git a/README.md b/README.md index 0de00ac..830b2ee 100644 --- a/README.md +++ b/README.md @@ -126,9 +126,9 @@ var methodOverride = require('method-override') var app = express() // override with different headers; last one takes precedence -app.use(methodOverride('X-HTTP-Method')) // Microsoft +app.use(methodOverride('X-HTTP-Method')) // Microsoft app.use(methodOverride('X-HTTP-Method-Override')) // Google/GData -app.use(methodOverride('X-Method-Override')) // IBM +app.use(methodOverride('X-Method-Override')) // IBM ``` ### custom logic diff --git a/package.json b/package.json index fff000a..213c269 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,13 @@ "vary": "~1.1.2" }, "devDependencies": { - "eslint": "3.19.0", - "eslint-config-standard": "10.2.1", - "eslint-plugin-import": "2.11.0", + "eslint": "4.19.1", + "eslint-config-standard": "11.0.0", + "eslint-plugin-import": "2.13.0", "eslint-plugin-markdown": "1.0.0-beta.6", - "eslint-plugin-node": "5.2.1", - "eslint-plugin-promise": "3.7.0", - "eslint-plugin-standard": "3.0.1", + "eslint-plugin-node": "6.0.1", + "eslint-plugin-promise": "3.8.0", + "eslint-plugin-standard": "3.1.0", "istanbul": "0.4.5", "mocha": "2.5.3", "supertest": "1.1.0" diff --git a/test/test.js b/test/test.js index 3fd74aa..e6dd59b 100644 --- a/test/test.js +++ b/test/test.js @@ -7,16 +7,16 @@ describe('methodOverride(getter)', function () { it('should not touch the method by default', function (done) { var server = createServer() request(server) - .get('/') - .expect('X-Got-Method', 'GET', done) + .get('/') + .expect('X-Got-Method', 'GET', done) }) it('should use X-HTTP-Method-Override by default', function (done) { var server = createServer() request(server) - .post('/') - .set('X-HTTP-Method-Override', 'DELETE') - .expect('X-Got-Method', 'DELETE', done) + .post('/') + .set('X-HTTP-Method-Override', 'DELETE') + .expect('X-Got-Method', 'DELETE', done) }) describe('with query', function () { @@ -24,27 +24,27 @@ describe('methodOverride(getter)', function () { var server = createServer('_method') request(server) - .post('/') - .set('Content-Type', 'application/json') - .expect('X-Got-Method', 'POST', done) + .post('/') + .set('Content-Type', 'application/json') + .expect('X-Got-Method', 'POST', done) }) it('should be case in-sensitive', function (done) { var server = createServer('_method') request(server) - .post('/?_method=DELete') - .set('Content-Type', 'application/json') - .expect('X-Got-Method', 'DELETE', done) + .post('/?_method=DELete') + .set('Content-Type', 'application/json') + .expect('X-Got-Method', 'DELETE', done) }) it('should ignore invalid methods', function (done) { var server = createServer('_method') request(server) - .post('/?_method=BOGUS') - .set('Content-Type', 'application/json') - .expect('X-Got-Method', 'POST', done) + .post('/?_method=BOGUS') + .set('Content-Type', 'application/json') + .expect('X-Got-Method', 'POST', done) }) it('should handle key referencing array', function (done) { @@ -60,9 +60,9 @@ describe('methodOverride(getter)', function () { var server = createServer('_method') request(server) - .delete('/?_method=PATCH') - .set('Content-Type', 'application/json') - .expect('X-Got-Method', 'DELETE', done) + .delete('/?_method=PATCH') + .set('Content-Type', 'application/json') + .expect('X-Got-Method', 'DELETE', done) }) }) @@ -74,50 +74,50 @@ describe('methodOverride(getter)', function () { it('should work missing header', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .expect('X-Got-Method', 'POST', done) + .post('/') + .set('Content-Type', 'application/json') + .expect('X-Got-Method', 'POST', done) }) it('should be case in-sensitive', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .set('X-HTTP-Method-Override', 'DELete') - .expect('X-Got-Method', 'DELETE', done) + .post('/') + .set('Content-Type', 'application/json') + .set('X-HTTP-Method-Override', 'DELete') + .expect('X-Got-Method', 'DELETE', done) }) it('should ignore invalid methods', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .set('X-HTTP-Method-Override', 'BOGUS') - .expect('X-Got-Method', 'POST', done) + .post('/') + .set('Content-Type', 'application/json') + .set('X-HTTP-Method-Override', 'BOGUS') + .expect('X-Got-Method', 'POST', done) }) it('should handle multiple headers', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .set('X-HTTP-Method-Override', 'DELETE, PUT') - .expect('X-Got-Method', 'DELETE', done) + .post('/') + .set('Content-Type', 'application/json') + .set('X-HTTP-Method-Override', 'DELETE, PUT') + .expect('X-Got-Method', 'DELETE', done) }) it('should set Vary header', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .set('X-HTTP-Method-Override', 'DELETE') - .expect('Vary', 'X-HTTP-Method-Override') - .expect('X-Got-Method', 'DELETE', done) + .post('/') + .set('Content-Type', 'application/json') + .set('X-HTTP-Method-Override', 'DELETE') + .expect('Vary', 'X-HTTP-Method-Override') + .expect('X-Got-Method', 'DELETE', done) }) it('should set Vary header even with no override', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .expect('Vary', 'X-HTTP-Method-Override') - .expect('X-Got-Method', 'POST', done) + .post('/') + .set('Content-Type', 'application/json') + .expect('Vary', 'X-HTTP-Method-Override') + .expect('X-Got-Method', 'POST', done) }) }) @@ -131,25 +131,25 @@ describe('methodOverride(getter)', function () { it('should work missing header', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .expect('X-Got-Method', 'PATCH', done) + .post('/') + .set('Content-Type', 'application/json') + .expect('X-Got-Method', 'PATCH', done) }) it('should be case in-sensitive', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .set('X-Method-Override', 'DELete') - .expect('X-Got-Method', 'DELETE', done) + .post('/') + .set('Content-Type', 'application/json') + .set('X-Method-Override', 'DELete') + .expect('X-Got-Method', 'DELETE', done) }) it('should ignore invalid methods', function (done) { request(server) - .post('/') - .set('Content-Type', 'application/json') - .set('X-Method-Override', 'BOGUS') - .expect('X-Got-Method', 'POST', done) + .post('/') + .set('Content-Type', 'application/json') + .set('X-Method-Override', 'BOGUS') + .expect('X-Got-Method', 'POST', done) }) }) @@ -157,27 +157,27 @@ describe('methodOverride(getter)', function () { it('should allow other methods', function (done) { var server = createServer('X-HTTP-Method-Override', { methods: ['POST', 'PATCH'] }) request(server) - .patch('/') - .set('Content-Type', 'application/json') - .set('X-HTTP-Method-Override', 'DELETE') - .expect('X-Got-Method', 'DELETE', done) + .patch('/') + .set('Content-Type', 'application/json') + .set('X-HTTP-Method-Override', 'DELETE') + .expect('X-Got-Method', 'DELETE', done) }) it('should allow all methods', function (done) { var server = createServer('X-HTTP-Method-Override', { methods: null }) request(server) - .patch('/') - .set('Content-Type', 'application/json') - .set('X-HTTP-Method-Override', 'DELETE') - .expect('X-Got-Method', 'DELETE', done) + .patch('/') + .set('Content-Type', 'application/json') + .set('X-HTTP-Method-Override', 'DELETE') + .expect('X-Got-Method', 'DELETE', done) }) it('should not call getter when method not allowed', function (done) { var server = createServer(function (req) { return 'DELETE' }) request(server) - .patch('/') - .set('Content-Type', 'application/json') - .expect('X-Got-Method', 'PATCH', done) + .patch('/') + .set('Content-Type', 'application/json') + .expect('X-Got-Method', 'PATCH', done) }) }) })