From 82a7d7a9778a6047b2ec53fba9fd086a47e93c5a Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Tue, 29 Oct 2013 22:44:01 -0700 Subject: [PATCH 0001/1265] no semver2 so travis stops crying --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 845b22e6b06..31cb004999d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "should": "2", "connect-redis": "*", "marked": "*", - "supertest": "0.8.1 - 1" + "supertest": ">= 0.8.1 < 1" }, "keywords": [ "express", From 55d1a4f96463c114bb13d9dcc9fa1866ef6eb0b0 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Wed, 30 Oct 2013 20:34:16 -0700 Subject: [PATCH 0002/1265] always send ETag when content-length > 0 closes #1780 --- lib/response.js | 2 +- test/res.send.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/response.js b/lib/response.js index b0816b33cce..6be9ded66ba 100644 --- a/lib/response.js +++ b/lib/response.js @@ -132,7 +132,7 @@ res.send = function(body){ // ETag support // TODO: W/ support - if (app.settings.etag && len > 1024 && 'GET' == req.method) { + if (app.settings.etag && len && 'GET' == req.method) { if (!this.get('ETag')) { this.set('ETag', etag(body)); } diff --git a/test/res.send.js b/test/res.send.js index 52e3c5b4d82..8f631593428 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -321,6 +321,21 @@ describe('res', function(){ describe('"etag" setting', function(){ describe('when enabled', function(){ + it('should send ETag even when content-length < 1024', function(done){ + var app = express(); + + app.use(function(req, res){ + res.send('kajdslfkasdf'); + }); + + request(app) + .get('/') + .end(function(err, res){ + res.headers.should.have.property('etag'); + done(); + }); + }) + it('should send ETag ', function(done){ var app = express(); From 2e197e2b98823e0f332c1c76e410379458c84242 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Wed, 30 Oct 2013 20:37:01 -0700 Subject: [PATCH 0003/1265] be less picky with ENOENT errors in tests closes #1580 --- test/res.sendfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/res.sendfile.js b/test/res.sendfile.js index 5193770dbed..30c2ebe00d9 100644 --- a/test/res.sendfile.js +++ b/test/res.sendfile.js @@ -51,7 +51,7 @@ describe('res', function(){ .get('/') .end(function(err, res){ assert(1 == calls, 'called too many times'); - res.text.should.equal("ENOENT, stat 'test/fixtures/nope.html'"); + res.text.should.startWith("ENOENT, stat"); res.statusCode.should.equal(200); done(); }); From a66d6bb0341b34204549ce966e94951c8281b21d Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Wed, 30 Oct 2013 20:51:10 -0700 Subject: [PATCH 0004/1265] pin dev deps to semver compatible versions --- .travis.yml | 2 ++ package.json | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc4dba29d95..09bd249bdaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,5 @@ language: node_js node_js: - "0.8" - "0.10" +before_install: + - "npm update -g npm" \ No newline at end of file diff --git a/package.json b/package.json index 31cb004999d..6dc90424341 100644 --- a/package.json +++ b/package.json @@ -32,18 +32,18 @@ "methods": "0.1.0", "send": "0.1.4", "cookie-signature": "1.0.1", - "debug": "*" + "debug": "0.7.3 - 1" }, "devDependencies": { - "ejs": "*", - "mocha": "*", + "ejs": "0.8.4 - 1", + "mocha": "^1.13.0", "jade": "0.30.0", - "hjs": "*", - "stylus": "*", - "should": "2", - "connect-redis": "*", - "marked": "*", - "supertest": ">= 0.8.1 < 1" + "hjs": "0.0.6 - 1", + "stylus": "0.39.1 - 1", + "should": "^2.0.2", + "connect-redis": "^1.4.5", + "marked": "0.2.9 - 1", + "supertest": "0.8.1 - 1" }, "keywords": [ "express", From 6e3f3887e9367543e9adb72af279bdad19e863d4 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Wed, 30 Oct 2013 20:55:11 -0700 Subject: [PATCH 0005/1265] pin deps using semver1 somebody is going to complain that they can't install stuff because they haven't upgraded npm --- .travis.yml | 4 +--- package.json | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09bd249bdaf..a12e3f0fdeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ language: node_js node_js: - "0.8" - - "0.10" -before_install: - - "npm update -g npm" \ No newline at end of file + - "0.10" \ No newline at end of file diff --git a/package.json b/package.json index 6dc90424341..21ac882628a 100644 --- a/package.json +++ b/package.json @@ -32,18 +32,18 @@ "methods": "0.1.0", "send": "0.1.4", "cookie-signature": "1.0.1", - "debug": "0.7.3 - 1" + "debug": ">= 0.7.3 < 1" }, "devDependencies": { - "ejs": "0.8.4 - 1", - "mocha": "^1.13.0", + "ejs": ">= 0.8.4 < 1", + "mocha": ">= 1.13.0 < 2", "jade": "0.30.0", - "hjs": "0.0.6 - 1", - "stylus": "0.39.1 - 1", - "should": "^2.0.2", - "connect-redis": "^1.4.5", - "marked": "0.2.9 - 1", - "supertest": "0.8.1 - 1" + "hjs": ">= 0.0.6 < 1", + "stylus": ">= 0.39.1 < 1", + "should": ">= 2.0.2 < 3", + "connect-redis": ">= 1.4.5 < 2", + "marked": ">= 0.2.9 < 1", + "supertest": ">= 0.8.1 < 1" }, "keywords": [ "express", @@ -66,6 +66,6 @@ "test": "make test" }, "engines": { - "node": "*" + "node": ">= 0.8.0" } } From 661914781ed5c66f99b389320d99cb175a2c665f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Sat, 2 Nov 2013 00:39:32 +0100 Subject: [PATCH 0006/1265] semicolons --- lib/response.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/response.js b/lib/response.js index 6be9ded66ba..cb322448310 100644 --- a/lib/response.js +++ b/lib/response.js @@ -643,11 +643,11 @@ res.location = function(url){ // relative if (!~url.indexOf('://') && 0 != url.indexOf('//')) { - var path + var path; // relative to path if ('.' == url[0]) { - path = req.originalUrl.split('?')[0] + path = req.originalUrl.split('?')[0]; url = path + ('/' == path[path.length - 1] ? '' : '/') + url; // relative to mount-point } else if ('/' != url[0]) { From b7a38af41d517a25e2161b3800609fdb0b9ef899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Sat, 2 Nov 2013 01:28:07 +0100 Subject: [PATCH 0007/1265] Use url.resolve to compute location header of relative paths --- lib/response.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/response.js b/lib/response.js index cb322448310..e160c06a0d4 100644 --- a/lib/response.js +++ b/lib/response.js @@ -14,6 +14,7 @@ var http = require('http') , cookie = require('cookie') , send = require('send') , mime = connect.mime + , resolve = require('url').resolve , basename = path.basename , extname = path.extname; @@ -633,7 +634,8 @@ res.cookie = function(name, val, options){ res.location = function(url){ var app = this.app - , req = this.req; + , req = this.req + , path; // setup redirect map var map = { back: req.get('Referrer') || '/' }; @@ -643,12 +645,11 @@ res.location = function(url){ // relative if (!~url.indexOf('://') && 0 != url.indexOf('//')) { - var path; - // relative to path if ('.' == url[0]) { path = req.originalUrl.split('?')[0]; - url = path + ('/' == path[path.length - 1] ? '' : '/') + url; + path = path + ('/' == path[path.length - 1] ? '' : '/'); + url = resolve(path, url); // relative to mount-point } else if ('/' != url[0]) { path = app.path(); From 9c0de236456069fbc5cd9dc8c19d98c19913b698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Sat, 2 Nov 2013 01:29:04 +0100 Subject: [PATCH 0008/1265] Update tests expectancy of location headers --- test/res.location.js | 4 ++-- test/res.redirect.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/res.location.js b/test/res.location.js index 3f7a9dac06d..e4fad6acdbf 100644 --- a/test/res.location.js +++ b/test/res.location.js @@ -64,7 +64,7 @@ describe('res', function(){ request(app) .get('/post/1') .end(function(err, res){ - res.headers.should.have.property('location', '/post/1/./edit'); + res.headers.should.have.property('location', '/post/1/edit'); done(); }) }) @@ -81,7 +81,7 @@ describe('res', function(){ request(app) .get('/post/1') .end(function(err, res){ - res.headers.should.have.property('location', '/post/1/../new'); + res.headers.should.have.property('location', '/post/new'); done(); }) }) diff --git a/test/res.redirect.js b/test/res.redirect.js index 735e3d870ee..4640719c7f3 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -210,17 +210,17 @@ describe('res', function(){ request(root) .get('/depth1') .end(function(err, res){ - res.headers.should.have.property('location', '/depth1/./index'); + res.headers.should.have.property('location', '/depth1/index'); request(root) .get('/depth1/depth2') .end(function(err, res){ - res.headers.should.have.property('location', '/depth1/depth2/./index'); + res.headers.should.have.property('location', '/depth1/depth2/index'); request(root) .get('/depth1/depth2/depth3') .end(function(err, res){ - res.headers.should.have.property('location', '/depth1/depth2/depth3/./index'); + res.headers.should.have.property('location', '/depth1/depth2/depth3/index'); done(); }) }) @@ -231,11 +231,11 @@ describe('res', function(){ request(root) .get('/depth2') .end(function(err, res){ - res.headers.should.have.property('location', '/depth2/./index'); + res.headers.should.have.property('location', '/depth2/index'); request(root) .get('/depth3') .end(function(err, res){ - res.headers.should.have.property('location', '/depth3/./index'); + res.headers.should.have.property('location', '/depth3/index'); done(); }) }) From c9865b821dae889f62ae986660d4f6ffaca4c06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Sat, 2 Nov 2013 01:29:47 +0100 Subject: [PATCH 0009/1265] Test location with leading ./ and containing .. --- test/res.location.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/res.location.js b/test/res.location.js index e4fad6acdbf..b9810d312b0 100644 --- a/test/res.location.js +++ b/test/res.location.js @@ -86,6 +86,23 @@ describe('res', function(){ }) }) }) + + describe('with leading ./ and containing ..', function(){ + it('should construct path-relative urls', function(done){ + var app = express(); + + app.use(function(req, res){ + res.location('./skip/../../new').end(); + }); + + request(app) + .get('/post/1') + .end(function(err, res){ + res.headers.should.have.property('location', '/post/new'); + done(); + }) + }) + }) describe('without leading /', function(){ it('should construct mount-point relative urls', function(done){ From 373fa55981c88a4ad38181aead00120262f5c0af Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Sat, 9 Nov 2013 19:08:25 -0800 Subject: [PATCH 0010/1265] fix markdown example test marked 0.2.10 adds ids to header elements now. --- test/acceptance/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/acceptance/markdown.js b/test/acceptance/markdown.js index 667e73a8c10..d086992b2f5 100644 --- a/test/acceptance/markdown.js +++ b/test/acceptance/markdown.js @@ -7,7 +7,7 @@ describe('markdown', function(){ it('should respond with html', function(done){ request(app) .get('/') - .expect(/

Markdown Example<\/h1>/,done) + .expect(/]*>Markdown Example<\/h1>/,done) }) }) From cada9f61c805ed63dd01321383a45ffb8d6ecb5a Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sat, 9 Nov 2013 22:23:48 -0500 Subject: [PATCH 0011/1265] pin devDependencies using ~ If tests are passing and everything works, don't let things change out from under us as much. Really we should do hard pinning, but will be a bit lenient for now. --- package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 21ac882628a..3871764e022 100644 --- a/package.json +++ b/package.json @@ -35,15 +35,15 @@ "debug": ">= 0.7.3 < 1" }, "devDependencies": { - "ejs": ">= 0.8.4 < 1", - "mocha": ">= 1.13.0 < 2", - "jade": "0.30.0", - "hjs": ">= 0.0.6 < 1", - "stylus": ">= 0.39.1 < 1", - "should": ">= 2.0.2 < 3", - "connect-redis": ">= 1.4.5 < 2", - "marked": ">= 0.2.9 < 1", - "supertest": ">= 0.8.1 < 1" + "ejs": "~0.8.4", + "mocha": "~1.14.0", + "jade": "~0.30.0", + "hjs": "~0.0.6", + "stylus": "~0.40.0", + "should": "~2.0.2", + "connect-redis": "~1.4.5", + "marked": "~0.2.10", + "supertest": "~0.8.1" }, "keywords": [ "express", From 89e7264e53beee9c243efcb54ceb1a20d80d59d2 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sat, 9 Nov 2013 22:30:39 -0500 Subject: [PATCH 0012/1265] pin marked devDep to protect out tests marked has shown that it cannot be trusted with patch level changes! --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3871764e022..2ead4ec324c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "stylus": "~0.40.0", "should": "~2.0.2", "connect-redis": "~1.4.5", - "marked": "~0.2.10", + "marked": "0.2.10", "supertest": "~0.8.1" }, "keywords": [ From f47c0d9774e1be00ec3316f496a5c1d297cc3343 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Tue, 16 Jul 2013 09:46:35 -0700 Subject: [PATCH 0013/1265] add Router.all() method Similar to app.all() but specifically for attaching handlers to all methods under a standalone router. This is useful for isolating routers that require "middleware" like features for all routes managed by the router. --- lib/router/index.js | 9 +++++++++ test/Router.js | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/router/index.js b/lib/router/index.js index 12f112d4f06..e17ff740109 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -302,6 +302,15 @@ Router.prototype.route = function(method, path, callbacks){ return this; }; +Router.prototype.all = function(path) { + var self = this; + var args = [].slice.call(arguments); + methods.forEach(function(method){ + self.route.apply(self, [method].concat(args)); + }); + return this; +}; + methods.forEach(function(method){ Router.prototype[method] = function(path){ var args = [method].concat([].slice.call(arguments)); diff --git a/test/Router.js b/test/Router.js index a2ddd68064f..5bb49753220 100644 --- a/test/Router.js +++ b/test/Router.js @@ -2,6 +2,7 @@ var express = require('../') , Router = express.Router , request = require('./support/http') + , methods = require('methods') , assert = require('assert'); describe('Router', function(){ @@ -100,4 +101,21 @@ describe('Router', function(){ router.route('get', '/foo', function(){}, function(){}); }) }) + + describe('.all', function() { + it('should support using .all to capture all http verbs', function() { + var router = new Router(); + + router.all('/foo', function(){}); + + var url = '/foo?bar=baz'; + + methods.forEach(function testMethod(method) { + var route = router.match(method, url); + route.constructor.name.should.equal('Route'); + route.method.should.equal(method); + route.path.should.equal('/foo'); + }); + }) + }) }) From 1684a8792a5caf894d6e1b1b4d59b6d0cdaa6dc9 Mon Sep 17 00:00:00 2001 From: Rick Yakubowski Date: Thu, 21 Nov 2013 14:01:56 -0500 Subject: [PATCH 0014/1265] Removed Buffer call with 'binary' encoding option in auth example. According to the Node.js documentation for Buffer objects regarding the 'binary' encoding option: "This encoding method is deprecated and should be avoided in favor of Buffer objects where possible. This encoding will be removed in future versions of Node." Simply calling toString() with a 'base64' argument on the hash seems to accomplish the same thing; this makes the code compatible with current documentation as well as being a bit easier to follow. --- examples/auth/pass.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/auth/pass.js b/examples/auth/pass.js index d0ba2b20ae6..0779c814bd6 100644 --- a/examples/auth/pass.js +++ b/examples/auth/pass.js @@ -32,7 +32,7 @@ var iterations = 12000; exports.hash = function (pwd, salt, fn) { if (3 == arguments.length) { crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){ - fn(err, (new Buffer(hash, 'binary')).toString('base64')); + fn(err, hash.toString('base64')); }); } else { fn = salt; @@ -41,8 +41,8 @@ exports.hash = function (pwd, salt, fn) { salt = salt.toString('base64'); crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){ if (err) return fn(err); - fn(null, salt, (new Buffer(hash, 'binary')).toString('base64')); + fn(null, salt, hash.toString('base64')); }); }); } -}; \ No newline at end of file +}; From 2f2a652bc9420f2d05ddfe914048cfe5c327d7c7 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Tue, 26 Nov 2013 13:11:15 -0600 Subject: [PATCH 0015/1265] fixes #1826: res.redirect('toString') fails with 500 Removed the unused map and corrected the doc comment. --- lib/response.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/response.js b/lib/response.js index e160c06a0d4..25c49eedf2b 100644 --- a/lib/response.js +++ b/lib/response.js @@ -605,8 +605,7 @@ res.cookie = function(name, val, options){ /** * Set the location header to `url`. * - * The given `url` can also be the name of a mapped url, for - * example by default express supports "back" which redirects + * The given `url` can also be "back", which redirects * to the _Referrer_ or _Referer_ headers or "/". * * Examples: @@ -637,11 +636,8 @@ res.location = function(url){ , req = this.req , path; - // setup redirect map - var map = { back: req.get('Referrer') || '/' }; - - // perform redirect - url = map[url] || url; + // "back" is an alias for the referrer + if(url === 'back') url = req.get('Referrer') || '/'; // relative if (!~url.indexOf('://') && 0 != url.indexOf('//')) { From 8a7a695836e6c2fe1145ad100a6eaae6235722e4 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 26 Nov 2013 11:12:56 -0800 Subject: [PATCH 0016/1265] ocd --- lib/response.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/response.js b/lib/response.js index 25c49eedf2b..31c79c0d5b5 100644 --- a/lib/response.js +++ b/lib/response.js @@ -637,7 +637,7 @@ res.location = function(url){ , path; // "back" is an alias for the referrer - if(url === 'back') url = req.get('Referrer') || '/'; + if ('back' == url) url = req.get('Referrer') || '/'; // relative if (!~url.indexOf('://') && 0 != url.indexOf('//')) { From a71d264d45ab6773443bdebc9f6c314b1e99a4d8 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 26 Nov 2013 23:39:08 -0800 Subject: [PATCH 0017/1265] fix weird variable name in example --- examples/content-negotiation/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/content-negotiation/index.js b/examples/content-negotiation/index.js index bb234984bc2..d3c0430f24f 100644 --- a/examples/content-negotiation/index.js +++ b/examples/content-negotiation/index.js @@ -28,8 +28,8 @@ app.get('/', function(req, res){ // this to add a layer of abstraction // and make things a bit more declarative: -function format(requestHandlerName) { - var requestHandler = require(requestHandlerName); +function format(path) { + var requestHandler = require(path); return function(req, res){ res.format(requestHandler); } From edd39fb194eddd7baf414f2c85828474009f6662 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 26 Nov 2013 23:39:35 -0800 Subject: [PATCH 0018/1265] fix weird variable name in example --- examples/content-negotiation/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/content-negotiation/index.js b/examples/content-negotiation/index.js index d3c0430f24f..db5ac863121 100644 --- a/examples/content-negotiation/index.js +++ b/examples/content-negotiation/index.js @@ -29,9 +29,9 @@ app.get('/', function(req, res){ // and make things a bit more declarative: function format(path) { - var requestHandler = require(path); + var obj = require(path); return function(req, res){ - res.format(requestHandler); + res.format(obj); } } From 863160ae499b056ac7ade9737ca049fa5f5cb357 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Wed, 27 Nov 2013 15:54:41 -0800 Subject: [PATCH 0019/1265] 3.4.5 --- History.md | 9 +++++++++ package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index d784c26cf2b..a631c324d8a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,12 @@ +3.4.5 / 2013-11-27 +================== + + * update connect + * res.location: remove leading ./ #1802 @kapouer + * res.redirect: fix `res.redirect('toString') #1829 @michaelficarra + * res.send: always send ETag when content-length > 0 + * router: add Router.all() method + 3.4.4 / 2013-10-29 ================== diff --git a/package.json b/package.json index 2ead4ec324c..dedea10c238 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.4.4", + "version": "3.4.5", "author": "TJ Holowaychuk ", "contributors": [ { @@ -22,7 +22,7 @@ } ], "dependencies": { - "connect": "2.11.0", + "connect": "2.11.1", "commander": "1.3.2", "range-parser": "0.0.4", "mkdirp": "0.3.5", From c6c71abf4d4d6b10e040d0ee9e09ce304b172fff Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Wed, 27 Nov 2013 19:46:39 -0800 Subject: [PATCH 0020/1265] change req.params to an object instead of an array --- lib/router/route.js | 7 ++++--- test/app.router.js | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/router/route.js b/lib/router/route.js index 4334c88e450..a976aab02c6 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -49,8 +49,9 @@ function Route(method, path, callbacks, options) { Route.prototype.match = function(path){ var keys = this.keys - , params = this.params = [] - , m = this.regexp.exec(path); + , params = this.params = {} + , m = this.regexp.exec(path) + , n = 0; if (!m) return false; @@ -64,7 +65,7 @@ Route.prototype.match = function(path){ if (key) { params[key.name] = val; } else { - params.push(val); + params[n++] = val; } } diff --git a/test/app.router.js b/test/app.router.js index 65c98c728c6..90f0315655c 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -126,8 +126,8 @@ describe('app.router', function(){ var app = express(); app.get(/^\/user\/([0-9]+)\/(view|edit)?$/, function(req, res){ - var id = req.params.shift() - , op = req.params.shift(); + var id = req.params[0] + , op = req.params[1]; res.end(op + 'ing user ' + id); }); @@ -302,8 +302,8 @@ describe('app.router', function(){ var app = express(); app.get('/api/*.*', function(req, res){ - var resource = req.params.shift() - , format = req.params.shift(); + var resource = req.params[0] + , format = req.params[1]; res.end(resource + ' as ' + format); }); From 606f68de021139778ca935541a9e65fcc0d1abff Mon Sep 17 00:00:00 2001 From: Ben Lewis Date: Thu, 28 Nov 2013 06:36:21 -0700 Subject: [PATCH 0021/1265] Grammar and punctuation fixes [ci skip] --- Readme.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Readme.md b/Readme.md index 44d47feeb51..e1e3f7e9862 100644 --- a/Readme.md +++ b/Readme.md @@ -50,14 +50,14 @@ app.listen(3000); ## Philosophy - The Express philosophy is to provide small, robust tooling for HTTP servers. Making + The Express philosophy is to provide small, robust tooling for HTTP servers, making it a great solution for single page applications, web sites, hybrids, or public HTTP APIs. - Built on Connect you can use _only_ what you need, and nothing more, applications + Built on Connect, you can use _only_ what you need, and nothing more. Applications can be as big or as small as you like, even a single file. Express does not force you to use any specific ORM or template engine. With support for over - 14 template engines via [Consolidate.js](http://github.com/visionmedia/consolidate.js) + 14 template engines via [Consolidate.js](http://github.com/visionmedia/consolidate.js), you can quickly craft your perfect framework. ## More Information @@ -72,27 +72,27 @@ app.listen(3000); ## Viewing Examples -Clone the Express repo, then install the dev dependencies to install all the example / test suite deps: +Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies: $ git clone git://github.com/visionmedia/express.git --depth 1 $ cd express $ npm install -then run whichever tests you want: +Then run whichever tests you want: $ node examples/content-negotiation -You can also view live examples here +You can also view live examples here: ## Running Tests -To run the test suite first invoke the following command within the repo, installing the development dependencies: +To run the test suite, first invoke the following command within the repo, installing the development dependencies: $ npm install -then run the tests: +Then run the tests: $ make test From 7724fc6af7b7ff636f7ae284a05d3d8500fc84d0 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Sun, 1 Dec 2013 12:21:08 -0800 Subject: [PATCH 0022/1265] 3.4.6 --- History.md | 5 +++++ package.json | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index a631c324d8a..be0b1981148 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.4.6 / 2013-12-01 +================== + + * update connect (raw-body) + 3.4.5 / 2013-11-27 ================== diff --git a/package.json b/package.json index dedea10c238..d0b1744ea49 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.4.5", + "version": "3.4.6", "author": "TJ Holowaychuk ", "contributors": [ { @@ -22,7 +22,7 @@ } ], "dependencies": { - "connect": "2.11.1", + "connect": "2.11.2", "commander": "1.3.2", "range-parser": "0.0.4", "mkdirp": "0.3.5", From 2e68ddbae9cec2d0b22f48f35ef4da964f51949e Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Tue, 10 Dec 2013 23:52:48 -0800 Subject: [PATCH 0023/1265] expose connect.middleware using Object.getOwnPropertyDescriptor() closes #1853. no tests, but it should be fine. --- lib/express.js | 8 ++------ package.json | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/express.js b/lib/express.js index c204849e2c6..4f61cdbd4d7 100644 --- a/lib/express.js +++ b/lib/express.js @@ -2,6 +2,7 @@ * Module dependencies. */ +var merge = require('merge-descriptors'); var connect = require('connect') , proto = require('./application') , Route = require('./router/route') @@ -43,12 +44,7 @@ function createApplication() { * for example `express.logger` etc. */ -for (var key in connect.middleware) { - Object.defineProperty( - exports - , key - , Object.getOwnPropertyDescriptor(connect.middleware, key)); -} +merge(exports, connect.middleware); /** * Error on createServer(). diff --git a/package.json b/package.json index d0b1744ea49..648f51940f2 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "methods": "0.1.0", "send": "0.1.4", "cookie-signature": "1.0.1", + "merge-descriptors": "0.0.1", "debug": ">= 0.7.3 < 1" }, "devDependencies": { From 7c6882234e44234ac048f6c8f44f75a1a6a9be88 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Tue, 10 Dec 2013 23:54:07 -0800 Subject: [PATCH 0024/1265] bump connect, mocha, and should --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 648f51940f2..b107c06b1f8 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ } ], "dependencies": { - "connect": "2.11.2", + "connect": "2.12.0", "commander": "1.3.2", "range-parser": "0.0.4", "mkdirp": "0.3.5", @@ -37,11 +37,11 @@ }, "devDependencies": { "ejs": "~0.8.4", - "mocha": "~1.14.0", + "mocha": "~1.15.1", "jade": "~0.30.0", "hjs": "~0.0.6", "stylus": "~0.40.0", - "should": "~2.0.2", + "should": "~2.1.1", "connect-redis": "~1.4.5", "marked": "0.2.10", "supertest": "~0.8.1" From 34c83d7d29d3acb718cac56aa4361c3a320fd80d Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Tue, 10 Dec 2013 23:57:39 -0800 Subject: [PATCH 0025/1265] 3.4.7 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index be0b1981148..82ece29e8d7 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.4.7 / 2013-12-10 +================== + + * update connect + 3.4.6 / 2013-12-01 ================== diff --git a/package.json b/package.json index b107c06b1f8..7fd89cb7489 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.4.6", + "version": "3.4.7", "author": "TJ Holowaychuk ", "contributors": [ { From 7b0dca0f9c7eb0c79fbc4e487a06357ab35347e7 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Thu, 12 Dec 2013 02:49:16 +0400 Subject: [PATCH 0026/1265] throw 400 in case of malformed paths --- lib/router/route.js | 12 ++++++--- lib/utils.js | 19 -------------- test/app.router.js | 60 ++++++++++++++++++++++++++++++++------------- 3 files changed, 52 insertions(+), 39 deletions(-) diff --git a/lib/router/route.js b/lib/router/route.js index 4334c88e450..d7ec88d2ea3 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -57,9 +57,15 @@ Route.prototype.match = function(path){ for (var i = 1, len = m.length; i < len; ++i) { var key = keys[i - 1]; - var val = 'string' == typeof m[i] - ? utils.decode(m[i]) - : m[i]; + try { + var val = 'string' == typeof m[i] + ? decodeURIComponent(m[i]) + : m[i]; + } catch(e) { + var err = new Error("Failed to decode param '" + m[i] + "'"); + err.status = 400; + throw err; + } if (key) { params[key.name] = val; diff --git a/lib/utils.js b/lib/utils.js index f19061bc273..b30873a8ac7 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -312,22 +312,3 @@ exports.pathRegexp = function(path, keys, sensitive, strict) { .replace(/\*/g, '(.*)'); return new RegExp('^' + path + '$', sensitive ? '' : 'i'); } - - -/** - * Decodes a URI component. Returns - * the original string if the component - * is malformed. - * - * @param {String} str - * @return {String} - * @api private - */ - -exports.decode = function(str) { - try { - return decodeURIComponent(str); - } catch (e) { - return str; - } -} diff --git a/test/app.router.js b/test/app.router.js index 65c98c728c6..c2bd082c720 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -27,28 +27,54 @@ describe('app.router', function(){ }); }) - it('should decode params', function(done){ - var app = express(); + describe('decode querystring', function(){ + it('should decode correct params', function(done){ + var app = express(); - app.get('/:name', function(req, res, next){ - res.send(req.params.name); - }); + app.get('/:name', function(req, res, next){ + res.send(req.params.name); + }); - request(app) - .get('/foo%2Fbar') - .expect('foo/bar', done); - }) + request(app) + .get('/foo%2Fbar') + .expect('foo/bar', done); + }) - it('should accept params in malformed paths', function(done) { - var app = express(); + it('should not accept params in malformed paths', function(done) { + var app = express(); - app.get('/:name', function(req, res, next){ - res.send(req.params.name); - }); + app.get('/:name', function(req, res, next){ + res.send(req.params.name); + }); - request(app) - .get('/%foobar') - .expect('%foobar', done); + request(app) + .get('/%foobar') + .expect(400, done); + }) + + it('should not decode spaces', function(done) { + var app = express(); + + app.get('/:name', function(req, res, next){ + res.send(req.params.name); + }); + + request(app) + .get('/foo+bar') + .expect('foo+bar', done); + }) + + it('should work with unicode', function(done) { + var app = express(); + + app.get('/:name', function(req, res, next){ + res.send(req.params.name); + }); + + request(app) + .get('/%ce%b1') + .expect('\u03b1', done); + }) }) it('should be .use()able', function(done){ From a0c1ac7b454b7ab4161f63ed1f5ca2c40eebe4bb Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Wed, 18 Dec 2013 10:16:56 -0500 Subject: [PATCH 0027/1265] add license field to package.json close #1862 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7fd89cb7489..4f84768965d 100644 --- a/package.json +++ b/package.json @@ -68,5 +68,6 @@ }, "engines": { "node": ">= 0.8.0" - } + }, + "license": "MIT" } From 85834fd146392dafb98211dc89472fe3ed2f329d Mon Sep 17 00:00:00 2001 From: Matt Copperwaite Date: Fri, 20 Dec 2013 11:39:31 +0000 Subject: [PATCH 0028/1265] Error message now describes where the view was not able to be found. Useful for debugging. --- lib/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index d5806f0be26..865e1e02b1d 100644 --- a/lib/application.js +++ b/lib/application.js @@ -490,7 +490,7 @@ app.render = function(name, options, fn){ }); if (!view.path) { - var err = new Error('Failed to lookup view "' + name + '"'); + var err = new Error('Failed to lookup view "' + name + '" in views directory "' + view.root + '"'); err.view = view; return fn(err); } From 9a45f7bd3d46c4278561c8bc6f254ce272ac0046 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Fri, 20 Dec 2013 19:34:59 -0800 Subject: [PATCH 0029/1265] add new benchmarks (to match koa) --- Makefile | 6 +++--- benchmarks/Makefile | 13 +++++++++++++ benchmarks/middleware.js | 23 +++++++++++++++++++++++ benchmarks/run | 16 ++++++++++++++++ support/bench | 32 -------------------------------- 5 files changed, 55 insertions(+), 35 deletions(-) create mode 100644 benchmarks/Makefile create mode 100644 benchmarks/middleware.js create mode 100755 benchmarks/run delete mode 100755 support/bench diff --git a/Makefile b/Makefile index d0cb2a017b2..a1f33a70292 100644 --- a/Makefile +++ b/Makefile @@ -24,11 +24,11 @@ test-cov: lib-cov lib-cov: @jscoverage lib lib-cov -benchmark: - @./support/bench +bench: + @$(MAKE) -C benchmarks clean: rm -f coverage.html rm -fr lib-cov -.PHONY: test test-unit test-acceptance benchmark clean +.PHONY: test test-unit test-acceptance bench clean diff --git a/benchmarks/Makefile b/benchmarks/Makefile new file mode 100644 index 00000000000..baf0d6fce92 --- /dev/null +++ b/benchmarks/Makefile @@ -0,0 +1,13 @@ + +all: + @./run 1 middleware + @./run 5 middleware + @./run 10 middleware + @./run 15 middleware + @./run 20 middleware + @./run 30 middleware + @./run 50 middleware + @./run 100 middleware + @echo + +.PHONY: all diff --git a/benchmarks/middleware.js b/benchmarks/middleware.js new file mode 100644 index 00000000000..3aa7a8b4ac7 --- /dev/null +++ b/benchmarks/middleware.js @@ -0,0 +1,23 @@ + +var http = require('http'); +var express = require('..'); +var app = express(); + +// number of middleware + +var n = parseInt(process.env.MW || '1', 10); +console.log(' %s middleware', n); + +while (n--) { + app.use(function(req, res, next){ + next(); + }); +} + +var body = new Buffer('Hello World'); + +app.use(function(req, res, next){ + res.send(body); +}); + +app.listen(3333); diff --git a/benchmarks/run b/benchmarks/run new file mode 100755 index 00000000000..fc84f27f1ec --- /dev/null +++ b/benchmarks/run @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +echo +MW=$1 node --harmony-generators $2 & +pid=$! + +sleep 2 + +wrk 'http://localhost:3333/?foo[bar]=baz' \ + -d 3 \ + -c 50 \ + -t 4 \ + | grep 'Requests/sec' \ + | awk '{ print " " $2 }' + +kill $pid diff --git a/support/bench b/support/bench deleted file mode 100755 index 207c18199b5..00000000000 --- a/support/bench +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -NODE_ENV=production node ./support/app & -pid=$! - -bench() { - ab -n 5000 -c 50 -k -q http://127.0.0.1:8000$1 \ - | grep "Requests per" \ - | cut -d ' ' -f 7 \ - | xargs echo "$2:" -} - -bench_conditional() { - ab -n 5000 -c 50 -H "If-None-Match: $3" -k -q http://127.0.0.1:8000$1 \ - | grep "Requests per" \ - | cut -d ' ' -f 7 \ - | xargs echo "$2:" -} - -sleep .5 -bench / "Hello World" -bench /blog "Mounted Hello World" -bench /blog/admin "Mounted 2 Hello World" -bench /middleware "Middleware" -bench /match "Router" -bench /render "Render" -bench /json "JSON tiny" -bench /json/15 "JSON small" -bench /json/50 "JSON medium" -bench /json/150 "JSON large" - -kill -9 $pid \ No newline at end of file From e9851672eb77232b1a92a6ee4a282cc69465480c Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Fri, 20 Dec 2013 21:15:17 -0800 Subject: [PATCH 0030/1265] bench: remove --harmony-generators flag --- benchmarks/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/run b/benchmarks/run index fc84f27f1ec..5a8c1956beb 100755 --- a/benchmarks/run +++ b/benchmarks/run @@ -1,7 +1,7 @@ #!/usr/bin/env bash echo -MW=$1 node --harmony-generators $2 & +MW=$1 node $2 & pid=$! sleep 2 From fcbe53ddb5fd64063d8d65c3faf8a4c2e7dd5237 Mon Sep 17 00:00:00 2001 From: Matt Copperwaite Date: Sat, 21 Dec 2013 17:34:59 +0000 Subject: [PATCH 0031/1265] Added appropriate test for more descriptive render error --- test/app.render.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/app.render.js b/test/app.render.js index 4f79e163e3f..a9586c77c68 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -59,7 +59,7 @@ describe('app', function(){ var app = express(); app.set('views', __dirname + '/fixtures'); app.render('rawr.jade', function(err){ - err.message.should.equal('Failed to lookup view "rawr.jade"'); + err.message.should.equal('Failed to lookup view "rawr.jade" in views directory "' + __dirname + '/fixtures"'); done(); }); }) From 3baca251f0888fa66cb23be1b1bb301ff4341f0a Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sun, 22 Dec 2013 08:57:04 -0800 Subject: [PATCH 0032/1265] use 8 threads for benchmarks --- benchmarks/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/run b/benchmarks/run index 5a8c1956beb..93b5bc52ff2 100755 --- a/benchmarks/run +++ b/benchmarks/run @@ -9,7 +9,7 @@ sleep 2 wrk 'http://localhost:3333/?foo[bar]=baz' \ -d 3 \ -c 50 \ - -t 4 \ + -t 8 \ | grep 'Requests/sec' \ | awk '{ print " " $2 }' From 00a3b01f391f472e895934f6ccad65c9f59a34a8 Mon Sep 17 00:00:00 2001 From: yosssi Date: Mon, 23 Dec 2013 22:13:05 +0900 Subject: [PATCH 0033/1265] Changed `doctype 5` to `doctype html` on the example file because the former was deprecated on Jade version 1.0.0. --- examples/view-locals/layout.jade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/view-locals/layout.jade b/examples/view-locals/layout.jade index a800c9791e6..5616cfaf7c2 100644 --- a/examples/view-locals/layout.jade +++ b/examples/view-locals/layout.jade @@ -1,4 +1,4 @@ -doctype 5 +doctype html html head title= title From cfd93b752936087a58c8d0616bbae3cd699e42fc Mon Sep 17 00:00:00 2001 From: Bent Cardan Date: Mon, 23 Dec 2013 13:03:21 -0500 Subject: [PATCH 0034/1265] update express jade layout generator update doctype --- bin/express | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express b/bin/express index 69b65d98080..cb979288397 100755 --- a/bin/express +++ b/bin/express @@ -74,7 +74,7 @@ var users = [ */ var jadeLayout = [ - 'doctype 5' + 'doctype html' , 'html' , ' head' , ' title= title' From 476f8deb07d48aac146a94262ea65b7991d840be Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Fri, 3 Jan 2014 02:33:00 -0800 Subject: [PATCH 0035/1265] remove binary --- History.md | 5 + bin/express | 423 --------------------------------------------------- package.json | 6 - 3 files changed, 5 insertions(+), 429 deletions(-) delete mode 100755 bin/express diff --git a/History.md b/History.md index 82ece29e8d7..47559cf35d0 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +4.0.0 / +================== + + * remove binary (moved to [express-generator](https://github.com/expressjs/generator)) + 3.4.7 / 2013-12-10 ================== diff --git a/bin/express b/bin/express deleted file mode 100755 index cb979288397..00000000000 --- a/bin/express +++ /dev/null @@ -1,423 +0,0 @@ -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -var program = require('commander') - , mkdirp = require('mkdirp') - , pkg = require('../package.json') - , version = pkg.version - , os = require('os') - , fs = require('fs'); - -// CLI - -program - .version(version) - .usage('[options] [dir]') - .option('-s, --sessions', 'add session support') - .option('-e, --ejs', 'add ejs engine support (defaults to jade)') - .option('-J, --jshtml', 'add jshtml engine support (defaults to jade)') - .option('-H, --hogan', 'add hogan.js engine support') - .option('-c, --css ', 'add stylesheet support (less|stylus) (defaults to plain css)') - .option('-f, --force', 'force on non-empty directory') - .parse(process.argv); - -// Path - -var path = program.args.shift() || '.'; - -// end-of-line code - -var eol = os.EOL - -// Template engine - -program.template = 'jade'; -if (program.ejs) program.template = 'ejs'; -if (program.jshtml) program.template = 'jshtml'; -if (program.hogan) program.template = 'hjs'; - -/** - * Routes index template. - */ - -var index = [ - '' - , '/*' - , ' * GET home page.' - , ' */' - , '' - , 'exports.index = function(req, res){' - , ' res.render(\'index\', { title: \'Express\' });' - , '};' -].join(eol); - -/** - * Routes users template. - */ - -var users = [ - '' - , '/*' - , ' * GET users listing.' - , ' */' - , '' - , 'exports.list = function(req, res){' - , ' res.send("respond with a resource");' - , '};' -].join(eol); - -/** - * Jade layout template. - */ - -var jadeLayout = [ - 'doctype html' - , 'html' - , ' head' - , ' title= title' - , ' link(rel=\'stylesheet\', href=\'/stylesheets/style.css\')' - , ' body' - , ' block content' -].join(eol); - -/** - * Jade index template. - */ - -var jadeIndex = [ - 'extends layout' - , '' - , 'block content' - , ' h1= title' - , ' p Welcome to #{title}' -].join(eol); - -/** - * EJS index template. - */ - -var ejsIndex = [ - '' - , '' - , ' ' - , ' <%= title %>' - , ' ' - , ' ' - , ' ' - , '

<%= title %>

' - , '

Welcome to <%= title %>

' - , ' ' - , '' -].join(eol); - -/** - * JSHTML layout template. - */ - -var jshtmlLayout = [ - '' - , '' - , ' ' - , ' @write(title) ' - , ' ' - , ' ' - , ' ' - , ' @write(body)' - , ' ' - , '' -].join(eol); - -/** - * JSHTML index template. - */ - -var jshtmlIndex = [ - '

@write(title)

' - , '

Welcome to @write(title)

' -].join(eol); - -/** - * Hogan.js index template. - */ -var hoganIndex = [ - '' - , '' - , ' ' - , ' {{ title }}' - , ' ' - , ' ' - , ' ' - , '

{{ title }}

' - , '

Welcome to {{ title }}

' - , ' ' - , '' -].join(eol); - -/** - * Default css template. - */ - -var css = [ - 'body {' - , ' padding: 50px;' - , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;' - , '}' - , '' - , 'a {' - , ' color: #00B7FF;' - , '}' -].join(eol); - -/** - * Default less template. - */ - -var less = [ - 'body {' - , ' padding: 50px;' - , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;' - , '}' - , '' - , 'a {' - , ' color: #00B7FF;' - , '}' -].join(eol); - -/** - * Default stylus template. - */ - -var stylus = [ - 'body' - , ' padding: 50px' - , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif' - , 'a' - , ' color: #00B7FF' -].join(eol); - -/** - * App template. - */ - -var app = [ - '' - , '/**' - , ' * Module dependencies.' - , ' */' - , '' - , 'var express = require(\'express\');' - , 'var routes = require(\'./routes\');' - , 'var user = require(\'./routes/user\');' - , 'var http = require(\'http\');' - , 'var path = require(\'path\');' - , '' - , 'var app = express();' - , '' - , '// all environments' - , 'app.set(\'port\', process.env.PORT || 3000);' - , 'app.set(\'views\', path.join(__dirname, \'views\'));' - , 'app.set(\'view engine\', \':TEMPLATE\');' - , 'app.use(express.favicon());' - , 'app.use(express.logger(\'dev\'));' - , 'app.use(express.json());' - , 'app.use(express.urlencoded());' - , 'app.use(express.methodOverride());{sess}' - , 'app.use(app.router);{css}' - , 'app.use(express.static(path.join(__dirname, \'public\')));' - , '' - , '// development only' - , 'if (\'development\' == app.get(\'env\')) {' - , ' app.use(express.errorHandler());' - , '}' - , '' - , 'app.get(\'/\', routes.index);' - , 'app.get(\'/users\', user.list);' - , '' - , 'http.createServer(app).listen(app.get(\'port\'), function(){' - , ' console.log(\'Express server listening on port \' + app.get(\'port\'));' - , '});' - , '' -].join(eol); - -// Generate application - -(function createApplication(path) { - emptyDirectory(path, function(empty){ - if (empty || program.force) { - createApplicationAt(path); - } else { - program.confirm('destination is not empty, continue? ', function(ok){ - if (ok) { - process.stdin.destroy(); - createApplicationAt(path); - } else { - abort('aborting'); - } - }); - } - }); -})(path); - -/** - * Create application at the given directory `path`. - * - * @param {String} path - */ - -function createApplicationAt(path) { - console.log(); - process.on('exit', function(){ - console.log(); - console.log(' install dependencies:'); - console.log(' $ cd %s && npm install', path); - console.log(); - console.log(' run the app:'); - console.log(' $ node app'); - console.log(); - }); - - mkdir(path, function(){ - mkdir(path + '/public'); - mkdir(path + '/public/javascripts'); - mkdir(path + '/public/images'); - mkdir(path + '/public/stylesheets', function(){ - switch (program.css) { - case 'less': - write(path + '/public/stylesheets/style.less', less); - break; - case 'stylus': - write(path + '/public/stylesheets/style.styl', stylus); - break; - default: - write(path + '/public/stylesheets/style.css', css); - } - }); - - mkdir(path + '/routes', function(){ - write(path + '/routes/index.js', index); - write(path + '/routes/user.js', users); - }); - - mkdir(path + '/views', function(){ - switch (program.template) { - case 'ejs': - write(path + '/views/index.ejs', ejsIndex); - break; - case 'jade': - write(path + '/views/layout.jade', jadeLayout); - write(path + '/views/index.jade', jadeIndex); - break; - case 'jshtml': - write(path + '/views/layout.jshtml', jshtmlLayout); - write(path + '/views/index.jshtml', jshtmlIndex); - break; - case 'hjs': - write(path + '/views/index.hjs', hoganIndex); - break; - - } - }); - - // CSS Engine support - switch (program.css) { - case 'less': - app = app.replace('{css}', eol + 'app.use(require(\'less-middleware\')({ src: path.join(__dirname, \'public\') }));'); - break; - case 'stylus': - app = app.replace('{css}', eol + 'app.use(require(\'stylus\').middleware(path.join(__dirname, \'public\')));'); - break; - default: - app = app.replace('{css}', ''); - } - - // Session support - app = app.replace('{sess}', program.sessions - ? eol + 'app.use(express.cookieParser(\'your secret here\'));' + eol + 'app.use(express.session());' - : ''); - - // Template support - app = app.replace(':TEMPLATE', program.template); - - // package.json - var pkg = { - name: 'application-name' - , version: '0.0.1' - , private: true - , scripts: { start: 'node app.js' } - , dependencies: { - express: version - } - } - - if (program.template) pkg.dependencies[program.template] = '*'; - - // CSS Engine support - switch (program.css) { - case 'less': - pkg.dependencies['less-middleware'] = '*'; - break; - default: - if (program.css) { - pkg.dependencies[program.css] = '*'; - } - } - - write(path + '/package.json', JSON.stringify(pkg, null, 2)); - write(path + '/app.js', app); - }); -} - -/** - * Check if the given directory `path` is empty. - * - * @param {String} path - * @param {Function} fn - */ - -function emptyDirectory(path, fn) { - fs.readdir(path, function(err, files){ - if (err && 'ENOENT' != err.code) throw err; - fn(!files || !files.length); - }); -} - -/** - * echo str > path. - * - * @param {String} path - * @param {String} str - */ - -function write(path, str) { - fs.writeFile(path, str); - console.log(' \x1b[36mcreate\x1b[0m : ' + path); -} - -/** - * Mkdir -p. - * - * @param {String} path - * @param {Function} fn - */ - -function mkdir(path, fn) { - mkdirp(path, 0755, function(err){ - if (err) throw err; - console.log(' \033[36mcreate\033[0m : ' + path); - fn && fn(); - }); -} - -/** - * Exit with the given `str`. - * - * @param {String} str - */ - -function abort(str) { - console.error(str); - process.exit(1); -} diff --git a/package.json b/package.json index 4f84768965d..d928c75bf1d 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,7 @@ ], "dependencies": { "connect": "2.12.0", - "commander": "1.3.2", "range-parser": "0.0.4", - "mkdirp": "0.3.5", "cookie": "0.1.0", "buffer-crc32": "0.2.1", "fresh": "0.2.0", @@ -58,10 +56,6 @@ "api" ], "repository": "git://github.com/visionmedia/express", - "main": "index", - "bin": { - "express": "./bin/express" - }, "scripts": { "prepublish": "npm prune", "test": "make test" From cec0c06a70c874298761282984573475293c0071 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Fri, 3 Jan 2014 02:50:09 -0800 Subject: [PATCH 0036/1265] refactor req.is and req.accepts* --- History.md | 10 ++ lib/request.js | 146 ++++++----------------------- lib/utils.js | 121 ------------------------ package.json | 2 + test/req.accepted.js | 37 -------- test/req.acceptedCharsets.js | 37 -------- test/req.acceptedEncodings.js | 37 -------- test/req.acceptedLanguages.js | 37 -------- test/req.accepts.js | 13 --- test/req.acceptsCharset.js | 6 +- test/req.is.js | 21 +++-- test/utils.js | 171 ---------------------------------- 12 files changed, 53 insertions(+), 585 deletions(-) delete mode 100644 test/req.accepted.js delete mode 100644 test/req.acceptedCharsets.js delete mode 100644 test/req.acceptedEncodings.js delete mode 100644 test/req.acceptedLanguages.js diff --git a/History.md b/History.md index 47559cf35d0..2a9c83420d7 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,16 @@ ================== * remove binary (moved to [express-generator](https://github.com/expressjs/generator)) + * refactor + - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) + - `req.is` with [type-is](https://github.com/expressjs/type-is) + * change + - `req.accepts[x]` -> `req.accepts[x]s` + * remove + - `req.acceptedEncodings` + - `req.accepted` + - `req.acceptedLanguages` + - `req.acceptedCharsets` 3.4.7 / 2013-12-10 ================== diff --git a/lib/request.js b/lib/request.js index 3d41617ebdf..062014e7d38 100644 --- a/lib/request.js +++ b/lib/request.js @@ -3,6 +3,8 @@ * Module dependencies. */ +var accepts = require('accepts'); +var typeis = require('type-is'); var http = require('http') , utils = require('./utils') , connect = require('connect') @@ -56,6 +58,8 @@ req.header = function(name){ }; /** + * To do: update docs. + * * Check if the given `type(s)` is acceptable, returning * the best match when true, otherwise `undefined`, in which * case you should respond with 406 "Not Acceptable". @@ -99,9 +103,9 @@ req.header = function(name){ * @api public */ -req.accepts = function(type){ - var args = arguments.length > 1 ? [].slice.apply(arguments) : type; - return utils.accepts(args, this.get('Accept')); +req.accepts = function(){ + var accept = accepts(this); + return accept.types.apply(accept, arguments); }; /** @@ -112,11 +116,15 @@ req.accepts = function(type){ * @api public */ -req.acceptsEncoding = function(encoding){ - return !! ~this.acceptedEncodings.indexOf(encoding); +req.acceptsEncoding = // backwards compatibility +req.acceptsEncodings = function(){ + var accept = accepts(this); + return accept.encodings.apply(accept, arguments); }; /** + * To do: update docs. + * * Check if the given `charset` is acceptable, * otherwise you should respond with 406 "Not Acceptable". * @@ -125,14 +133,15 @@ req.acceptsEncoding = function(encoding){ * @api public */ -req.acceptsCharset = function(charset){ - var accepted = this.acceptedCharsets; - return accepted.length - ? !! ~accepted.indexOf(charset) - : true; +req.acceptsCharset = // backwards compatibility +req.acceptsCharsets = function(){ + var accept = accepts(this); + return accept.charsets.apply(accept, arguments); }; /** + * To do: update docs. + * * Check if the given `lang` is acceptable, * otherwise you should respond with 406 "Not Acceptable". * @@ -141,11 +150,10 @@ req.acceptsCharset = function(charset){ * @api public */ -req.acceptsLanguage = function(lang){ - var accepted = this.acceptedLanguages; - return accepted.length - ? !! ~accepted.indexOf(lang) - : true; +req.acceptsLanguage = // backwards compatibility +req.acceptsLanguages = function(lang){ + var accept = accepts(this); + return accept.languages.apply(accept, arguments); }; /** @@ -174,98 +182,6 @@ req.range = function(size){ return parseRange(size, range); }; -/** - * Return an array of encodings. - * - * Examples: - * - * ['gzip', 'deflate'] - * - * @return {Array} - * @api public - */ - -req.__defineGetter__('acceptedEncodings', function(){ - var accept = this.get('Accept-Encoding'); - return accept - ? accept.trim().split(/ *, */) - : []; -}); - -/** - * Return an array of Accepted media types - * ordered from highest quality to lowest. - * - * Examples: - * - * [ { value: 'application/json', - * quality: 1, - * type: 'application', - * subtype: 'json' }, - * { value: 'text/html', - * quality: 0.5, - * type: 'text', - * subtype: 'html' } ] - * - * @return {Array} - * @api public - */ - -req.__defineGetter__('accepted', function(){ - var accept = this.get('Accept'); - return accept - ? utils.parseAccept(accept) - : []; -}); - -/** - * Return an array of Accepted languages - * ordered from highest quality to lowest. - * - * Examples: - * - * Accept-Language: en;q=.5, en-us - * ['en-us', 'en'] - * - * @return {Array} - * @api public - */ - -req.__defineGetter__('acceptedLanguages', function(){ - var accept = this.get('Accept-Language'); - return accept - ? utils - .parseParams(accept) - .map(function(obj){ - return obj.value; - }) - : []; -}); - -/** - * Return an array of Accepted charsets - * ordered from highest quality to lowest. - * - * Examples: - * - * Accept-Charset: iso-8859-5;q=.2, unicode-1-1;q=0.8 - * ['unicode-1-1', 'iso-8859-5'] - * - * @return {Array} - * @api public - */ - -req.__defineGetter__('acceptedCharsets', function(){ - var accept = this.get('Accept-Charset'); - return accept - ? utils - .parseParams(accept) - .map(function(obj){ - return obj.value; - }) - : []; -}); - /** * Return the value of param `name` when present or `defaultValue`. * @@ -319,19 +235,9 @@ req.param = function(name, defaultValue){ * @api public */ -req.is = function(type){ - var ct = this.get('Content-Type'); - if (!ct) return false; - ct = ct.split(';')[0]; - if (!~type.indexOf('/')) type = mime.lookup(type); - if (~type.indexOf('*')) { - type = type.split('/'); - ct = ct.split('/'); - if ('*' == type[0] && type[1] == ct[1]) return true; - if ('*' == type[1] && type[0] == ct[0]) return true; - return false; - } - return !! ~ct.indexOf(type); +req.is = function(types){ + if (!Array.isArray(types)) types = [].slice.call(arguments); + return typeis(this, types); }; /** diff --git a/lib/utils.js b/lib/utils.js index b30873a8ac7..139cf1c1562 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -110,127 +110,6 @@ exports.normalizeTypes = function(types){ return ret; }; -/** - * Return the acceptable type in `types`, if any. - * - * @param {Array} types - * @param {String} str - * @return {String} - * @api private - */ - -exports.acceptsArray = function(types, str){ - // accept anything when Accept is not present - if (!str) return types[0]; - - // parse - var accepted = exports.parseAccept(str) - , normalized = exports.normalizeTypes(types) - , len = accepted.length; - - for (var i = 0; i < len; ++i) { - for (var j = 0, jlen = types.length; j < jlen; ++j) { - if (exports.accept(normalized[j], accepted[i])) { - return types[j]; - } - } - } -}; - -/** - * Check if `type(s)` are acceptable based on - * the given `str`. - * - * @param {String|Array} type(s) - * @param {String} str - * @return {Boolean|String} - * @api private - */ - -exports.accepts = function(type, str){ - if ('string' == typeof type) type = type.split(/ *, */); - return exports.acceptsArray(type, str); -}; - -/** - * Check if `type` array is acceptable for `other`. - * - * @param {Object} type - * @param {Object} other - * @return {Boolean} - * @api private - */ - -exports.accept = function(type, other){ - var t = type.value.split('/'); - return (t[0] == other.type || '*' == other.type) - && (t[1] == other.subtype || '*' == other.subtype) - && paramsEqual(type.params, other.params); -}; - -/** - * Check if accept params are equal. - * - * @param {Object} a - * @param {Object} b - * @return {Boolean} - * @api private - */ - -function paramsEqual(a, b){ - return !Object.keys(a).some(function(k) { - return a[k] != b[k]; - }); -} - -/** - * Parse accept `str`, returning - * an array objects containing - * `.type` and `.subtype` along - * with the values provided by - * `parseQuality()`. - * - * @param {Type} name - * @return {Type} - * @api private - */ - -exports.parseAccept = function(str){ - return exports - .parseParams(str) - .map(function(obj){ - var parts = obj.value.split('/'); - obj.type = parts[0]; - obj.subtype = parts[1]; - return obj; - }); -}; - -/** - * Parse quality `str`, returning an - * array of objects with `.value`, - * `.quality` and optional `.params` - * - * @param {String} str - * @return {Array} - * @api private - */ - -exports.parseParams = function(str){ - return str - .split(/ *, */) - .map(acceptParams) - .filter(function(obj){ - return obj.quality; - }) - .sort(function(a, b){ - if (a.quality === b.quality) { - return a.originalIndex - b.originalIndex; - } else { - return b.quality - a.quality; - } - }); -}; /** * Parse accept params `str` returning an diff --git a/package.json b/package.json index d928c75bf1d..bd55647739f 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ ], "dependencies": { "connect": "2.12.0", + "accepts": "1.0.0", + "type-is": "1.0.0", "range-parser": "0.0.4", "cookie": "0.1.0", "buffer-crc32": "0.2.1", diff --git a/test/req.accepted.js b/test/req.accepted.js deleted file mode 100644 index 79f122a8020..00000000000 --- a/test/req.accepted.js +++ /dev/null @@ -1,37 +0,0 @@ - -var express = require('../') - , request = require('./support/http'); - -describe('req', function(){ - describe('.accepted', function(){ - it('should return an array of accepted media types', function(done){ - var app = express(); - - app.use(function(req, res){ - req.accepted[0].value.should.equal('application/json'); - req.accepted[1].value.should.equal('text/html'); - res.end(); - }); - - request(app) - .get('/') - .set('Accept', 'text/html;q=.5, application/json') - .expect(200, done); - }) - - describe('when Accept is not present', function(){ - it('should default to []', function(done){ - var app = express(); - - app.use(function(req, res){ - req.accepted.should.have.length(0); - res.end(); - }); - - request(app) - .get('/') - .expect(200, done); - }) - }) - }) -}) diff --git a/test/req.acceptedCharsets.js b/test/req.acceptedCharsets.js deleted file mode 100644 index 2bc3e0d94e4..00000000000 --- a/test/req.acceptedCharsets.js +++ /dev/null @@ -1,37 +0,0 @@ - -var express = require('../') - , request = require('./support/http'); - -describe('req', function(){ - describe('.acceptedCharsets', function(){ - it('should return an array of accepted charsets', function(done){ - var app = express(); - - app.use(function(req, res){ - req.acceptedCharsets[0].should.equal('unicode-1-1'); - req.acceptedCharsets[1].should.equal('iso-8859-5'); - res.end(); - }); - - request(app) - .get('/') - .set('Accept-Charset', 'iso-8859-5;q=.2, unicode-1-1;q=0.8') - .expect(200, done); - }) - - describe('when Accept-Charset is not present', function(){ - it('should default to []', function(done){ - var app = express(); - - app.use(function(req, res){ - req.acceptedCharsets.should.have.length(0); - res.end(); - }); - - request(app) - .get('/') - .expect(200, done); - }) - }) - }) -}) diff --git a/test/req.acceptedEncodings.js b/test/req.acceptedEncodings.js deleted file mode 100644 index 50ac9c2d7eb..00000000000 --- a/test/req.acceptedEncodings.js +++ /dev/null @@ -1,37 +0,0 @@ - -var express = require('../') - , request = require('./support/http'); - -describe('req', function(){ - describe('.acceptedEncodings', function(){ - it('should return an array of accepted encodings', function(done){ - var app = express(); - - app.use(function(req, res){ - req.acceptedEncodings.should.eql(['gzip', 'deflate']); - res.end(); - }); - - request(app) - .get('/') - .set('Accept-Encoding', ' gzip, deflate') - .expect(200, done); - }) - - describe('when Accept-Encoding is not present', function(){ - it('should default to []', function(done){ - var app = express(); - - app.use(function(req, res){ - req.acceptedEncodings.should.have.length(0); - res.end(); - }); - - request(app) - .get('/') - .set('Accept-Encoding', '') - .expect(200, done); - }) - }) - }) -}) diff --git a/test/req.acceptedLanguages.js b/test/req.acceptedLanguages.js deleted file mode 100644 index 9325d955696..00000000000 --- a/test/req.acceptedLanguages.js +++ /dev/null @@ -1,37 +0,0 @@ - -var express = require('../') - , request = require('./support/http'); - -describe('req', function(){ - describe('.acceptedLanguages', function(){ - it('should return an array of accepted languages', function(done){ - var app = express(); - - app.use(function(req, res){ - req.acceptedLanguages[0].should.equal('en-us'); - req.acceptedLanguages[1].should.equal('en'); - res.end(); - }); - - request(app) - .get('/') - .set('Accept-Language', 'en;q=.5, en-us') - .expect(200, done); - }) - - describe('when Accept-Language is not present', function(){ - it('should default to []', function(done){ - var app = express(); - - app.use(function(req, res){ - req.acceptedLanguages.should.have.length(0); - res.end(); - }); - - request(app) - .get('/') - .expect(200, done); - }) - }) - }) -}) diff --git a/test/req.accepts.js b/test/req.accepts.js index a8fc13b55d9..aeaf2258e56 100644 --- a/test/req.accepts.js +++ b/test/req.accepts.js @@ -43,19 +43,6 @@ describe('req', function(){ }) }) - it('should accept a comma-delimited list of types', function(done){ - var app = express(); - - app.use(function(req, res, next){ - res.end(req.accepts('json, html')); - }); - - request(app) - .get('/') - .set('Accept', 'text/html') - .expect('html', done); - }) - it('should accept an argument list of type names', function(done){ var app = express(); diff --git a/test/req.acceptsCharset.js b/test/req.acceptsCharset.js index 1db237d4c60..4b18a4c8675 100644 --- a/test/req.acceptsCharset.js +++ b/test/req.acceptsCharset.js @@ -9,7 +9,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res, next){ - res.end(req.acceptsCharset('utf-8') ? 'yes' : 'no'); + res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); }); request(app) @@ -23,7 +23,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res, next){ - res.end(req.acceptsCharset('utf-8') ? 'yes' : 'no'); + res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); }); request(app) @@ -36,7 +36,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res, next){ - res.end(req.acceptsCharset('utf-8') ? 'yes' : 'no'); + res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); }); request(app) diff --git a/test/req.is.js b/test/req.is.js index b51e6c81e44..5a4c336b186 100644 --- a/test/req.is.js +++ b/test/req.is.js @@ -4,8 +4,11 @@ var express = require('../') function req(ct) { var req = { - headers: { 'content-type': ct } - , __proto__: express.request + headers: { + 'content-type': ct, + 'transfer-encoding': 'chunked' + }, + __proto__: express.request }; return req; @@ -15,7 +18,7 @@ describe('req.is()', function(){ it('should ignore charset', function(){ req('application/json; charset=utf-8') .is('json') - .should.be.true; + .should.equal('json'); }) describe('when content-type is not present', function(){ @@ -30,7 +33,7 @@ describe('req.is()', function(){ it('should lookup the mime type', function(){ req('application/json') .is('json') - .should.be.true; + .should.equal('json'); req('text/html') .is('json') @@ -42,7 +45,7 @@ describe('req.is()', function(){ it('should match', function(){ req('application/json') .is('application/json') - .should.be.true; + .should.equal('application/json'); req('image/jpeg') .is('application/json') @@ -54,7 +57,7 @@ describe('req.is()', function(){ it('should match', function(){ req('application/json') .is('*/json') - .should.be.true; + .should.equal('application/json'); req('image/jpeg') .is('*/json') @@ -65,7 +68,7 @@ describe('req.is()', function(){ it('should match', function(){ req('text/html; charset=utf-8') .is('*/html') - .should.be.true; + .should.equal('text/html'); req('text/plain; charset=utf-8') .is('*/html') @@ -78,7 +81,7 @@ describe('req.is()', function(){ it('should match', function(){ req('image/png') .is('image/*') - .should.be.true; + .should.equal('image/png'); req('text/html') .is('image/*') @@ -89,7 +92,7 @@ describe('req.is()', function(){ it('should match', function(){ req('text/html; charset=utf-8') .is('text/*') - .should.be.true; + .should.equal('text/html'); req('something/html; charset=utf-8') .is('text/*') diff --git a/test/utils.js b/test/utils.js index 649ad12ab9b..e6b826dd833 100644 --- a/test/utils.js +++ b/test/utils.js @@ -48,174 +48,3 @@ describe('utils.escape(html)', function(){ .should.equal('<script>foo & "bar"') }) }) - -describe('utils.parseParams(str)', function(){ - it('should default quality to 1', function(){ - utils.parseParams('text/html') - .should.eql([{ value: 'text/html', quality: 1, params: {}, originalIndex: 0 }]); - }) - - it('should parse qvalues', function(){ - utils.parseParams('text/html; q=0.5') - .should.eql([{ value: 'text/html', quality: 0.5, params: {}, originalIndex: 0 }]); - - utils.parseParams('text/html; q=.2') - .should.eql([{ value: 'text/html', quality: 0.2, params: {}, originalIndex: 0 }]); - }) - - it('should parse accept parameters', function(){ - utils.parseParams('application/json; ver=2.0') - .should.eql([{ value: 'application/json', quality: 1, params: {ver: "2.0"}, originalIndex: 0 }]); - - utils.parseParams('text/html; q=0.5; level=2') - .should.eql([{ value: 'text/html', quality: 0.5, params: {level: "2"}, originalIndex: 0 }]); - utils.parseParams('text/html;q=.2;ver=beta') - .should.eql([{ value: 'text/html', quality: 0.2, params: {ver: "beta"}, originalIndex: 0 }]); - }) - - it('should work with messed up whitespace', function(){ - utils.parseParams('text/html ; q = .2') - .should.eql([{ value: 'text/html', quality: 0.2, params: {}, originalIndex: 0 }]); - }) - - it('should work with multiples', function(){ - var str = 'da, en;q=.5, en-gb;q=.8'; - var arr = utils.parseParams(str); - arr[0].value.should.equal('da'); - arr[1].value.should.equal('en-gb'); - arr[2].value.should.equal('en'); - }) - - it('should work with long lists', function(){ - var str = 'en, nl, fr, de, ja, it, es, pt, pt-PT, da, fi, nb, sv, ko, zh-Hans, zh-Hant, ru, pl'; - var arr = utils.parseParams(str).map(function(o){ return o.value }); - arr.should.eql(str.split(', ')); - }) - - it('should sort by quality', function(){ - var str = 'text/plain;q=.2, application/json, text/html;q=0.5'; - var arr = utils.parseParams(str); - arr[0].value.should.equal('application/json'); - arr[1].value.should.equal('text/html'); - arr[2].value.should.equal('text/plain'); - }) - - it('should exclude those with a quality of 0', function(){ - var str = 'text/plain;q=.2, application/json, text/html;q=0'; - var arr = utils.parseParams(str); - arr.should.have.length(2); - }) -}) - -describe('utils.parseAccept(str)', function(){ - it('should provide .type', function(){ - var arr = utils.parseAccept('text/html'); - arr[0].type.should.equal('text'); - }) - - it('should provide .subtype', function(){ - var arr = utils.parseAccept('text/html'); - arr[0].subtype.should.equal('html'); - }) -}) - -describe('utils.accepts(type, str)', function(){ - describe('when a string is not given', function(){ - it('should return the value', function(){ - utils.accepts('text/html') - .should.equal('text/html'); - }) - }) - - describe('when a string is empty', function(){ - it('should return the value', function(){ - utils.accepts('text/html', '') - .should.equal('text/html'); - }) - }) - - describe('when */* is given', function(){ - it('should return the value', function(){ - utils.accepts('text/html', 'text/plain, */*') - .should.equal('text/html'); - }) - }) - - describe('when an array is given', function(){ - it('should return the best match', function(){ - utils.accepts(['html', 'json'], 'text/plain, application/json') - .should.equal('json'); - - utils.accepts(['html', 'application/json'], 'text/plain, application/json') - .should.equal('application/json'); - - utils.accepts(['text/html', 'application/json'], 'application/json;q=.5, text/html') - .should.equal('text/html'); - }) - }) - - describe('when a comma-delimited list is give', function(){ - it('should behave like an array', function(){ - utils.accepts('html, json', 'text/plain, application/json') - .should.equal('json'); - - utils.accepts('html, application/json', 'text/plain, application/json') - .should.equal('application/json'); - - utils.accepts('text/html, application/json', 'application/json;q=.5, text/html') - .should.equal('text/html'); - }) - }) - - describe('when accepting type/subtype', function(){ - it('should return the value when present', function(){ - utils.accepts('text/html', 'text/plain, text/html') - .should.equal('text/html'); - }) - - it('should return undefined otherwise', function(){ - assert(null == utils.accepts('text/html', 'text/plain, application/json')); - }) - }) - - describe('when accepting */subtype', function(){ - it('should return the value when present', function(){ - utils.accepts('text/html', 'text/*') - .should.equal('text/html'); - }) - - it('should return undefined otherwise', function(){ - assert(null == utils.accepts('text/html', 'image/*')); - }) - }) - - describe('when accepting type/*', function(){ - it('should return the value when present', function(){ - utils.accepts('text/html', '*/html') - .should.equal('text/html'); - }) - - it('should return undefined otherwise', function(){ - assert(null == utils.accepts('text/html', '*/json')); - }) - }) - - describe('when an extension is given', function(){ - it('should return the value when present', function(){ - utils.accepts('html', 'text/html, application/json') - .should.equal('html'); - }) - - it('should return undefined otherwise', function(){ - assert(null == utils.accepts('html', 'text/plain, application/json')); - }) - - it('should support *', function(){ - utils.accepts('html', 'text/*') - .should.equal('html'); - - utils.accepts('html', '*/html') - .should.equal('html'); - }) - }) -}) From 26c0be4c4e45276334b8e9afc2e26b3773f443cc Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Fri, 3 Jan 2014 02:57:24 -0800 Subject: [PATCH 0037/1265] improve history.md --- History.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/History.md b/History.md index 2a9c83420d7..8f410e9bb88 100644 --- a/History.md +++ b/History.md @@ -1,17 +1,14 @@ 4.0.0 / ================== - * remove binary (moved to [express-generator](https://github.com/expressjs/generator)) - * refactor + * remove: + - express(1) - moved to [express-generator](https://github.com/expressjs/generator) + - `req.accepted*` - use `req.accepts*()` instead + * change: + - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` + * refactor: - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) - `req.is` with [type-is](https://github.com/expressjs/type-is) - * change - - `req.accepts[x]` -> `req.accepts[x]s` - * remove - - `req.acceptedEncodings` - - `req.accepted` - - `req.acceptedLanguages` - - `req.acceptedCharsets` 3.4.7 / 2013-12-10 ================== From 7018d3d0e61a70a8720d6871af48191b0d6307ff Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Fri, 3 Jan 2014 03:00:48 -0800 Subject: [PATCH 0038/1265] history: req.params --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index 8f410e9bb88..e345f051db2 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,7 @@ - `req.accepted*` - use `req.accepts*()` instead * change: - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` + - `req.params` is now an object instead of an array * refactor: - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) - `req.is` with [type-is](https://github.com/expressjs/type-is) From a36eeb96f3d9836a7205d54bcfea2e8a124781a7 Mon Sep 17 00:00:00 2001 From: Veselin Todorov Date: Fri, 3 Jan 2014 19:47:57 +0200 Subject: [PATCH 0039/1265] update the tests to show a difference between `send(null)` and `send(undefiend)` --- test/res.send.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/res.send.js b/test/res.send.js index 8f631593428..9de7cbd3bb4 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -14,6 +14,7 @@ describe('res', function(){ request(app) .get('/') + .expect('Content-Length', '0') .expect('', done); }) }) @@ -28,7 +29,10 @@ describe('res', function(){ request(app) .get('/') - .expect('', done); + .expect('', function(req, res){ + res.header.should.not.have.property('content-length'); + done(); + }); }) }) From 951c70496b7d6e6c1938ab326b37e5f2445485af Mon Sep 17 00:00:00 2001 From: Oliver Salzburg Date: Sat, 4 Jan 2014 17:50:27 +0100 Subject: [PATCH 0040/1265] Value parameter of app.set() should be typed optional Object --- lib/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index 865e1e02b1d..6cae2183110 100644 --- a/lib/application.js +++ b/lib/application.js @@ -242,7 +242,7 @@ app.param = function(name, fn){ * Mounted servers inherit their parent server's settings. * * @param {String} setting - * @param {String} val + * @param {Object} [val] * @return {Server} for chaining * @api public */ From 28af21baeb7e8c77ea618b106ae3d0893875de4e Mon Sep 17 00:00:00 2001 From: Oliver Salzburg Date: Sat, 4 Jan 2014 22:05:19 +0100 Subject: [PATCH 0041/1265] Value parameter of app.set() is now typed optional mixed --- lib/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index 6cae2183110..076607573e3 100644 --- a/lib/application.js +++ b/lib/application.js @@ -242,7 +242,7 @@ app.param = function(name, fn){ * Mounted servers inherit their parent server's settings. * * @param {String} setting - * @param {Object} [val] + * @param {*} [val] * @return {Server} for chaining * @api public */ From 38996b30b1df2924655f153a06022d7845fcb6e8 Mon Sep 17 00:00:00 2001 From: Matheus Azzi Date: Sun, 5 Jan 2014 01:14:38 -0200 Subject: [PATCH 0042/1265] Update layout.jade --- examples/jade/views/layout.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/jade/views/layout.jade b/examples/jade/views/layout.jade index 614d674a483..300cdc78473 100644 --- a/examples/jade/views/layout.jade +++ b/examples/jade/views/layout.jade @@ -1,5 +1,5 @@ -!!! 5 +doctype html html include header body - block content \ No newline at end of file + block content From 8c3f153dd464aeac054521650fb7fd52e54e0522 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sat, 11 Jan 2014 10:52:38 -0500 Subject: [PATCH 0043/1265] remove use of app.configure for view cache setting --- lib/application.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/application.js b/lib/application.js index 076607573e3..c40ae4a6fbe 100644 --- a/lib/application.js +++ b/lib/application.js @@ -86,9 +86,9 @@ app.defaultConfiguration = function(){ this.set('json spaces', 2); }); - this.configure('production', function(){ + if (this.get('env') === 'production') { this.enable('view cache'); - }); + }; }; /** From 8c059469fd1e009211cdf3aafa925e941eea4b00 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sat, 11 Jan 2014 10:42:15 -0500 Subject: [PATCH 0044/1265] No 'json spaces' by default Json rendering can be handled by user tools or overridden in their own app to behave as desired. Minimizes the use of magic env settings. --- lib/application.js | 4 ---- test/res.json.js | 13 +++---------- test/res.jsonp.js | 9 +-------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/application.js b/lib/application.js index c40ae4a6fbe..2aae86db7d7 100644 --- a/lib/application.js +++ b/lib/application.js @@ -82,10 +82,6 @@ app.defaultConfiguration = function(){ this.set('views', process.cwd() + '/views'); this.set('jsonp callback name', 'callback'); - this.configure('development', function(){ - this.set('json spaces', 2); - }); - if (this.get('env') === 'production') { this.enable('view cache'); }; diff --git a/test/res.json.js b/test/res.json.js index b439f244bcb..5712fc3e63f 100644 --- a/test/res.json.js +++ b/test/res.json.js @@ -52,7 +52,7 @@ describe('res', function(){ }) }) }) - + describe('when given an object', function(){ it('should respond with json', function(done){ var app = express(); @@ -95,14 +95,7 @@ describe('res', function(){ }) describe('"json spaces" setting', function(){ - it('should default to 2 in development', function(){ - process.env.NODE_ENV = 'development'; - var app = express(); - app.get('json spaces').should.equal(2); - process.env.NODE_ENV = 'test'; - }) - - it('should be undefined otherwise', function(){ + it('should be undefined by default', function(){ var app = express(); assert(undefined === app.get('json spaces')); }) @@ -125,7 +118,7 @@ describe('res', function(){ }) }) }) - + describe('.json(status, object)', function(){ it('should respond with json and set the .statusCode', function(done){ var app = express(); diff --git a/test/res.jsonp.js b/test/res.jsonp.js index 76f07c1fc1f..9f7769e38a6 100644 --- a/test/res.jsonp.js +++ b/test/res.jsonp.js @@ -181,14 +181,7 @@ describe('res', function(){ }) describe('"json spaces" setting', function(){ - it('should default to 2 in development', function(){ - process.env.NODE_ENV = 'development'; - var app = express(); - app.get('json spaces').should.equal(2); - process.env.NODE_ENV = 'test'; - }) - - it('should be undefined otherwise', function(){ + it('should be undefined by default', function(){ var app = express(); assert(undefined === app.get('json spaces')); }) From 7282b50ad0dbd9553ac8170d7eeda5a5f5992c8d Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sat, 11 Jan 2014 10:42:33 -0500 Subject: [PATCH 0045/1265] remove app.configure() --- lib/application.js | 54 -------------------------- test/config.env.js | 96 ---------------------------------------------- 2 files changed, 150 deletions(-) delete mode 100644 test/config.env.js diff --git a/lib/application.js b/lib/application.js index 2aae86db7d7..d306e817f9a 100644 --- a/lib/application.js +++ b/lib/application.js @@ -334,60 +334,6 @@ app.disable = function(setting){ return this.set(setting, false); }; -/** - * Configure callback for zero or more envs, - * when no `env` is specified that callback will - * be invoked for all environments. Any combination - * can be used multiple times, in any order desired. - * - * Examples: - * - * app.configure(function(){ - * // executed for all envs - * }); - * - * app.configure('stage', function(){ - * // executed staging env - * }); - * - * app.configure('stage', 'production', function(){ - * // executed for stage and production - * }); - * - * Note: - * - * These callbacks are invoked immediately, and - * are effectively sugar for the following: - * - * var env = process.env.NODE_ENV || 'development'; - * - * switch (env) { - * case 'development': - * ... - * break; - * case 'stage': - * ... - * break; - * case 'production': - * ... - * break; - * } - * - * @param {String} env... - * @param {Function} fn - * @return {app} for chaining - * @api public - */ - -app.configure = function(env, fn){ - var envs = 'all' - , args = [].slice.call(arguments); - fn = args.pop(); - if (args.length) envs = args; - if ('all' == envs || ~envs.indexOf(this.settings.env)) fn.call(this); - return this; -}; - /** * Delegate `.VERB(...)` calls to `router.VERB(...)`. */ diff --git a/test/config.env.js b/test/config.env.js deleted file mode 100644 index fd5d1c31b1b..00000000000 --- a/test/config.env.js +++ /dev/null @@ -1,96 +0,0 @@ - -var express = require('../'); - -describe('config', function(){ - describe('.configure()', function(){ - describe('when no env is given', function(){ - it('should always execute', function(){ - var app = express(); - var calls = []; - - app.configure(function(){ - calls.push('all'); - }); - - app.configure('test', function(){ - calls.push('test'); - }); - - app.configure('test', function(){ - calls.push('test 2'); - }); - - calls.should.eql(['all', 'test', 'test 2']) - }) - }) - - describe('when an env is given', function(){ - it('should only execute the matching env', function(){ - var app = express(); - var calls = []; - - app.set('env', 'development'); - - app.configure('development', function(){ - calls.push('dev'); - }); - - app.configure('test', function(){ - calls.push('test'); - }); - - calls.should.eql(['dev']); - }) - }) - - describe('when several envs are given', function(){ - it('should execute when matching one', function(){ - var app = express(); - var calls = []; - - app.set('env', 'development'); - - app.configure('development', function(){ - calls.push('dev'); - }); - - app.configure('test', 'development', function(){ - calls.push('dev 2'); - }); - - app.configure('development', 'test', function(){ - calls.push('dev 3'); - }); - - app.configure('test', function(){ - calls.push('dev 3'); - }); - - calls.should.eql(['dev', 'dev 2', 'dev 3']); - }) - }) - - it('should execute in order as defined', function(){ - var app = express(); - var calls = []; - - app.configure(function(){ - calls.push('all'); - }); - - app.configure('test', function(){ - calls.push('test'); - }); - - app.configure(function(){ - calls.push('all 2'); - }); - - app.configure('test', function(){ - calls.push('test 2'); - }); - - calls.should.eql(['all', 'test', 'all 2', 'test 2']) - }) - }) -}) \ No newline at end of file From dff22e9d095c5f9e848fada72e60cd801c6815ca Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sat, 11 Jan 2014 10:45:31 -0500 Subject: [PATCH 0046/1265] update history file with configure changes --- History.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/History.md b/History.md index e345f051db2..f8c6bfd8364 100644 --- a/History.md +++ b/History.md @@ -4,9 +4,11 @@ * remove: - express(1) - moved to [express-generator](https://github.com/expressjs/generator) - `req.accepted*` - use `req.accepts*()` instead + - `app.configure` - use logic in your own app code * change: - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` - `req.params` is now an object instead of an array + - `json spaces` no longer enabled by default in development * refactor: - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) - `req.is` with [type-is](https://github.com/expressjs/type-is) From a3b5f6d07f880298a92164fe7f0519d736524dcf Mon Sep 17 00:00:00 2001 From: Doug Patti Date: Thu, 2 Jan 2014 13:05:23 -0500 Subject: [PATCH 0047/1265] prevent incorrect automatic OPTIONS responses The router has automatic handling of OPTIONS based on the registered routes, but if you make an OPTIONS request for an endpoint that does not exist, then it will still return a 200 with nothing allowed. Instead, we can let the request move on down the middleware chain. This has two benefits: first, if the route was not defined and no other middleware handles it, it will return with a 404. Secondly, if multiple routers are used and a later one has the route or a custom OPTIONS defined, the first router will not respond incorrectly. --- lib/router/index.js | 5 +++-- test/app.options.js | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/router/index.js b/lib/router/index.js index e17ff740109..cd2f2693787 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -104,7 +104,7 @@ Router.prototype._dispatch = function(req, res, next){ req.route = route = self.matchRequest(req, i); // implied OPTIONS - if (!route && 'OPTIONS' == req.method) return self._options(req, res); + if (!route && 'OPTIONS' == req.method) return self._options(req, res, next); // no route if (!route) return next(err); @@ -181,9 +181,10 @@ Router.prototype._dispatch = function(req, res, next){ * @api private */ -Router.prototype._options = function(req, res){ +Router.prototype._options = function(req, res, next){ var path = parse(req).pathname , body = this._optionsFor(path).join(','); + if (!body) return next(); res.set('Allow', body).send(body); }; diff --git a/test/app.options.js b/test/app.options.js index 836a3463c23..a6f7b65fb16 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -15,6 +15,30 @@ describe('OPTIONS', function(){ .expect('GET,PUT') .expect('Allow', 'GET,PUT', done); }) + + it('should not respond if the path is not defined', function(done){ + var app = express(); + + app.get('/users', function(req, res){}); + + request(app) + .options('/other') + .expect(404, done); + }) + + it('should forward requests down the middleware chain', function(done){ + var app = express(); + var router = new express.Router(); + + router.get('/users', function(req, res){}); + app.use(router.middleware); + app.get('/other', function(req, res){}); + + request(app) + .options('/other') + .expect('GET') + .expect('Allow', 'GET', done); + }) }) describe('app.options()', function(){ From e465624fd02bc27824249e3c673151055dac4c39 Mon Sep 17 00:00:00 2001 From: Matheus Azzi Date: Sun, 5 Jan 2014 01:14:38 -0200 Subject: [PATCH 0048/1265] Update layout.jade --- examples/jade/views/layout.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/jade/views/layout.jade b/examples/jade/views/layout.jade index 614d674a483..300cdc78473 100644 --- a/examples/jade/views/layout.jade +++ b/examples/jade/views/layout.jade @@ -1,5 +1,5 @@ -!!! 5 +doctype html html include header body - block content \ No newline at end of file + block content From 1d97599f8b2f4ea6be0b7082ac1d9d93c8d00665 Mon Sep 17 00:00:00 2001 From: Doug Patti Date: Thu, 2 Jan 2014 13:05:23 -0500 Subject: [PATCH 0049/1265] prevent incorrect automatic OPTIONS responses The router has automatic handling of OPTIONS based on the registered routes, but if you make an OPTIONS request for an endpoint that does not exist, then it will still return a 200 with nothing allowed. Instead, we can let the request move on down the middleware chain. This has two benefits: first, if the route was not defined and no other middleware handles it, it will return with a 404. Secondly, if multiple routers are used and a later one has the route or a custom OPTIONS defined, the first router will not respond incorrectly. --- lib/router/index.js | 5 +++-- test/app.options.js | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/router/index.js b/lib/router/index.js index e17ff740109..cd2f2693787 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -104,7 +104,7 @@ Router.prototype._dispatch = function(req, res, next){ req.route = route = self.matchRequest(req, i); // implied OPTIONS - if (!route && 'OPTIONS' == req.method) return self._options(req, res); + if (!route && 'OPTIONS' == req.method) return self._options(req, res, next); // no route if (!route) return next(err); @@ -181,9 +181,10 @@ Router.prototype._dispatch = function(req, res, next){ * @api private */ -Router.prototype._options = function(req, res){ +Router.prototype._options = function(req, res, next){ var path = parse(req).pathname , body = this._optionsFor(path).join(','); + if (!body) return next(); res.set('Allow', body).send(body); }; diff --git a/test/app.options.js b/test/app.options.js index 836a3463c23..a6f7b65fb16 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -15,6 +15,30 @@ describe('OPTIONS', function(){ .expect('GET,PUT') .expect('Allow', 'GET,PUT', done); }) + + it('should not respond if the path is not defined', function(done){ + var app = express(); + + app.get('/users', function(req, res){}); + + request(app) + .options('/other') + .expect(404, done); + }) + + it('should forward requests down the middleware chain', function(done){ + var app = express(); + var router = new express.Router(); + + router.get('/users', function(req, res){}); + app.use(router.middleware); + app.get('/other', function(req, res){}); + + request(app) + .options('/other') + .expect('GET') + .expect('Allow', 'GET', done); + }) }) describe('app.options()', function(){ From ff23423d34d9d7f829d160aeb91b5c939ab4a4e1 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Mon, 13 Jan 2014 20:50:51 -0800 Subject: [PATCH 0050/1265] 3.4.8 --- History.md | 22 ++++++++++++++++++++++ package.json | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 82ece29e8d7..9d53bef43a3 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,25 @@ +4.0.0 / +================== + + * remove: + - express(1) - moved to [express-generator](https://github.com/expressjs/generator) + - `req.accepted*` - use `req.accepts*()` instead + - `app.configure` - use logic in your own app code + * change: + - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` + - `req.params` is now an object instead of an array + - `json spaces` no longer enabled by default in development + * refactor: + - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) + - `req.is` with [type-is](https://github.com/expressjs/type-is) + +3.4.8 / 2014-01-13 +================== + + * prevent incorrect automatic OPTIONS responses #1868 @dpatti + * update binary and examples for jade 1.0 #1876 @yossi, #1877 @reqshark, #1892 @matheusazzi + * throw 400 in case of malformed paths @rlidwka + 3.4.7 / 2013-12-10 ================== diff --git a/package.json b/package.json index 4f84768965d..926e9d37e64 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.4.7", + "version": "3.4.8", "author": "TJ Holowaychuk ", "contributors": [ { From fd6439bb36c9d39dc05067310edaf770dc5bb262 Mon Sep 17 00:00:00 2001 From: Haoliang Gao Date: Sun, 19 Jan 2014 23:53:48 +0800 Subject: [PATCH 0051/1265] delete semicolon --- lib/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index d306e817f9a..9d7639e353f 100644 --- a/lib/application.js +++ b/lib/application.js @@ -84,7 +84,7 @@ app.defaultConfiguration = function(){ if (this.get('env') === 'production') { this.enable('view cache'); - }; + } }; /** From f56a5f01c46677320cb9efa09800af13de1790d9 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sun, 19 Jan 2014 14:05:12 -0500 Subject: [PATCH 0052/1265] remove deprecated express.createServer() method This has been warning about deprecation for a long time. Use `express()` to instantiate an express app. --- History.md | 1 + lib/express.js | 15 --------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/History.md b/History.md index f8c6bfd8364..ad94194c51b 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ - express(1) - moved to [express-generator](https://github.com/expressjs/generator) - `req.accepted*` - use `req.accepts*()` instead - `app.configure` - use logic in your own app code + - `express.createServer()` - it has been deprecated for a long time. Use `express()` * change: - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` - `req.params` is now an object instead of an array diff --git a/lib/express.js b/lib/express.js index 4f61cdbd4d7..0f9f8dcf4e2 100644 --- a/lib/express.js +++ b/lib/express.js @@ -46,21 +46,6 @@ function createApplication() { merge(exports, connect.middleware); -/** - * Error on createServer(). - */ - -exports.createServer = function(){ - console.warn('Warning: express.createServer() is deprecated, express'); - console.warn('applications no longer inherit from http.Server,'); - console.warn('please use:'); - console.warn(''); - console.warn(' var express = require("express");'); - console.warn(' var app = express();'); - console.warn(''); - return createApplication(); -}; - /** * Expose the prototypes. */ From 718e68ffae3875c9d294471a1e1683fffc2e28e0 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Fri, 24 Jan 2014 19:16:37 -0500 Subject: [PATCH 0053/1265] use utils-merge module to mixin object properties --- lib/application.js | 7 ++++--- lib/express.js | 9 +++++---- lib/response.js | 5 +++-- package.json | 1 + test/res.cookie.js | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/application.js b/lib/application.js index 9d7639e353f..fadc409beb7 100644 --- a/lib/application.js +++ b/lib/application.js @@ -3,6 +3,7 @@ */ var connect = require('connect') + , mixin = require('utils-merge') , Router = require('./router') , methods = require('methods') , middleware = require('./middleware') @@ -407,13 +408,13 @@ app.render = function(name, options, fn){ } // merge app.locals - utils.merge(opts, this.locals); + mixin(opts, this.locals); // merge options._locals - if (options._locals) utils.merge(opts, options._locals); + if (options._locals) mixin(opts, options._locals); // merge options - utils.merge(opts, options); + mixin(opts, options); // set .cache unless explicitly provided opts.cache = null == opts.cache diff --git a/lib/express.js b/lib/express.js index 0f9f8dcf4e2..2f0217162c7 100644 --- a/lib/express.js +++ b/lib/express.js @@ -2,14 +2,15 @@ * Module dependencies. */ -var merge = require('merge-descriptors'); var connect = require('connect') - , proto = require('./application') + , merge = require('merge-descriptors') + , mixin = require('utils-merge') + +var proto = require('./application') , Route = require('./router/route') , Router = require('./router') , req = require('./request') , res = require('./response') - , utils = connect.utils; /** * Expose `createApplication()`. @@ -32,7 +33,7 @@ exports.mime = connect.mime; function createApplication() { var app = connect(); - utils.merge(app, proto); + mixin(app, proto); app.request = { __proto__: req, app: app }; app.response = { __proto__: res, app: app }; app.init(); diff --git a/lib/response.js b/lib/response.js index 31c79c0d5b5..f175ddd874a 100644 --- a/lib/response.js +++ b/lib/response.js @@ -5,6 +5,7 @@ var http = require('http') , path = require('path') , connect = require('connect') + , mixin = require('utils-merge') , utils = connect.utils , sign = require('cookie-signature').sign , normalizeType = require('./utils').normalizeType @@ -557,7 +558,7 @@ res.get = function(field){ res.clearCookie = function(name, options){ var opts = { expires: new Date(1), path: '/' }; return this.cookie(name, '', options - ? utils.merge(opts, options) + ? mixin(opts, options) : opts); }; @@ -585,7 +586,7 @@ res.clearCookie = function(name, options){ */ res.cookie = function(name, val, options){ - options = utils.merge({}, options); + options = mixin({}, options); var secret = this.req.secret; var signed = options.signed; if (signed && !secret) throw new Error('connect.cookieParser("secret") required for signed cookies'); diff --git a/package.json b/package.json index bd55647739f..ab1a8cb8c60 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "send": "0.1.4", "cookie-signature": "1.0.1", "merge-descriptors": "0.0.1", + "utils-merge": "1.0.0", "debug": ">= 0.7.3 < 1" }, "devDependencies": { diff --git a/test/res.cookie.js b/test/res.cookie.js index d671def31a7..d60635e0e72 100644 --- a/test/res.cookie.js +++ b/test/res.cookie.js @@ -1,7 +1,7 @@ var express = require('../') , request = require('./support/http') - , utils = require('connect').utils + , mixin = require('utils-merge') , cookie = require('cookie'); describe('res', function(){ @@ -114,7 +114,7 @@ describe('res', function(){ var app = express(); var options = { maxAge: 1000 }; - var optionsCopy = utils.merge({}, options); + var optionsCopy = mixin({}, options); app.use(function(req, res){ res.cookie('name', 'tobi', options) From 63c6a9c5ad6e7f6b93433c6917e611dcda593887 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Fri, 24 Jan 2014 19:21:21 -0500 Subject: [PATCH 0054/1265] use escape-html module to escape html Another util bites the dust. --- lib/response.js | 4 ++-- lib/utils.js | 16 ---------------- package.json | 1 + test/utils.js | 7 ------- 4 files changed, 3 insertions(+), 25 deletions(-) diff --git a/lib/response.js b/lib/response.js index f175ddd874a..97a2ac2b494 100644 --- a/lib/response.js +++ b/lib/response.js @@ -6,7 +6,7 @@ var http = require('http') , path = require('path') , connect = require('connect') , mixin = require('utils-merge') - , utils = connect.utils + , escapeHtml = require('escape-html') , sign = require('cookie-signature').sign , normalizeType = require('./utils').normalizeType , normalizeTypes = require('./utils').normalizeTypes @@ -706,7 +706,7 @@ res.redirect = function(url){ }, html: function(){ - var u = utils.escape(url); + var u = escapeHtml(url); body = '

' + statusCodes[status] + '. Redirecting to ' + u + '

'; }, diff --git a/lib/utils.js b/lib/utils.js index 139cf1c1562..6379b076821 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -137,22 +137,6 @@ function acceptParams(str, index) { return ret; } -/** - * Escape special characters in the given string of html. - * - * @param {String} html - * @return {String} - * @api private - */ - -exports.escape = function(html) { - return String(html) - .replace(/&/g, '&') - .replace(/"/g, '"') - .replace(//g, '>'); -}; - /** * Normalize the given path string, * returning a regular expression. diff --git a/package.json b/package.json index ab1a8cb8c60..25fef7a9f20 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "cookie-signature": "1.0.1", "merge-descriptors": "0.0.1", "utils-merge": "1.0.0", + "escape-html": "1.0.1", "debug": ">= 0.7.3 < 1" }, "devDependencies": { diff --git a/test/utils.js b/test/utils.js index e6b826dd833..ce2a7be2a8c 100644 --- a/test/utils.js +++ b/test/utils.js @@ -41,10 +41,3 @@ describe('utils.flatten(arr)', function(){ .should.eql(['one', 'two', 'three', 'four', 'five']); }) }) - -describe('utils.escape(html)', function(){ - it('should escape html entities', function(){ - utils.escape(' - \ No newline at end of file + From 2cccbc186efdcaf089bc501a5148391b6e92f473 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 Jun 2014 16:17:44 -0400 Subject: [PATCH 0342/1265] add deprecation message to non-plural req.accepts* --- History.md | 1 + lib/request.js | 29 +++++++++++--------- test/req.acceptsCharset.js | 6 ++-- test/req.acceptsCharsets.js | 49 +++++++++++++++++++++++++++++++++ test/req.acceptsEncoding.js | 2 +- test/req.acceptsEncodings.js | 36 ++++++++++++++++++++++++ test/req.acceptsLanguages.js | 53 ++++++++++++++++++++++++++++++++++++ 7 files changed, 159 insertions(+), 17 deletions(-) create mode 100644 test/req.acceptsCharsets.js create mode 100644 test/req.acceptsEncodings.js create mode 100644 test/req.acceptsLanguages.js diff --git a/History.md b/History.md index 41fbdc3b672..ac659fa1e0b 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * add deprecation message to non-plural `req.accepts*` * deprecate things with `depd` module * fix behavior when handling request without routes * fix handling when `route.all` is only route diff --git a/lib/request.js b/lib/request.js index 500890fdf2f..e7e7f8e9563 100644 --- a/lib/request.js +++ b/lib/request.js @@ -3,6 +3,7 @@ */ var accepts = require('accepts'); +var deprecate = require('depd')('express'); var typeis = require('type-is'); var http = require('http'); var fresh = require('fresh'); @@ -106,53 +107,55 @@ req.accepts = function(){ }; /** - * Check if the given `encoding` is accepted. + * Check if the given `encoding`s are accepted. * - * @param {String} encoding + * @param {String} ...encoding * @return {Boolean} * @api public */ -req.acceptsEncoding = // backwards compatibility req.acceptsEncodings = function(){ var accept = accepts(this); return accept.encodings.apply(accept, arguments); }; +req.acceptsEncoding = deprecate.function(req.acceptsEncodings, + 'req.acceptsEncoding: Use acceptsEncodings instead'); + /** - * To do: update docs. - * - * Check if the given `charset` is acceptable, + * Check if the given `charset`s are acceptable, * otherwise you should respond with 406 "Not Acceptable". * - * @param {String} charset + * @param {String} ...charset * @return {Boolean} * @api public */ -req.acceptsCharset = // backwards compatibility req.acceptsCharsets = function(){ var accept = accepts(this); return accept.charsets.apply(accept, arguments); }; +req.acceptsCharset = deprecate.function(req.acceptsCharsets, + 'req.acceptsCharset: Use acceptsCharsets instead'); + /** - * To do: update docs. - * - * Check if the given `lang` is acceptable, + * Check if the given `lang`s are acceptable, * otherwise you should respond with 406 "Not Acceptable". * - * @param {String} lang + * @param {String} ...lang * @return {Boolean} * @api public */ -req.acceptsLanguage = // backwards compatibility req.acceptsLanguages = function(){ var accept = accepts(this); return accept.languages.apply(accept, arguments); }; +req.acceptsLanguage = deprecate.function(req.acceptsLanguages, + 'req.acceptsLanguage: Use acceptsLanguages instead'); + /** * Parse Range header field, * capping to the given `size`. diff --git a/test/req.acceptsCharset.js b/test/req.acceptsCharset.js index a5461d01ae8..0d0ed8b5e41 100644 --- a/test/req.acceptsCharset.js +++ b/test/req.acceptsCharset.js @@ -9,7 +9,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res, next){ - res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); + res.end(req.acceptsCharset('utf-8') ? 'yes' : 'no'); }); request(app) @@ -23,7 +23,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res, next){ - res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); + res.end(req.acceptsCharset('utf-8') ? 'yes' : 'no'); }); request(app) @@ -36,7 +36,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res, next){ - res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); + res.end(req.acceptsCharset('utf-8') ? 'yes' : 'no'); }); request(app) diff --git a/test/req.acceptsCharsets.js b/test/req.acceptsCharsets.js new file mode 100644 index 00000000000..2f4574c5244 --- /dev/null +++ b/test/req.acceptsCharsets.js @@ -0,0 +1,49 @@ + +var express = require('../') + , request = require('supertest'); + +describe('req', function(){ + describe('.acceptsCharsets(type)', function(){ + describe('when Accept-Charset is not present', function(){ + it('should return true', function(done){ + var app = express(); + + app.use(function(req, res, next){ + res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); + }); + + request(app) + .get('/') + .expect('yes', done); + }) + }) + + describe('when Accept-Charset is not present', function(){ + it('should return true when present', function(done){ + var app = express(); + + app.use(function(req, res, next){ + res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); + }); + + request(app) + .get('/') + .set('Accept-Charset', 'foo, bar, utf-8') + .expect('yes', done); + }) + + it('should return false otherwise', function(done){ + var app = express(); + + app.use(function(req, res, next){ + res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no'); + }); + + request(app) + .get('/') + .set('Accept-Charset', 'foo, bar') + .expect('no', done); + }) + }) + }) +}) diff --git a/test/req.acceptsEncoding.js b/test/req.acceptsEncoding.js index 8714904b118..930b4ea76c1 100644 --- a/test/req.acceptsEncoding.js +++ b/test/req.acceptsEncoding.js @@ -3,7 +3,7 @@ var express = require('../') , request = require('supertest'); describe('req', function(){ - describe('.acceptsEncodings', function(){ + describe('.acceptsEncoding', function(){ it('should be true if encoding accpeted', function(done){ var app = express(); diff --git a/test/req.acceptsEncodings.js b/test/req.acceptsEncodings.js new file mode 100644 index 00000000000..c4c68e1e8ed --- /dev/null +++ b/test/req.acceptsEncodings.js @@ -0,0 +1,36 @@ + +var express = require('../') + , request = require('supertest'); + +describe('req', function(){ + describe('.acceptsEncodingss', function(){ + it('should be true if encoding accpeted', function(done){ + var app = express(); + + app.use(function(req, res){ + req.acceptsEncodings('gzip').should.be.ok; + req.acceptsEncodings('deflate').should.be.ok; + res.end(); + }); + + request(app) + .get('/') + .set('Accept-Encoding', ' gzip, deflate') + .expect(200, done); + }) + + it('should be false if encoding not accpeted', function(done){ + var app = express(); + + app.use(function(req, res){ + req.acceptsEncodings('bogus').should.not.be.ok; + res.end(); + }); + + request(app) + .get('/') + .set('Accept-Encoding', ' gzip, deflate') + .expect(200, done); + }) + }) +}) diff --git a/test/req.acceptsLanguages.js b/test/req.acceptsLanguages.js new file mode 100644 index 00000000000..8d11eb81e83 --- /dev/null +++ b/test/req.acceptsLanguages.js @@ -0,0 +1,53 @@ + +var express = require('../') + , request = require('supertest'); + +describe('req', function(){ + describe('.acceptsLanguages', function(){ + it('should be true if language accpeted', function(done){ + var app = express(); + + app.use(function(req, res){ + req.acceptsLanguages('en-us').should.be.ok; + req.acceptsLanguages('en').should.be.ok; + res.end(); + }); + + request(app) + .get('/') + .set('Accept-Language', 'en;q=.5, en-us') + .expect(200, done); + }) + + it('should be false if language not accpeted', function(done){ + var app = express(); + + app.use(function(req, res){ + req.acceptsLanguages('es').should.not.be.ok; + res.end(); + }); + + request(app) + .get('/') + .set('Accept-Language', 'en;q=.5, en-us') + .expect(200, done); + }) + + describe('when Accept-Language is not present', function(){ + it('should always return true', function(done){ + var app = express(); + + app.use(function(req, res){ + req.acceptsLanguages('en').should.be.ok; + req.acceptsLanguages('es').should.be.ok; + req.acceptsLanguages('jp').should.be.ok; + res.end(); + }); + + request(app) + .get('/') + .expect(200, done); + }) + }) + }) +}) From ba8a4c5a8d491012a017f1c9b97d09115b877687 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 Jun 2014 16:26:00 -0400 Subject: [PATCH 0343/1265] add deprecation message to res.send(body, status) --- History.md | 1 + lib/response.js | 1 + 2 files changed, 2 insertions(+) diff --git a/History.md b/History.md index ac659fa1e0b..914c14e5559 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * add deprecation message to non-plural `req.accepts*` + * add deprecation message to `res.send(body, status)` * deprecate things with `depd` module * fix behavior when handling request without routes * fix handling when `route.all` is only route diff --git a/lib/response.js b/lib/response.js index db31d79e607..d70595c5134 100644 --- a/lib/response.js +++ b/lib/response.js @@ -92,6 +92,7 @@ res.send = function(body){ if (2 == arguments.length) { // res.send(body, status) backwards compat if ('number' != typeof body && 'number' == typeof arguments[1]) { + deprecate('res.send(body, status): Use res.send(status, body) instead'); this.statusCode = arguments[1]; } else { this.statusCode = body; From 381b3b0f77a5050cea95a36ea7f657bae8d4a905 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 Jun 2014 16:26:28 -0400 Subject: [PATCH 0344/1265] add deprecation message to res.vary() --- History.md | 1 + lib/response.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 914c14e5559..4507794304c 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ unreleased * add deprecation message to non-plural `req.accepts*` * add deprecation message to `res.send(body, status)` + * add deprecation message to `res.vary()` * deprecate things with `depd` module * fix behavior when handling request without routes * fix handling when `route.all` is only route diff --git a/lib/response.js b/lib/response.js index d70595c5134..9a0a8864585 100644 --- a/lib/response.js +++ b/lib/response.js @@ -730,8 +730,10 @@ res.redirect = function(url){ res.vary = function(field){ // checks for back-compat - if (!field) return this; - if (Array.isArray(field) && !field.length) return this; + if (!field || (Array.isArray(field) && !field.length)) { + deprecate('res.vary(): Provide a field name'); + return this; + } vary(this, field); From 0ebfc6b7bf921d9ee0b8f46cbdc1819c49ab9d55 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 Jun 2014 20:35:44 -0400 Subject: [PATCH 0345/1265] tests: add test for OPTIONS in app.all --- test/app.options.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/app.options.js b/test/app.options.js index b7689d493f1..98fefe9a0bd 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -16,6 +16,24 @@ describe('OPTIONS', function(){ .expect('Allow', 'GET,PUT', done); }) + it('should not be affected by app.all', function(done){ + var app = express(); + + app.get('/', function(){}); + app.get('/users', function(req, res){}); + app.put('/users', function(req, res){}); + app.all('/users', function(req, res, next){ + res.setHeader('x-hit', '1'); + next(); + }); + + request(app) + .options('/users') + .expect('x-hit', '1') + .expect('allow', 'GET,PUT') + .expect(200, 'GET,PUT', done); + }) + it('should not respond if the path is not defined', function(done){ var app = express(); From a5252526908104823584652424f98cff41212393 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 24 Jun 2014 21:15:43 -0400 Subject: [PATCH 0346/1265] deps: istanbul@0.2.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a90d730895f..77b43d172a3 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "after": "0.8.1", - "istanbul": "0.2.10", + "istanbul": "0.2.11", "mocha": "~1.20.1", "should": "~4.0.4", "supertest": "~0.13.0", From e7caaf6757d2a070fc1a20cac8faa5872c93f426 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 24 Jun 2014 21:18:12 -0400 Subject: [PATCH 0347/1265] deps: type-is@~1.3.2 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4507794304c..6c6f48b3320 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,7 @@ unreleased * restore `req.params` after invoking router * use `finalhandler` for final response handling * use `media-typer` to alter content-type charset + * deps: type-is@~1.3.2 4.4.4 / 2014-06-20 ================== diff --git a/package.json b/package.json index 77b43d172a3..da322e82081 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "range-parser": "1.0.0", "send": "0.4.3", "serve-static": "1.2.3", - "type-is": "1.2.1", + "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From 81036aa6399ff3ed2285ca9017850a65037e2e8c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 24 Jun 2014 21:19:03 -0400 Subject: [PATCH 0348/1265] deps: finalhandler@0.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da322e82081..a2b4c1213ab 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "debug": "1.0.2", "depd": "0.3.0", "escape-html": "1.0.1", - "finalhandler": "0.0.0", + "finalhandler": "0.0.2", "media-typer": "0.2.0", "methods": "1.0.1", "parseurl": "1.0.1", From 9cb147370ec8d062891229cad38134850449a5e3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jun 2014 18:21:26 -0400 Subject: [PATCH 0349/1265] deps: istanbul@0.2.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c2e0cbbf78..2a5d5a8a5c3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "merge-descriptors": "0.0.2" }, "devDependencies": { - "istanbul": "0.2.10", + "istanbul": "0.2.12", "mocha": "~1.20.0", "should": "~4.0.0", "ejs": "~1.0.0", From 8ffb9f94774d36ecaa8b5904d27552ff63c4c594 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jun 2014 18:25:48 -0400 Subject: [PATCH 0350/1265] deps: connect@2.21.1 --- History.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7a72df67b0c..a0365d36847 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,12 @@ +3.x +=== + + * deps: connect@2.21.1 + - deps: cookie-parser@1.3.2 + - deps: cookie-signature@1.0.4 + - deps: express-session@~1.5.2 + - deps: type-is@~1.3.2 + 3.12.0 / 2014-06-21 =================== diff --git a/package.json b/package.json index 2a5d5a8a5c3..8e4a16a7bf5 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "license": "MIT", "dependencies": { "buffer-crc32": "0.2.3", - "connect": "2.21.0", + "connect": "2.21.1", "commander": "1.3.2", "debug": "1.0.2", "depd": "0.3.0", From 78d489d73050e87d8fd0f99d16a8283143aaf4d6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jun 2014 18:26:34 -0400 Subject: [PATCH 0351/1265] deps: cookie-signature@1.0.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a0365d36847..3f309143d8e 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,8 @@ - deps: cookie-signature@1.0.4 - deps: express-session@~1.5.2 - deps: type-is@~1.3.2 + * deps: cookie-signature@1.0.4 + - fix for timing attacks 3.12.0 / 2014-06-21 =================== diff --git a/package.json b/package.json index 8e4a16a7bf5..36366e9dce4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", - "cookie-signature": "1.0.3", + "cookie-signature": "1.0.4", "merge-descriptors": "0.0.2" }, "devDependencies": { From 9bb47fba300a4c096e049e51b636b3c282eb11f7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jun 2014 18:35:54 -0400 Subject: [PATCH 0352/1265] 3.12.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 3f309143d8e..7c67c733e5f 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.12.1 / 2014-06-26 +=================== * deps: connect@2.21.1 - deps: cookie-parser@1.3.2 diff --git a/package.json b/package.json index 36366e9dce4..e29e9eeab9c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.12.0", + "version": "3.12.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From f0ad55798705a780c508ba78e7b0a7c4f6374373 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jun 2014 20:25:20 -0400 Subject: [PATCH 0353/1265] deps: cookie-signature@1.0.4 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ec406e5cf05..1b51ea56fe9 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: cookie-signature@1.0.4 + - fix for timing attacks + 4.4.4 / 2014-06-20 ================== diff --git a/package.json b/package.json index 923ec45168a..25902b3ea3e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", - "cookie-signature": "1.0.3", + "cookie-signature": "1.0.4", "merge-descriptors": "0.0.2", "utils-merge": "1.0.0", "qs": "0.6.6", From fd27f1f4e19710d683f78b0683d45c5d8c590eae Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jun 2014 20:26:43 -0400 Subject: [PATCH 0354/1265] 4.4.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 1b51ea56fe9..9beb88943a0 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.4.5 / 2014-06-26 +================== * deps: cookie-signature@1.0.4 - fix for timing attacks diff --git a/package.json b/package.json index 25902b3ea3e..3dee3263143 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "4.4.4", + "version": "4.4.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From fd35351594b71cb61c9c5803efdf0e7d23d0afc7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 01:06:21 -0400 Subject: [PATCH 0355/1265] Add mergeParams option to Router fixes #2153 fixes #2203 --- History.md | 2 + lib/router/index.js | 43 ++++++++++++- test/app.router.js | 154 ++++++++++++++++++++++++++++++++++++-------- 3 files changed, 171 insertions(+), 28 deletions(-) diff --git a/History.md b/History.md index 4d4319c7938..81029b58fd9 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * add deprecation message to non-plural `req.accepts*` * add deprecation message to `res.send(body, status)` * add deprecation message to `res.vary()` + * add `mergeParams` option to `Router` + - merges `req.params` from parent routes * deprecate things with `depd` module * fix behavior when handling request without routes * fix handling when `route.all` is only route diff --git a/lib/router/index.js b/lib/router/index.js index 189f3cc7fa2..388ac9d6d07 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -5,6 +5,7 @@ var Route = require('./route'); var Layer = require('./layer'); var methods = require('methods'); +var mixin = require('utils-merge'); var debug = require('debug')('express:router'); var parseUrl = require('parseurl'); var slice = Array.prototype.slice; @@ -30,6 +31,7 @@ var proto = module.exports = function(options) { router.params = {}; router._params = []; router.caseSensitive = options.caseSensitive; + router.mergeParams = options.mergeParams; router.strict = options.strict; router.stack = []; @@ -132,6 +134,7 @@ proto.handle = function(req, res, done) { var stack = self.stack; // manage inter-router variables + var parentParams = req.params; var parentUrl = req.baseUrl || ''; done = restore(done, req, 'baseUrl', 'next', 'params'); @@ -197,7 +200,9 @@ proto.handle = function(req, res, done) { } // Capture one-time layer values - req.params = layer.params; + req.params = self.mergeParams + ? mergeParams(layer.params, parentParams) + : layer.params; layerPath = layer.path; // this should be done for the layer @@ -441,6 +446,42 @@ methods.concat('all').forEach(function(method){ }; }); +// merge params with parent params +function mergeParams(params, parent) { + if (typeof parent !== 'object' || !parent) { + return params; + } + + // make copy of parent for base + var obj = mixin({}, parent); + + // simple non-numeric merging + if (!(0 in params) || !(0 in parent)) { + return mixin(obj, params); + } + + var i = 0; + var o = 0; + + // determine numeric gaps + while (i === o || o in parent) { + if (i in params) i++; + if (o in parent) o++; + } + + // offset numeric indices in params before merge + for (i--; i >= 0; i--) { + params[i + o] = params[i]; + + // create holes for the merge when necessary + if (i < o) { + delete params[i]; + } + } + + return mixin(parent, params); +} + // restore obj props after function function restore(fn, obj) { var props = new Array(arguments.length - 2); diff --git a/test/app.router.js b/test/app.router.js index 71cea448da2..ade4240c962 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -5,6 +5,33 @@ var express = require('../') , methods = require('methods'); describe('app.router', function(){ + it('should restore req.params after leaving router', function(done){ + var app = express(); + var router = new express.Router(); + + function handler1(req, res, next){ + res.setHeader('x-user-id', req.params.id); + next() + } + + function handler2(req, res){ + res.send(req.params.id); + } + + router.use(function(req, res, next){ + res.setHeader('x-router', req.params.id); + next(); + }); + + app.get('/user/:id', handler1, router, handler2); + + request(app) + .get('/user/1') + .expect('x-router', 'undefined') + .expect('x-user-id', '1') + .expect(200, '1', done); + }) + describe('methods supported', function(){ methods.concat('del').forEach(function(method){ if (method === 'connect') return; @@ -183,6 +210,106 @@ describe('app.router', function(){ }) }) + describe('params', function(){ + it('should overwrite existing req.params by default', function(done){ + var app = express(); + var router = new express.Router(); + + router.get('/:action', function(req, res){ + res.send(req.params); + }); + + app.use('/user/:user', router); + + request(app) + .get('/user/1/get') + .expect(200, '{"action":"get"}', done); + }) + + it('should allow merging existing req.params', function(done){ + var app = express(); + var router = new express.Router({ mergeParams: true }); + + router.get('/:action', function(req, res){ + var keys = Object.keys(req.params).sort(); + res.send(keys.map(function(k){ return [k, req.params[k]] })); + }); + + app.use('/user/:user', router); + + request(app) + .get('/user/tj/get') + .expect(200, '[["action","get"],["user","tj"]]', done); + }) + + it('should use params from router', function(done){ + var app = express(); + var router = new express.Router({ mergeParams: true }); + + router.get('/:thing', function(req, res){ + var keys = Object.keys(req.params).sort(); + res.send(keys.map(function(k){ return [k, req.params[k]] })); + }); + + app.use('/user/:thing', router); + + request(app) + .get('/user/tj/get') + .expect(200, '[["thing","get"]]', done); + }) + + it('should merge numeric indices req.params', function(done){ + var app = express(); + var router = new express.Router({ mergeParams: true }); + + router.get('/*.*', function(req, res){ + var keys = Object.keys(req.params).sort(); + res.send(keys.map(function(k){ return [k, req.params[k]] })); + }); + + app.use('/user/id:(\\d+)', router); + + request(app) + .get('/user/id:10/profile.json') + .expect(200, '[["0","10"],["1","profile"],["2","json"]]', done); + }) + + it('should merge numeric indices req.params when more in parent', function(done){ + var app = express(); + var router = new express.Router({ mergeParams: true }); + + router.get('/*', function(req, res){ + var keys = Object.keys(req.params).sort(); + res.send(keys.map(function(k){ return [k, req.params[k]] })); + }); + + app.use('/user/id:(\\d+)/name:(\\w+)', router); + + request(app) + .get('/user/id:10/name:tj/profile') + .expect(200, '[["0","10"],["1","tj"],["2","profile"]]', done); + }) + + it('should ignore invalid incoming req.params', function(done){ + var app = express(); + var router = new express.Router({ mergeParams: true }); + + router.get('/:name', function(req, res){ + var keys = Object.keys(req.params).sort(); + res.send(keys.map(function(k){ return [k, req.params[k]] })); + }); + + app.use('/user/', function (req, res, next) { + req.params = 3; // wat? + router(req, res, next); + }); + + request(app) + .get('/user/tj') + .expect(200, '[["name","tj"]]', done); + }) + }) + describe('trailing slashes', function(){ it('should be optional by default', function(done){ var app = express(); @@ -656,33 +783,6 @@ describe('app.router', function(){ .expect(200, '0,1,2,3,4,5', done); }) - it('should provide req.params to all handlers', function(done){ - var app = express(); - var router = new express.Router(); - - function handler1(req, res, next){ - res.setHeader('x-user-id', req.params.id); - next() - } - - function handler2(req, res){ - res.send(req.params.id); - } - - router.use(function(req, res, next){ - res.setHeader('x-router', req.params.id); - next(); - }); - - app.get('/user/:id', handler1, router, handler2); - - request(app) - .get('/user/1') - .expect('x-router', 'undefined') - .expect('x-user-id', '1') - .expect(200, '1', done); - }) - it('should be chainable', function(){ var app = express(); app.get('/', function(){}).should.equal(app); From ca306eace1befc9d290cd5f79be8e6ba7c01b917 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 10:49:53 -0400 Subject: [PATCH 0356/1265] deps: update example dependencies --- examples/auth/app.js | 6 +++++- examples/mvc/index.js | 6 +++++- examples/session/index.js | 6 +++++- examples/session/redis.js | 7 ++++++- package.json | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/examples/auth/app.js b/examples/auth/app.js index 79c74dbb345..d110fe28d42 100644 --- a/examples/auth/app.js +++ b/examples/auth/app.js @@ -17,7 +17,11 @@ app.set('views', __dirname + '/views'); // middleware app.use(bodyParser.urlencoded({ extended: false })); -app.use(session({ secret: 'shhhh, very secret' })); +app.use(session({ + resave: false, // don't save session if unmodified + saveUninitialized: false, // don't create session until something stored + secret: 'shhhh, very secret' +})); // Session-persisted message middleware diff --git a/examples/mvc/index.js b/examples/mvc/index.js index 91e2bf7a763..bf7f726e30f 100644 --- a/examples/mvc/index.js +++ b/examples/mvc/index.js @@ -37,7 +37,11 @@ if (!module.parent) app.use(logger('dev')); app.use(express.static(__dirname + '/public')); // session support -app.use(session({ secret: 'some secret here' })); +app.use(session({ + resave: false, // don't save session if unmodified + saveUninitialized: false, // don't create session until something stored + secret: 'some secret here' +})); // parse request bodies (req.body) app.use(bodyParser.urlencoded({ extended: true })); diff --git a/examples/session/index.js b/examples/session/index.js index de60eac0b8f..de41a77d2c0 100644 --- a/examples/session/index.js +++ b/examples/session/index.js @@ -8,7 +8,11 @@ var session = require('express-session'); var app = express(); // Populates req.session -app.use(session({ secret: 'keyboard cat' })); +app.use(session({ + resave: false, // don't save session if unmodified + saveUninitialized: false, // don't create session until something stored + secret: 'keyboard cat' +})); app.get('/', function(req, res){ var body = ''; diff --git a/examples/session/redis.js b/examples/session/redis.js index 77fe60f7aeb..1338d6e95e6 100644 --- a/examples/session/redis.js +++ b/examples/session/redis.js @@ -15,7 +15,12 @@ var app = express(); app.use(logger('dev')); // Populates req.session -app.use(session({ store: new RedisStore, secret: 'keyboard cat' })); +app.use(session({ + resave: false, // don't save session if unmodified + saveUninitialized: false, // don't create session until something stored + secret: 'keyboard cat', + store: new RedisStore +})); app.get('/', function(req, res){ var body = ''; diff --git a/package.json b/package.json index 31a8b35539f..ac3693df728 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "hjs": "~0.0.6", "body-parser": "~1.4.3", "cookie-parser": "~1.3.1", - "express-session": "~1.5.0", + "express-session": "~1.6.1", "method-override": "2.0.2", "morgan": "1.1.1", "vhost": "2.0.0" From d1b1dfd472a790f165ee2ef98565e353eb4f632e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 11:11:18 -0400 Subject: [PATCH 0357/1265] deps: serve-static@~1.3.0 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 81029b58fd9..6df81e17f2c 100644 --- a/History.md +++ b/History.md @@ -12,6 +12,11 @@ unreleased * restore `req.params` after invoking router * use `finalhandler` for final response handling * use `media-typer` to alter content-type charset + * deps: serve-static@~1.3.0 + - Accept string for `maxAge` (converted by `ms`) + - Add `setHeaders` option + - Include HTML link in redirect response + - deps: send@0.5.0 * deps: type-is@~1.3.2 4.4.5 / 2014-06-26 diff --git a/package.json b/package.json index ac3693df728..5aceff68ed0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.4.3", - "serve-static": "1.2.3", + "serve-static": "~1.3.0", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 3136e98dced1739d4c724135c5515f8c8a9543f2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 11:18:35 -0400 Subject: [PATCH 0358/1265] deps: send@0.5.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6df81e17f2c..2bf296d9df1 100644 --- a/History.md +++ b/History.md @@ -12,6 +12,9 @@ unreleased * restore `req.params` after invoking router * use `finalhandler` for final response handling * use `media-typer` to alter content-type charset + * deps: send@0.5.0 + - Accept string for `maxage` (converted by `ms`) + - Include link in default redirect response * deps: serve-static@~1.3.0 - Accept string for `maxAge` (converted by `ms`) - Add `setHeaders` option diff --git a/package.json b/package.json index 5aceff68ed0..f63622f7f19 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "parseurl": "1.0.1", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.4.3", + "send": "0.5.0", "serve-static": "~1.3.0", "type-is": "~1.3.2", "vary": "0.1.0", From ce3d1fe07ed312f3b8420bd4e200fbb58bcae434 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 12:53:49 -0400 Subject: [PATCH 0359/1265] Add headers option to res.sendfile --- History.md | 2 ++ lib/response.js | 35 ++++++++++++++++++++++++++--------- test/res.sendfile.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/History.md b/History.md index 2bf296d9df1..d28542bf52c 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * add deprecation message to non-plural `req.accepts*` * add deprecation message to `res.send(body, status)` * add deprecation message to `res.vary()` + * add `headers` option to `res.sendfile` + - use to set headers on successful file transfer * add `mergeParams` option to `Router` - merges `req.params` from parent routes * deprecate things with `depd` module diff --git a/lib/response.js b/lib/response.js index 9a0a8864585..13f215d33be 100644 --- a/lib/response.js +++ b/lib/response.js @@ -278,9 +278,10 @@ res.jsonp = function(obj){ * * Options: * - * - `maxAge` defaulting to 0 - * - `root` root directory for relative filenames - * - `hidden` serve hidden files, defaulting to false + * - `maxAge` defaulting to 0 (can be string converted by `ms`) + * - `root` root directory for relative filenames + * - `headers` object of headers to serve with file + * - `hidden` serve hidden files, defaulting to false * * Other options are passed along to `send`. * @@ -331,14 +332,10 @@ res.sendfile = function(path, options, fn){ // clean up cleanup(); - if (!self.headersSent) self.removeHeader('Content-Disposition'); // callback available if (fn) return fn(err); - // list in limbo if there's no callback - if (self.headersSent) return; - // delegate next(err); } @@ -363,6 +360,21 @@ res.sendfile = function(path, options, fn){ file.on('error', error); file.on('directory', next); file.on('stream', stream); + + if (options.headers) { + // set headers on successful transfer + file.on('headers', function headers(res) { + var obj = options.headers; + var keys = Object.keys(obj); + + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + res.setHeader(k, obj[k]); + } + }); + } + + // pipe file.pipe(this); this.on('finish', cleanup); }; @@ -388,8 +400,13 @@ res.download = function(path, filename, fn){ } filename = filename || path; - this.set('Content-Disposition', contentDisposition(filename)); - return this.sendfile(path, fn); + + // set Content-Disposition when file is sent + var headers = { + 'Content-Disposition': contentDisposition(filename) + }; + + return this.sendfile(path, { headers: headers }, fn); }; /** diff --git a/test/res.sendfile.js b/test/res.sendfile.js index 6fcbf11758a..45e55845bb8 100644 --- a/test/res.sendfile.js +++ b/test/res.sendfile.js @@ -130,6 +130,41 @@ describe('res', function(){ .expect(200, 'tobi', done); }) + it('should accept headers option', function(done){ + var app = express(); + var headers = { + 'x-success': 'sent', + 'x-other': 'done' + }; + + app.use(function(req, res){ + res.sendfile('test/fixtures/user.html', { headers: headers }); + }); + + request(app) + .get('/') + .expect('x-success', 'sent') + .expect('x-other', 'done') + .expect(200, done); + }) + + it('should ignore headers option on 404', function(done){ + var app = express(); + var headers = { 'x-success': 'sent' }; + + app.use(function(req, res){ + res.sendfile('test/fixtures/user.nothing', { headers: headers }); + }); + + request(app) + .get('/') + .expect(404, function (err, res) { + if (err) return done(err); + res.headers.should.not.have.property('x-success'); + done(); + }); + }) + describe('with an absolute path', function(){ it('should transfer the file', function(done){ var app = express(); From c468f5ff2031150bc95d16e1716569716be46788 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 11:18:35 -0400 Subject: [PATCH 0360/1265] deps: send@0.5.0 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7c67c733e5f..245cc0181ef 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +unreleased +========== + + * deps: send@0.5.0 + - Accept string for `maxage` (converted by `ms`) + - Include link in default redirect response + 3.12.1 / 2014-06-26 =================== diff --git a/package.json b/package.json index e29e9eeab9c..818d28dd21d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "parseurl": "1.0.1", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.4.3", + "send": "0.5.0", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From 185e327e29e8afbb23d7d0ad3c74aba31883370f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 14:13:39 -0400 Subject: [PATCH 0361/1265] add deprecation message to app.configure --- History.md | 1 + lib/application.js | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index 245cc0181ef..dcb4d666bd9 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * add deprecation message to `app.configure` * deps: send@0.5.0 - Accept string for `maxage` (converted by `ms`) - Include link in default redirect response diff --git a/lib/application.js b/lib/application.js index e4618fbd967..5be5ad45e98 100644 --- a/lib/application.js +++ b/lib/application.js @@ -48,10 +48,12 @@ app.defaultConfiguration = function(){ // default settings this.enable('x-powered-by'); this.set('etag', 'weak'); - this.set('env', process.env.NODE_ENV || 'development'); + var env = process.env.NODE_ENV || 'development'; + this.set('env', env); this.set('subdomain offset', 2); this.set('trust proxy', false); - debug('booting in %s mode', this.get('env')); + + debug('booting in %s mode', env); // implicit middleware this.use(connect.query()); @@ -86,13 +88,13 @@ app.defaultConfiguration = function(){ this.set('views', process.cwd() + '/views'); this.set('jsonp callback name', 'callback'); - this.configure('development', function(){ + if (env === 'development') { this.set('json spaces', 2); - }); + } - this.configure('production', function(){ + if (env === 'production') { this.enable('view cache'); - }); + } }; /** @@ -411,6 +413,9 @@ app.configure = function(env, fn){ return this; }; +app.configure = deprecate.function(app.configure, + 'app.configure: Check app.get(\'env\') in an if statement'); + /** * Delegate `.VERB(...)` calls to `router.VERB(...)`. */ From 12507cfcd0958b2e49a2f4ff6b96d5e772656eb1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 23:09:44 -0400 Subject: [PATCH 0362/1265] deps: connect@2.22.0 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index dcb4d666bd9..40972bf7a2d 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,11 @@ unreleased ========== * add deprecation message to `app.configure` + * deps: connect@2.22.0 + - deps: csurf@~1.3.0 + - deps: express-session@~1.6.1 + - deps: multiparty@3.3.0 + - deps: serve-static@~1.3.0 * deps: send@0.5.0 - Accept string for `maxage` (converted by `ms`) - Include link in default redirect response diff --git a/package.json b/package.json index 818d28dd21d..33ff74b50cf 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "license": "MIT", "dependencies": { "buffer-crc32": "0.2.3", - "connect": "2.21.1", + "connect": "2.22.0", "commander": "1.3.2", "debug": "1.0.2", "depd": "0.3.0", From f381f2d9b6e9ed962f5efff367cfff8d52d02ede Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 00:24:01 -0400 Subject: [PATCH 0363/1265] add deprecation message to req.auth --- History.md | 2 ++ lib/request.js | 19 +++++++------------ package.json | 1 + 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/History.md b/History.md index 40972bf7a2d..60b6ee68d09 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * add deprecation message to `app.configure` + * add deprecation message to `req.auth` + * use `basic-auth` to parse `Authorization` header * deps: connect@2.22.0 - deps: csurf@~1.3.0 - deps: express-session@~1.6.1 diff --git a/lib/request.js b/lib/request.js index dac29ee44f8..065e4c6fe3c 100644 --- a/lib/request.js +++ b/lib/request.js @@ -3,6 +3,8 @@ * Module dependencies. */ +var auth = require('basic-auth'); +var deprecate = require('depd')('express'); var http = require('http') , utils = require('./utils') , connect = require('connect') @@ -422,20 +424,13 @@ req.__defineGetter__('ips', function(){ */ req.__defineGetter__('auth', function(){ - // missing - var auth = this.get('Authorization'); - if (!auth) return; - - // malformed - var parts = auth.split(' '); - if ('basic' != parts[0].toLowerCase()) return; - if (!parts[1]) return; - auth = parts[1]; + deprecate('req.auth: Use basic-auth module directly'); // credentials - auth = new Buffer(auth, 'base64').toString().match(/^([^:]*):(.*)$/); - if (!auth) return; - return { username: auth[1], password: auth[2] }; + var creds = auth(this); + if (!creds) return; + + return { username: creds.name, password: creds.pass }; }); /** diff --git a/package.json b/package.json index 33ff74b50cf..ca1fe625efd 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "repository": "visionmedia/express", "license": "MIT", "dependencies": { + "basic-auth": "0.0.1", "buffer-crc32": "0.2.3", "connect": "2.22.0", "commander": "1.3.2", From b601d64203d50950bee4dee967187b06becfb6f4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 00:38:59 -0400 Subject: [PATCH 0364/1265] tests: fix inconsistent test --- test/app.head.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/app.head.js b/test/app.head.js index 9ba2ad9a911..ed8499ce293 100644 --- a/test/app.head.js +++ b/test/app.head.js @@ -34,6 +34,8 @@ describe('HEAD', function(){ .get('/tobi') .expect(200, function(err, res){ if (err) return done(err); + delete headers.date; + delete res.headers.date; assert.deepEqual(res.headers, headers); done(); }); From abe0ffa311bf39ca2bbfc8791856753b7cabe843 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 00:40:01 -0400 Subject: [PATCH 0365/1265] 3.13.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 60b6ee68d09..322cdaf971f 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +3.13.0 / 2014-07-03 +=================== * add deprecation message to `app.configure` * add deprecation message to `req.auth` diff --git a/package.json b/package.json index ca1fe625efd..1c0a31d02c8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.12.1", + "version": "3.13.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 32dbda1460bd042bc68d2a9e6ef4f86fd0d8ea87 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 01:23:14 -0400 Subject: [PATCH 0366/1265] deps: istanbul@0.2.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f63622f7f19..931f751bb79 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "after": "0.8.1", - "istanbul": "0.2.12", + "istanbul": "0.2.14", "mocha": "~1.20.1", "should": "~4.0.4", "supertest": "~0.13.0", From 99e839a27460cc3b014c8b4d7cb4be8ec5857c67 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 01:24:42 -0400 Subject: [PATCH 0367/1265] deps: update example dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 931f751bb79..9bff085bb2e 100644 --- a/package.json +++ b/package.json @@ -58,12 +58,12 @@ "ejs": "~1.0.0", "jade": "~1.3.1", "marked": "0.3.2", - "multiparty": "~3.2.4", "hjs": "~0.0.6", "body-parser": "~1.4.3", "cookie-parser": "~1.3.1", "express-session": "~1.6.1", "method-override": "2.0.2", + "multiparty": "~3.3.0", "morgan": "1.1.1", "vhost": "2.0.0" }, From efbc3f95eebbe56683948e5d80add740afe37a85 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 12:51:44 -0400 Subject: [PATCH 0368/1265] deps: accepts@~1.0.7 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ca8ca42c014..fb9507b3b80 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,7 @@ unreleased * restore `req.params` after invoking router * use `finalhandler` for final response handling * use `media-typer` to alter content-type charset + * deps: accepts@~1.0.7 * deps: send@0.5.0 - Accept string for `maxage` (converted by `ms`) - Include link in default redirect response diff --git a/package.json b/package.json index 9bff085bb2e..4b5681883ad 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "repository": "visionmedia/express", "license": "MIT", "dependencies": { - "accepts": "~1.0.5", + "accepts": "~1.0.7", "buffer-crc32": "0.2.3", "debug": "1.0.2", "depd": "0.3.0", From 269dc5323f41ce9d56229784f9441857fbf5f27f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Jul 2014 16:41:23 -0400 Subject: [PATCH 0369/1265] Invoke router.param() only when route matches fixes #2206 --- History.md | 1 + lib/router/index.js | 14 +++++++++++--- lib/router/route.js | 19 +++++++++++++++++++ test/app.param.js | 25 +++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index fb9507b3b80..d8d1d5b21c6 100644 --- a/History.md +++ b/History.md @@ -11,6 +11,7 @@ unreleased * deprecate things with `depd` module * fix behavior when handling request without routes * fix handling when `route.all` is only route + * invoke `router.param()` only when route matches * restore `req.params` after invoking router * use `finalhandler` for final response handling * use `media-typer` to alter content-type charset diff --git a/lib/router/index.js b/lib/router/index.js index 388ac9d6d07..23c1f8b0a42 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -191,12 +191,20 @@ proto.handle = function(req, res, done) { return next(err); } - req.route = route; + var has_method = route._handles_method(method); - // we can now dispatch to the route - if (method === 'options' && !route.methods['options']) { + // build up automatic options response + if (!has_method && method === 'options') { options.push.apply(options, route._options()); } + + // don't even bother + if (!has_method && method !== 'head') { + return next(); + } + + // we can now dispatch to the route + req.route = route; } // Capture one-time layer values diff --git a/lib/router/route.js b/lib/router/route.js index f67d0dd727f..e9cf1a95abd 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -28,6 +28,24 @@ function Route(path) { this.methods = {}; } +/** + * @api private + */ + +Route.prototype._handles_method = function _handles_method(method) { + if (this.methods._all) { + return true; + } + + method = method.toLowerCase(); + + if (method === 'head' && !this.methods['head']) { + method = 'get'; + } + + return Boolean(this.methods[method]); +}; + /** * @return {Array} supported HTTP methods * @api private @@ -137,6 +155,7 @@ Route.prototype.all = function(){ throw new Error(msg); } + self.methods._all = true; self.stack.push({ handle: fn }); }); diff --git a/test/app.param.js b/test/app.param.js index 9c6264c274c..cd5bc9b298b 100644 --- a/test/app.param.js +++ b/test/app.param.js @@ -177,6 +177,31 @@ describe('app', function(){ .expect('loki', done); }) + it('should not invoke without route handler', function(done) { + var app = express(); + + app.param('thing', function(req, res, next, thing) { + req.thing = thing; + next(); + }); + + app.param('user', function(req, res, next, user) { + next(new Error('invalid invokation')); + }); + + app.post('/:user', function(req, res, next) { + res.send(req.params.user); + }); + + app.get('/:thing', function(req, res, next) { + res.send(req.thing); + }); + + request(app) + .get('/bob') + .expect(200, 'bob', done); + }) + it('should work with encoded values', function(done){ var app = express(); From e6eeec3f0392f32271309e92aec965b00bbb777d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 13:59:01 -0400 Subject: [PATCH 0370/1265] Add req.hostname closes #2179 --- History.md | 2 + lib/request.js | 12 +++- test/req.hostname.js | 138 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 test/req.hostname.js diff --git a/History.md b/History.md index d8d1d5b21c6..5df9e78aaf9 100644 --- a/History.md +++ b/History.md @@ -8,7 +8,9 @@ unreleased - use to set headers on successful file transfer * add `mergeParams` option to `Router` - merges `req.params` from parent routes + * add `req.hostname` -- correct name for what `req.host` returns * deprecate things with `depd` module + * deprecate `req.host` -- use `req.hostname` instead * fix behavior when handling request without routes * fix handling when `route.all` is only route * invoke `router.param()` only when route matches diff --git a/lib/request.js b/lib/request.js index e7e7f8e9563..514175b0037 100644 --- a/lib/request.js +++ b/lib/request.js @@ -330,7 +330,7 @@ defineGetter(req, 'ips', function ips() { defineGetter(req, 'subdomains', function subdomains() { var offset = this.app.get('subdomain offset'); - return (this.host || '') + return (this.hostname || '') .split('.') .reverse() .slice(offset); @@ -348,7 +348,7 @@ defineGetter(req, 'path', function path() { }); /** - * Parse the "Host" header field hostname. + * Parse the "Host" header field to a hostname. * * When the "trust proxy" setting trusts the socket * address, the "X-Forwarded-Host" header field will @@ -358,7 +358,7 @@ defineGetter(req, 'path', function path() { * @api public */ -defineGetter(req, 'host', function host(){ +defineGetter(req, 'hostname', function hostname(){ var trust = this.app.get('trust proxy fn'); var host = this.get('X-Forwarded-Host'); @@ -379,6 +379,12 @@ defineGetter(req, 'host', function host(){ : host; }); +// TODO: change req.host to return host in next major + +defineGetter(req, 'host', deprecate.function(function host(){ + return this.hostname; +}, 'req.host: Use req.hostname instead')); + /** * Check if the request is fresh, aka * Last-Modified and/or the ETag diff --git a/test/req.hostname.js b/test/req.hostname.js new file mode 100644 index 00000000000..65c2be81a1f --- /dev/null +++ b/test/req.hostname.js @@ -0,0 +1,138 @@ + +var express = require('../') + , request = require('supertest') + , assert = require('assert'); + +describe('req', function(){ + describe('.hostname', function(){ + it('should return the Host when present', function(done){ + var app = express(); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .post('/') + .set('Host', 'example.com') + .expect('example.com', done); + }) + + it('should strip port number', function(done){ + var app = express(); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .post('/') + .set('Host', 'example.com:3000') + .expect('example.com', done); + }) + + it('should return undefined otherwise', function(done){ + var app = express(); + + app.use(function(req, res){ + req.headers.host = null; + res.end(String(req.hostname)); + }); + + request(app) + .post('/') + .expect('undefined', done); + }) + + it('should work with IPv6 Host', function(done){ + var app = express(); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .post('/') + .set('Host', '[::1]') + .expect('[::1]', done); + }) + + it('should work with IPv6 Host and port', function(done){ + var app = express(); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .post('/') + .set('Host', '[::1]:3000') + .expect('[::1]', done); + }) + + describe('when "trust proxy" is enabled', function(){ + it('should respect X-Forwarded-Host', function(done){ + var app = express(); + + app.enable('trust proxy'); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .get('/') + .set('Host', 'localhost') + .set('X-Forwarded-Host', 'example.com:3000') + .expect('example.com', done); + }) + + it('should ignore X-Forwarded-Host if socket addr not trusted', function(done){ + var app = express(); + + app.set('trust proxy', '10.0.0.1'); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .get('/') + .set('Host', 'localhost') + .set('X-Forwarded-Host', 'example.com') + .expect('localhost', done); + }) + + it('should default to Host', function(done){ + var app = express(); + + app.enable('trust proxy'); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .get('/') + .set('Host', 'example.com') + .expect('example.com', done); + }) + }) + + describe('when "trust proxy" is disabled', function(){ + it('should ignore X-Forwarded-Host', function(done){ + var app = express(); + + app.use(function(req, res){ + res.end(req.hostname); + }); + + request(app) + .get('/') + .set('Host', 'localhost') + .set('X-Forwarded-Host', 'evil') + .expect('localhost', done); + }) + }) + }) +}) From bd6908516dd88320522d3a9d6089dde4d6005bba Mon Sep 17 00:00:00 2001 From: Fishrock123 Date: Fri, 4 Jul 2014 15:10:19 -0400 Subject: [PATCH 0371/1265] docs: cleanup readme, update package description closes #2210 --- Readme.md | 110 +++++++++++++++++++++++++++++---------------------- package.json | 2 +- 2 files changed, 63 insertions(+), 49 deletions(-) diff --git a/Readme.md b/Readme.md index 33caf7ff842..18fbcc51c69 100644 --- a/Readme.md +++ b/Readme.md @@ -1,48 +1,58 @@ -[![express logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/) +[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](https://expressjs.com/) - Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). + Fast, unopinionated, minimalist web framework for [node](https://nodejs.org). - [![NPM version](https://badge.fury.io/js/express.svg)](http://badge.fury.io/js/express) + [![NPM Version](https://badge.fury.io/js/express.svg)](https://badge.fury.io/js/express) [![Build Status](https://travis-ci.org/visionmedia/express.svg?branch=master)](https://travis-ci.org/visionmedia/express) [![Coverage Status](https://img.shields.io/coveralls/visionmedia/express.svg)](https://coveralls.io/r/visionmedia/express) - [![Gittip](http://img.shields.io/gittip/visionmedia.svg)](https://www.gittip.com/visionmedia/) + [![Gittip](https://img.shields.io/gittip/visionmedia.svg)](https://www.gittip.com/visionmedia/) ```js -var express = require('express'); -var app = express(); +var express = require('express') +var app = express() -app.get('/', function(req, res){ - res.send('Hello World'); -}); +app.get('/', function (req, res) { + res.send('Hello World') +}) -app.listen(3000); +app.listen(3000) ``` -**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/visionmedia/express/wiki/New-features-in-4.x). + **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/visionmedia/express/wiki/New-features-in-4.x). -## Installation +### Installation - $ npm install express +```bash +$ npm install express +``` ## Quick Start - The quickest way to get started with express is to utilize the executable [`express(1)`](http://github.com/expressjs/generator) to generate an application as shown below: - - Install the executable. The executable's major version will match Express's: - - $ npm install -g express-generator@3 + The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below: + + Install the executable. The executable's major version will match Express's: - Create the app: +```bash +$ npm install -g express-generator@4 +``` - $ express /tmp/foo && cd /tmp/foo + Create the app: + +```bash +$ express /tmp/foo && cd /tmp/foo +``` - Install dependencies: + Install dependencies: - $ npm install +```bash +$ npm install +``` - Start the server: + Start the server: - $ npm start +```bash +$ npm start +``` ## Features @@ -61,53 +71,57 @@ app.listen(3000); HTTP APIs. Express does not force you to use any specific ORM or template engine. With support for over - 14 template engines via [Consolidate.js](http://github.com/visionmedia/consolidate.js), + 14 template engines via [Consolidate.js](https://github.com/visionmedia/consolidate.js), you can quickly craft your perfect framework. ## More Information - * [Website and Documentation](http://expressjs.com/) stored at [visionmedia/expressjs.com](https://github.com/visionmedia/expressjs.com) - * Join #express on freenode - * [Google Group](http://groups.google.com/group/express-js) for discussion - * Follow [tjholowaychuk](http://twitter.com/tjholowaychuk) and [defunctzombie](https://twitter.com/defunctzombie) on twitter for updates - * Visit the [Wiki](http://github.com/visionmedia/express/wiki) + * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/visionmedia/expressjs.com)] + * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules + * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC + * Visit the [Wiki](https://github.com/visionmedia/express/wiki) + * [Google Group](https://groups.google.com/group/express-js) for discussion * [Русскоязычная документация](http://jsman.ru/express/) * Run express examples [online](https://runnable.com/express) ## Viewing Examples -Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies: + Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies: - $ git clone git://github.com/visionmedia/express.git --depth 1 - $ cd express - $ npm install +```bash +$ git clone git://github.com/visionmedia/express.git --depth 1 +$ cd express +$ npm install +``` -Then run whichever tests you want: + Then run whichever example you want: $ node examples/content-negotiation -You can also view live examples here: + You can also view live examples here: - + ## Running Tests -To run the test suite, first invoke the following command within the repo, installing the development dependencies: + To run the test suite, first invoke the following command within the repo, installing the development dependencies: - $ npm install +```bash +$ npm install +``` -Then run the tests: + Then run the tests: -```sh +```bash $ npm test ``` -## Contributors - - Author: [TJ Holowaychuk](http://github.com/visionmedia) - Lead Maintainer: [Roman Shtylman](https://github.com/defunctzombie) - Contributors: https://github.com/visionmedia/express/graphs/contributors +### Contributors + + * Author: [TJ Holowaychuk](https://github.com/visionmedia) + * Lead Maintainer: [Douglas Christopher Wilson](https://github.com/dougwilson) + * [All Contributors](https://github.com/visionmedia/express/graphs/contributors) -## License +### License -MIT + [MIT](LICENSE) diff --git a/package.json b/package.json index 4b5681883ad..7a20c574670 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "express", - "description": "Sinatra inspired web development framework", + "description": "Fast, unopinionated, minimalist web framework", "version": "4.4.5", "author": "TJ Holowaychuk ", "contributors": [ From 92c45199bdcbb1ffa753026f3862d7ad3dc7c514 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Jul 2014 21:03:07 -0400 Subject: [PATCH 0372/1265] 4.5.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 5df9e78aaf9..ed6059ce33f 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.5.0 / 2014-07-04 +================== * add deprecation message to non-plural `req.accepts*` * add deprecation message to `res.send(body, status)` diff --git a/package.json b/package.json index 7a20c574670..e0048d225e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.4.5", + "version": "4.5.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From b4b2efee0f0c07c944ead4444e63ac534fbf3238 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 5 Jul 2014 11:32:44 -0400 Subject: [PATCH 0373/1265] tests: add more app.use tests --- test/app.use.js | 84 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/test/app.use.js b/test/app.use.js index 9e115e95fee..dda16f4dd22 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -1,6 +1,7 @@ -var express = require('../') - , request = require('supertest'); +var after = require('after'); +var express = require('..'); +var request = require('supertest'); describe('app', function(){ it('should emit "mount" when mounted', function(done){ @@ -84,4 +85,83 @@ describe('app', function(){ .expect('success', done); }) }) + + describe('.use(middleware)', function(){ + it('should invoke middleware for all requests', function (done) { + var app = express(); + var cb = after(3, done); + + app.use(function (req, res) { + res.send('saw ' + req.method + ' ' + req.url); + }); + + request(app) + .get('/') + .expect(200, 'saw GET /', cb); + + request(app) + .options('/') + .expect(200, 'saw OPTIONS /', cb); + + request(app) + .post('/foo') + .expect(200, 'saw POST /foo', cb); + }) + }) + + describe('.use(path, middleware)', function(){ + it('should strip path from req.url', function (done) { + var app = express(); + + app.use('/foo', function (req, res) { + res.send('saw ' + req.method + ' ' + req.url); + }); + + request(app) + .get('/foo/bar') + .expect(200, 'saw GET /bar', done); + }) + + it('should invoke middleware for all requests starting with path', function (done) { + var app = express(); + var cb = after(3, done); + + app.use('/foo', function (req, res) { + res.send('saw ' + req.method + ' ' + req.url); + }); + + request(app) + .get('/') + .expect(404, cb); + + request(app) + .post('/foo') + .expect(200, 'saw POST /', cb); + + request(app) + .post('/foo/bar') + .expect(200, 'saw POST /bar', cb); + }) + + it('should work if path has trailing slash', function (done) { + var app = express(); + var cb = after(3, done); + + app.use('/foo/', function (req, res) { + res.send('saw ' + req.method + ' ' + req.url); + }); + + request(app) + .get('/') + .expect(404, cb); + + request(app) + .post('/foo') + .expect(200, 'saw POST /', cb); + + request(app) + .post('/foo/bar') + .expect(200, 'saw POST /bar', cb); + }) + }) }) From 23a49ff61eb30181917240bf722d89752738a1fe Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 6 Jul 2014 19:42:08 -0400 Subject: [PATCH 0374/1265] Fix routing regression when altering req.method --- History.md | 5 +++++ lib/router/index.js | 9 ++++----- test/app.router.js | 32 +++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index ed6059ce33f..765bbc1e659 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * fix routing regression when altering `req.method` + 4.5.0 / 2014-07-04 ================== diff --git a/lib/router/index.js b/lib/router/index.js index 23c1f8b0a42..c08b39cd935 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -115,8 +115,6 @@ proto.handle = function(req, res, done) { debug('dispatching %s %s', req.method, req.url); - var method = req.method.toLowerCase(); - var search = 1 + req.url.indexOf('?'); var pathlength = search ? search - 1 : req.url.length; var fqdn = 1 + req.url.substr(0, pathlength).indexOf('://'); @@ -142,7 +140,7 @@ proto.handle = function(req, res, done) { req.next = next; // for options requests, respond with a default if nothing else responds - if (method === 'options') { + if (req.method === 'OPTIONS') { done = wrap(done, function(old, err) { if (err || options.length === 0) return old(err); @@ -191,15 +189,16 @@ proto.handle = function(req, res, done) { return next(err); } + var method = req.method; var has_method = route._handles_method(method); // build up automatic options response - if (!has_method && method === 'options') { + if (!has_method && method === 'OPTIONS') { options.push.apply(options, route._options()); } // don't even bother - if (!has_method && method !== 'head') { + if (!has_method && method !== 'HEAD') { return next(); } diff --git a/test/app.router.js b/test/app.router.js index ade4240c962..f785069050f 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -1,4 +1,5 @@ +var after = require('after'); var express = require('../') , request = require('supertest') , assert = require('assert') @@ -32,7 +33,7 @@ describe('app.router', function(){ .expect(200, '1', done); }) - describe('methods supported', function(){ + describe('methods', function(){ methods.concat('del').forEach(function(method){ if (method === 'connect') return; @@ -58,6 +59,35 @@ describe('app.router', function(){ app[method].bind(app, '/', 3).should.throw(/Number/); }) }); + + it('should re-route when method is altered', function (done) { + var app = express(); + var cb = after(3, done); + + app.use(function (req, res, next) { + if (req.method !== 'POST') return next(); + req.method = 'DELETE'; + res.setHeader('X-Method-Altered', '1'); + next(); + }); + + app.delete('/', function (req, res) { + res.end('deleted everything'); + }); + + request(app) + .get('/') + .expect(404, 'Cannot GET /\n', cb); + + request(app) + .delete('/') + .expect(200, 'deleted everything', cb); + + request(app) + .post('/') + .expect('X-Method-Altered', '1') + .expect(200, 'deleted everything', cb); + }); }) describe('decode querystring', function(){ From bcdeee2df510cea17ad4524cf53b9900a46d5042 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 6 Jul 2014 19:48:18 -0400 Subject: [PATCH 0375/1265] 4.5.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 765bbc1e659..5c999c70375 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.5.1 / 2014-07-06 +================== * fix routing regression when altering `req.method` diff --git a/package.json b/package.json index e0048d225e7..9dc608fb23b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.5.0", + "version": "4.5.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From ef497fdae413f85362d319436cf113edf6320677 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 7 Jul 2014 23:06:48 -0400 Subject: [PATCH 0376/1265] tests: add mounting to strict routing test --- test/app.router.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/test/app.router.js b/test/app.router.js index f785069050f..b7422b5664f 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -368,6 +368,46 @@ describe('app.router', function(){ .expect('tj', done); }) + it('should pass-though middleware', function(done){ + var app = express(); + + app.enable('strict routing'); + + app.use(function (req, res, next) { + res.setHeader('x-middleware', 'true'); + next(); + }); + + app.get('/user/', function(req, res){ + res.end('tj'); + }); + + request(app) + .get('/user/') + .expect('x-middleware', 'true') + .expect(200, 'tj', done); + }) + + it('should pass-though mounted middleware', function(done){ + var app = express(); + + app.enable('strict routing'); + + app.use('/user/', function (req, res, next) { + res.setHeader('x-middleware', 'true'); + next(); + }); + + app.get('/user/test/', function(req, res){ + res.end('tj'); + }); + + request(app) + .get('/user/test/') + .expect('x-middleware', 'true') + .expect(200, 'tj', done); + }) + it('should match no slashes', function(done){ var app = express(); @@ -382,6 +422,48 @@ describe('app.router', function(){ .expect('tj', done); }) + it('should match middleware when omitting the trailing slash', function(done){ + var app = express(); + + app.enable('strict routing'); + + app.use('/user/', function(req, res){ + res.end('tj'); + }); + + request(app) + .get('/user') + .expect(200, 'tj', done); + }) + + it('should match middleware', function(done){ + var app = express(); + + app.enable('strict routing'); + + app.use('/user', function(req, res){ + res.end('tj'); + }); + + request(app) + .get('/user') + .expect(200, 'tj', done); + }) + + it('should match middleware when adding the trailing slash', function(done){ + var app = express(); + + app.enable('strict routing'); + + app.use('/user', function(req, res){ + res.end('tj'); + }); + + request(app) + .get('/user/') + .expect(200, 'tj', done); + }) + it('should fail when omitting the trailing slash', function(done){ var app = express(); From 968b00c3d76995f09a274530e0a83321db45aae1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 8 Jul 2014 19:40:22 -0400 Subject: [PATCH 0377/1265] tests: add missing FQDN router URL tests --- test/Router.js | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/test/Router.js b/test/Router.js index cbc8acbc525..e42d9520108 100644 --- a/test/Router.js +++ b/test/Router.js @@ -174,6 +174,111 @@ describe('Router', function(){ }); }) + describe('FQDN', function () { + it('should not obscure FQDNs', function (done) { + var request = { hit: 0, url: 'http://example.com/foo', method: 'GET' }; + var router = new Router(); + + router.use(function (req, res, next) { + assert.equal(req.hit++, 0); + assert.equal(req.url, 'http://example.com/foo'); + next(); + }); + + router.handle(request, {}, function (err) { + if (err) return done(err); + assert.equal(request.hit, 1); + done(); + }); + }); + + it('should ignore FQDN in search', function (done) { + var request = { hit: 0, url: '/proxy?url=http://example.com/blog/post/1', method: 'GET' }; + var router = new Router(); + + router.use('/proxy', function (req, res, next) { + assert.equal(req.hit++, 0); + assert.equal(req.url, '/?url=http://example.com/blog/post/1'); + next(); + }); + + router.handle(request, {}, function (err) { + if (err) return done(err); + assert.equal(request.hit, 1); + done(); + }); + }); + + it('should adjust FQDN req.url', function (done) { + var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' }; + var router = new Router(); + + router.use('/blog', function (req, res, next) { + assert.equal(req.hit++, 0); + assert.equal(req.url, 'http://example.com/post/1'); + next(); + }); + + router.handle(request, {}, function (err) { + if (err) return done(err); + assert.equal(request.hit, 1); + done(); + }); + }); + + it('should adjust FQDN req.url with multiple handlers', function (done) { + var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' }; + var router = new Router(); + + router.use(function (req, res, next) { + assert.equal(req.hit++, 0); + assert.equal(req.url, 'http://example.com/blog/post/1'); + next(); + }); + + router.use('/blog', function (req, res, next) { + assert.equal(req.hit++, 1); + assert.equal(req.url, 'http://example.com/post/1'); + next(); + }); + + router.handle(request, {}, function (err) { + if (err) return done(err); + assert.equal(request.hit, 2); + done(); + }); + }); + + it('should adjust FQDN req.url with multiple routed handlers', function (done) { + var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' }; + var router = new Router(); + + router.use('/blog', function (req, res, next) { + assert.equal(req.hit++, 0); + assert.equal(req.url, 'http://example.com/post/1'); + next(); + }); + + router.use('/blog', function (req, res, next) { + assert.equal(req.hit++, 1); + assert.equal(req.url, 'http://example.com/post/1'); + next(); + }); + + router.use(function (req, res, next) { + assert.equal(req.hit++, 2); + assert.equal(req.url, 'http://example.com/blog/post/1'); + next(); + }); + + router.handle(request, {}, function (err) { + if (err) return done(err); + assert.equal(request.hit, 3); + done(); + }); + }); + }) + describe('.all', function() { it('should support using .all to capture all http verbs', function(done){ var router = new Router(); From 4fe1073f105dbc3b8aa00adf33aa5a19f248117c Mon Sep 17 00:00:00 2001 From: Ryan Seys Date: Tue, 8 Jul 2014 21:47:11 -0700 Subject: [PATCH 0378/1265] docs: fix nodejs.org link closes #2222 --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 18fbcc51c69..6940c71efdd 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ [![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](https://expressjs.com/) - Fast, unopinionated, minimalist web framework for [node](https://nodejs.org). + Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). [![NPM Version](https://badge.fury.io/js/express.svg)](https://badge.fury.io/js/express) [![Build Status](https://travis-ci.org/visionmedia/express.svg?branch=master)](https://travis-ci.org/visionmedia/express) From 7bcf5f508535a974090c370ec742733d79bcd1c9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 22:56:31 -0400 Subject: [PATCH 0379/1265] deps: connect@2.23.0 --- History.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 322cdaf971f..2e901781a48 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,13 @@ +3.x +=== + + * deps: connect@2.23.0 + - deps: debug@1.0.3 + - deps: express-session@~1.6.4 + - deps: method-override@~2.1.0 + - deps: parseurl@~1.1.3 + - deps: serve-static@~1.3.1 + 3.13.0 / 2014-07-03 =================== diff --git a/package.json b/package.json index 1c0a31d02c8..20f836753cf 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "0.0.1", "buffer-crc32": "0.2.3", - "connect": "2.22.0", + "connect": "2.23.0", "commander": "1.3.2", "debug": "1.0.2", "depd": "0.3.0", From 7c1f90bf1657e68deddad0864216396981d4fb15 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 22:57:08 -0400 Subject: [PATCH 0380/1265] deps: istanbul@0.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 20f836753cf..61704a41e5e 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "merge-descriptors": "0.0.2" }, "devDependencies": { - "istanbul": "0.2.12", + "istanbul": "0.3.0", "mocha": "~1.20.0", "should": "~4.0.0", "ejs": "~1.0.0", From 3c87a6aedefda6ac6101c929b37155c716461773 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 23:02:24 -0400 Subject: [PATCH 0381/1265] deps: debug@1.0.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2e901781a48..3ec904ad087 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ - deps: method-override@~2.1.0 - deps: parseurl@~1.1.3 - deps: serve-static@~1.3.1 + * deps: debug@1.0.3 + - Add support for multiple wildcards in namespaces 3.13.0 / 2014-07-03 =================== diff --git a/package.json b/package.json index 61704a41e5e..128537a73a3 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "buffer-crc32": "0.2.3", "connect": "2.23.0", "commander": "1.3.2", - "debug": "1.0.2", + "debug": "1.0.3", "depd": "0.3.0", "escape-html": "1.0.1", "media-typer": "0.2.0", From 577cc1d1a065e3a36816de067e328d4486135fbc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 23:03:26 -0400 Subject: [PATCH 0382/1265] deps: parseurl@~1.1.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3ec904ad087..702875f527e 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,8 @@ - deps: serve-static@~1.3.1 * deps: debug@1.0.3 - Add support for multiple wildcards in namespaces + * deps: parseurl@~1.1.3 + - faster parsing of href-only URLs 3.13.0 / 2014-07-03 =================== diff --git a/package.json b/package.json index 128537a73a3..434b374c815 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "media-typer": "0.2.0", "methods": "1.0.1", "mkdirp": "0.5.0", - "parseurl": "1.0.1", + "parseurl": "~1.1.3", "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.5.0", From 25ef8425d22347448fb5c85ad47775be6bea0d80 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 23:06:15 -0400 Subject: [PATCH 0383/1265] deps: methods@1.1.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 702875f527e..1153237e23a 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,8 @@ - deps: serve-static@~1.3.1 * deps: debug@1.0.3 - Add support for multiple wildcards in namespaces + * deps: methods@1.1.0 + - add `CONNECT` * deps: parseurl@~1.1.3 - faster parsing of href-only URLs diff --git a/package.json b/package.json index 434b374c815..2b8093cff0b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "depd": "0.3.0", "escape-html": "1.0.1", "media-typer": "0.2.0", - "methods": "1.0.1", + "methods": "1.1.0", "mkdirp": "0.5.0", "parseurl": "~1.1.3", "proxy-addr": "1.0.1", From cf8005e63fb2d1d3ade4bc503034126dcdf6e227 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 23:07:45 -0400 Subject: [PATCH 0384/1265] deps: basic-auth@1.0.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1153237e23a..a00fcd67a6c 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,9 @@ 3.x === + * deps: basic-auth@1.0.0 + - support empty password + - support empty username * deps: connect@2.23.0 - deps: debug@1.0.3 - deps: express-session@~1.6.4 diff --git a/package.json b/package.json index 2b8093cff0b..3d66e6ec909 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "repository": "visionmedia/express", "license": "MIT", "dependencies": { - "basic-auth": "0.0.1", + "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", "connect": "2.23.0", "commander": "1.3.2", From 544c6665f54b1ebdbc54769ba78721c4e13acdf7 Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Thu, 10 Jul 2014 11:44:47 +0800 Subject: [PATCH 0385/1265] Fix res.send(status, num) to send num as json fixes #2226 --- History.md | 1 + lib/response.js | 15 +++++++++------ test/res.send.js | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index a00fcd67a6c..a94295825ca 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * fix `res.send(status, num)` to send `num` as json (not error) * deps: basic-auth@1.0.0 - support empty password - support empty username diff --git a/lib/response.js b/lib/response.js index 339bf0c483a..ebdb1a8f924 100644 --- a/lib/response.js +++ b/lib/response.js @@ -103,13 +103,15 @@ res.send = function(body){ } } + // disambiguate res.send(status) and res.send(status, num) + if (typeof body === 'number' && arguments.length === 1) { + // res.send(status) will set status message as text string + this.get('Content-Type') || this.type('txt'); + this.statusCode = body; + body = http.STATUS_CODES[body]; + } + switch (typeof body) { - // response status - case 'number': - this.get('Content-Type') || this.type('txt'); - this.statusCode = body; - body = http.STATUS_CODES[body]; - break; // string defaulting to html case 'string': if (!this.get('Content-Type')) { @@ -118,6 +120,7 @@ res.send = function(body){ } break; case 'boolean': + case 'number': case 'object': if (null == body) { body = ''; diff --git a/test/res.send.js b/test/res.send.js index ec9919f2c28..a73353c84b2 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -77,6 +77,21 @@ describe('res', function(){ }) }) + describe('.send(code, number)', function(){ + it('should send number as json', function(done){ + var app = express(); + + app.use(function(req, res){ + res.send(200, 0.123); + }); + + request(app) + .get('/') + .expect('Content-Type', 'application/json; charset=utf-8') + .expect(200, '0.123', done); + }) + }) + describe('.send(String)', function(){ it('should send as html', function(done){ var app = express(); From 5d03d0eac8cb64a24caba2b60b157263e21f6fdf Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 01:15:40 -0400 Subject: [PATCH 0386/1265] Deprecate res.redirect(url, status) --- History.md | 1 + lib/response.js | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index a94295825ca..fdd95b55188 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead * fix `res.send(status, num)` to send `num` as json (not error) * deps: basic-auth@1.0.0 - support empty password diff --git a/lib/response.js b/lib/response.js index ebdb1a8f924..db8c85db204 100644 --- a/lib/response.js +++ b/lib/response.js @@ -707,11 +707,8 @@ res.location = function(url){ * res.redirect('/foo/bar'); * res.redirect('http://example.com'); * res.redirect(301, 'http://example.com'); - * res.redirect('http://example.com', 301); * res.redirect('../login'); // /blog/post/1 -> /blog/login * - * @param {String} url - * @param {Number} code * @api public */ @@ -726,6 +723,7 @@ res.redirect = function(url){ status = url; url = arguments[1]; } else { + deprecate('res.redirect(ur, status): Use res.redirect(status, url) instead'); status = arguments[1]; } } From f684a64df71a08c0caf2371aa305411df690a10f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 00:05:33 -0400 Subject: [PATCH 0387/1265] Add explicit "Rosetta Flash JSONP abuse" protection --- History.md | 2 ++ lib/response.js | 15 ++++++++--- test/res.jsonp.js | 65 ++++++++++++++++++++++++----------------------- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/History.md b/History.md index fdd95b55188..9a99efda53b 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ 3.x === + * add explicit "Rosetta Flash JSONP abuse" protection + - previous versions are not vulnerable; this is just explicit protection * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead * fix `res.send(status, num)` to send `num` as json (not error) * deps: basic-auth@1.0.0 diff --git a/lib/response.js b/lib/response.js index db8c85db204..345597b80f2 100644 --- a/lib/response.js +++ b/lib/response.js @@ -266,8 +266,11 @@ res.jsonp = function(obj){ var callback = this.req.query[app.get('jsonp callback name')]; // content-type - this.charset = this.charset || 'utf-8'; - this.get('Content-Type') || this.set('Content-Type', 'application/json'); + if (!this.get('Content-Type')) { + this.charset = 'utf-8'; + this.set('X-Content-Type-Options', 'nosniff'); + this.set('Content-Type', 'application/json'); + } // fixup callback if (Array.isArray(callback)) { @@ -275,10 +278,14 @@ res.jsonp = function(obj){ } // jsonp - if (callback && 'string' === typeof callback) { + if (typeof callback === 'string' && callback.length !== 0) { + this.charset = 'utf-8'; + this.set('X-Content-Type-Options', 'nosniff'); this.set('Content-Type', 'text/javascript'); var cb = callback.replace(/[^\[\]\w$.]/g, ''); - body = 'typeof ' + cb + ' === \'function\' && ' + cb + '(' + body + ');'; + + // the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse" + body = '/**/ typeof ' + cb + ' === \'function\' && ' + cb + '(' + body + ');'; } return this.send(body); diff --git a/test/res.jsonp.js b/test/res.jsonp.js index 3637a23ed52..45acb906422 100644 --- a/test/res.jsonp.js +++ b/test/res.jsonp.js @@ -14,11 +14,8 @@ describe('res', function(){ request(app) .get('/?callback=something') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8'); - res.text.should.equal('typeof something === \'function\' && something({"count":1});'); - done(); - }) + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect(200, /something\(\{"count":1\}\);/, done); }) it('should use first callback parameter with jsonp', function(done){ @@ -29,12 +26,9 @@ describe('res', function(){ }); request(app) - .get('/?callback=something&callback=somethingelse') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8'); - res.text.should.equal('typeof something === \'function\' && something({"count":1});'); - done(); - }) + .get('/?callback=something&callback=somethingelse') + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect(200, /something\(\{"count":1\}\);/, done); }) it('should ignore object callback parameter with jsonp', function(done){ @@ -61,11 +55,8 @@ describe('res', function(){ request(app) .get('/?clb=something') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8'); - res.text.should.equal('typeof something === \'function\' && something({"count":1});'); - done(); - }) + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect(200, /something\(\{"count":1\}\);/, done); }) it('should allow []', function(done){ @@ -77,11 +68,8 @@ describe('res', function(){ request(app) .get('/?callback=callbacks[123]') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8'); - res.text.should.equal('typeof callbacks[123] === \'function\' && callbacks[123]({"count":1});'); - done(); - }) + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect(200, /callbacks\[123\]\(\{"count":1\}\);/, done); }) it('should disallow arbitrary js', function(done){ @@ -93,11 +81,8 @@ describe('res', function(){ request(app) .get('/?callback=foo;bar()') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8'); - res.text.should.equal('typeof foobar === \'function\' && foobar({});'); - done(); - }) + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect(200, /foobar\(\{\}\);/, done); }) it('should escape utf whitespace', function(done){ @@ -109,13 +94,24 @@ describe('res', function(){ request(app) .get('/?callback=foo') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8'); - res.text.should.equal('typeof foo === \'function\' && foo({"str":"\\u2028 \\u2029 woot"});'); - done(); - }); + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect(200, /foo\(\{"str":"\\u2028 \\u2029 woot"\}\);/, done); }); + it('should include security header and prologue', function (done) { + var app = express(); + + app.use(function(req, res){ + res.jsonp({ count: 1 }); + }); + + request(app) + .get('/?callback=something') + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect('X-Content-Type-Options', 'nosniff') + .expect(200, /^\/\*\*\//, done); + }) + it('should not override previous Content-Types with no callback', function(done){ var app = express(); @@ -127,7 +123,11 @@ describe('res', function(){ request(app) .get('/') .expect('Content-Type', 'application/vnd.example+json; charset=utf-8') - .expect(200, '{"hello":"world"}', done); + .expect(200, '{"hello":"world"}', function (err, res) { + if (err) return done(err); + res.headers.should.not.have.property('x-content-type-options'); + done(); + }); }) it('should override previous Content-Types with callback', function(done){ @@ -141,6 +141,7 @@ describe('res', function(){ request(app) .get('/?callback=cb') .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect('X-Content-Type-Options', 'nosniff') .expect(200, /cb\(\{"hello":"world"\}\);$/, done); }) From b2382a73365ecf1d411b7bf57e589bc6ccc073c7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 00:20:11 -0400 Subject: [PATCH 0388/1265] Remove unnecessary escaping in res.jsonp --- History.md | 1 + lib/response.js | 16 +++++++++++----- test/res.jsonp.js | 13 +++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index 9a99efda53b..bc318420cd1 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ - previous versions are not vulnerable; this is just explicit protection * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead * fix `res.send(status, num)` to send `num` as json (not error) + * remove unnecessary escaping when `res.jsonp` returns JSON response * deps: basic-auth@1.0.0 - support empty password - support empty username diff --git a/lib/response.js b/lib/response.js index 345597b80f2..2e4b35cb747 100644 --- a/lib/response.js +++ b/lib/response.js @@ -260,9 +260,7 @@ res.jsonp = function(obj){ var app = this.app; var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = JSON.stringify(obj, replacer, spaces) - .replace(/\u2028/g, '\\u2028') - .replace(/\u2029/g, '\\u2029'); + var body = JSON.stringify(obj, replacer, spaces); var callback = this.req.query[app.get('jsonp callback name')]; // content-type @@ -282,10 +280,18 @@ res.jsonp = function(obj){ this.charset = 'utf-8'; this.set('X-Content-Type-Options', 'nosniff'); this.set('Content-Type', 'text/javascript'); - var cb = callback.replace(/[^\[\]\w$.]/g, ''); + + // restrict callback charset + callback = callback.replace(/[^\[\]\w$.]/g, ''); + + // replace chars not allowed in JavaScript that are in JSON + body = body + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029'); // the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse" - body = '/**/ typeof ' + cb + ' === \'function\' && ' + cb + '(' + body + ');'; + // the typeof check is just to reduce client error noise + body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');'; } return this.send(body); diff --git a/test/res.jsonp.js b/test/res.jsonp.js index 45acb906422..2c5e245fbc0 100644 --- a/test/res.jsonp.js +++ b/test/res.jsonp.js @@ -98,6 +98,19 @@ describe('res', function(){ .expect(200, /foo\(\{"str":"\\u2028 \\u2029 woot"\}\);/, done); }); + it('should not escape utf whitespace for json fallback', function(done){ + var app = express(); + + app.use(function(req, res){ + res.jsonp({ str: '\u2028 \u2029 woot' }); + }); + + request(app) + .get('/') + .expect('Content-Type', 'application/json; charset=utf-8') + .expect(200, '{"str":"\u2028 \u2029 woot"}', done); + }); + it('should include security header and prologue', function (done) { var app = express(); From ec5b9f5c618d4f73fb3c211ed1936c89911acca3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 09:35:20 -0400 Subject: [PATCH 0389/1265] tests: add test for error handler in route closes #2228 --- test/app.router.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/app.router.js b/test/app.router.js index b7422b5664f..c0e13fdb75c 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -836,6 +836,32 @@ describe('app.router', function(){ done(); }) }) + + it('should call handler in same route, if exists', function(done){ + var app = express(); + + function fn1(req, res, next) { + next(new Error('boom!')); + } + + function fn2(req, res, next) { + res.send('foo here'); + } + + function fn3(err, req, res, next) { + res.send('route go ' + err.message); + } + + app.get('/foo', fn1, fn2, fn3); + + app.use(function (err, req, res, next) { + res.end('error!'); + }) + + request(app) + .get('/foo') + .expect('route go boom!', done) + }) }) it('should allow rewriting of the url', function(done){ From 916c53737d97b605385f9b5235a3a890f864c6bb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 13:11:31 -0400 Subject: [PATCH 0390/1265] 3.14.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index bc318420cd1..7bd01d44c65 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.14.0 / 2014-07-11 +=================== * add explicit "Rosetta Flash JSONP abuse" protection - previous versions are not vulnerable; this is just explicit protection diff --git a/package.json b/package.json index 3d66e6ec909..12780bd7552 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.13.0", + "version": "3.14.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 1c3bd36be62c16dc1792a6f38bcf12e7f582f74f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 5 Jul 2014 13:23:07 -0400 Subject: [PATCH 0391/1265] Support non-string path in app.use(path, fn) fixes #2207 --- History.md | 4 ++++ lib/application.js | 15 +++++++++------ lib/router/index.js | 21 ++++++++------------- package.json | 4 ++-- test/app.use.js | 46 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 21 deletions(-) diff --git a/History.md b/History.md index 2ce2b03eefb..fcbbc65dddc 100644 --- a/History.md +++ b/History.md @@ -6,12 +6,16 @@ unreleased * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead * fix `res.send(status, num)` to send `num` as json (not error) * remove unnecessary escaping when `res.jsonp` returns JSON response + * support non-string `path` in `app.use(path, fn)` + - supports array of paths + - supports `RegExp` * deps: debug@1.0.3 - Add support for multiple wildcards in namespaces * deps: methods@1.1.0 - add `CONNECT` * deps: parseurl@~1.1.3 - faster parsing of href-only URLs + * deps: path-to-regexp@0.1.3 4.5.1 / 2014-07-06 ================== diff --git a/lib/application.js b/lib/application.js index c755b1da8a9..5c11196ee25 100644 --- a/lib/application.js +++ b/lib/application.js @@ -147,19 +147,22 @@ app.handle = function(req, res, done) { * @api public */ -app.use = function(route, fn){ +app.use = function use(path, fn){ var mount_app; - // default route to '/' - if ('string' != typeof route) fn = route, route = '/'; + // default path to '/' + if (arguments.length < 2) { + fn = path; + path = '/'; + } // express app if (fn.handle && fn.set) mount_app = fn; // restore .app property on req and res if (mount_app) { - debug('.use app under %s', route); - mount_app.mountpath = route; + debug('.use app under %s', path); + mount_app.mountpath = path; fn = function(req, res, next) { var orig = req.app; mount_app.handle(req, res, function(err) { @@ -171,7 +174,7 @@ app.use = function(route, fn){ } this.lazyrouter(); - this._router.use(route, fn); + this._router.use(path, fn); // mounted an app if (mount_app) { diff --git a/lib/router/index.js b/lib/router/index.js index c08b39cd935..b0fe5428e1c 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -385,11 +385,11 @@ proto.process_params = function(layer, called, req, res, done) { * @api public */ -proto.use = function(route, fn){ - // default route to '/' - if ('string' != typeof route) { - fn = route; - route = '/'; +proto.use = function(path, fn){ + // default path to '/' + if (arguments.length < 2) { + fn = path; + path = '/'; } if (typeof fn !== 'function') { @@ -398,19 +398,14 @@ proto.use = function(route, fn){ throw new Error(msg); } - // strip trailing slash - if ('/' == route[route.length - 1]) { - route = route.slice(0, -1); - } - - var layer = new Layer(route, { + var layer = new Layer(path, { sensitive: this.caseSensitive, - strict: this.strict, + strict: false, end: false }, fn); // add the middleware - debug('use %s %s', route || '/', fn.name || 'anonymous'); + debug('use %s %s', path || '/', fn.name || 'anonymous'); this.stack.push(layer); return this; diff --git a/package.json b/package.json index e5d1ac2afb2..3067eec54f5 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "media-typer": "0.2.0", "methods": "1.1.0", "parseurl": "~1.1.3", + "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.5.0", @@ -44,9 +45,8 @@ "fresh": "0.2.2", "cookie-signature": "1.0.4", "merge-descriptors": "0.0.2", - "utils-merge": "1.0.0", "qs": "0.6.6", - "path-to-regexp": "0.1.2" + "utils-merge": "1.0.0" }, "devDependencies": { "after": "0.8.1", diff --git a/test/app.use.js b/test/app.use.js index dda16f4dd22..7ef6896c799 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -163,5 +163,51 @@ describe('app', function(){ .post('/foo/bar') .expect(200, 'saw POST /bar', cb); }) + + it('should support array of paths', function (done) { + var app = express(); + var cb = after(3, done); + + app.use(['/foo/', '/bar'], function (req, res) { + res.send('saw ' + req.method + ' ' + req.url + ' through ' + req.originalUrl); + }); + + request(app) + .get('/') + .expect(404, cb); + + request(app) + .get('/foo') + .expect(200, 'saw GET / through /foo', cb); + + request(app) + .get('/bar') + .expect(200, 'saw GET / through /bar', cb); + }) + + it('should support regexp path', function (done) { + var app = express(); + var cb = after(4, done); + + app.use(/^\/[a-z]oo/, function (req, res) { + res.send('saw ' + req.method + ' ' + req.url + ' through ' + req.originalUrl); + }); + + request(app) + .get('/') + .expect(404, cb); + + request(app) + .get('/foo') + .expect(200, 'saw GET / through /foo', cb); + + request(app) + .get('/zoo/bear') + .expect(200, 'saw GET /bear through /zoo/bear', cb); + + request(app) + .get('/get/zoo') + .expect(404, cb); + }) }) }) From 996d31926354d8c73d2ce314c0595367f8305451 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 7 Jul 2014 22:50:05 -0400 Subject: [PATCH 0392/1265] router: fix optimization on router exit --- History.md | 1 + lib/router/index.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index fcbbc65dddc..fc04680449a 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,7 @@ unreleased * support non-string `path` in `app.use(path, fn)` - supports array of paths - supports `RegExp` + * router: fix optimization on router exit * deps: debug@1.0.3 - Add support for multiple wildcards in namespaces * deps: methods@1.1.0 diff --git a/lib/router/index.js b/lib/router/index.js index b0fe5428e1c..c88ce9310c9 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -443,7 +443,7 @@ proto.route = function(path){ methods.concat('all').forEach(function(method){ proto[method] = function(path){ var route = this.route(path) - route[method].apply(route, [].slice.call(arguments, 1)); + route[method].apply(route, slice.call(arguments, 1)); return this; }; }); @@ -506,8 +506,14 @@ function restore(fn, obj) { // wrap a function function wrap(old, fn) { - return function () { - var args = [old].concat(slice.call(arguments)); + return function proxy() { + var args = new Array(arguments.length + 1); + + args[0] = old; + for (var i = 0, len = arguments.length; i < len; i++) { + args[i + 1] = arguments[i]; + } + fn.apply(this, args); }; } From 8dc67af6060a145f861f5300c4a3b52fc2bf76a6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 8 Jul 2014 00:16:39 -0400 Subject: [PATCH 0393/1265] router: speed up standard app.use(fn) --- History.md | 1 + lib/router/index.js | 46 ++++++++++++++++++---------------- lib/router/layer.js | 37 +++++++++++++++++++++------ lib/router/match.js | 61 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 30 deletions(-) create mode 100644 lib/router/match.js diff --git a/History.md b/History.md index fc04680449a..beeab59be04 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,7 @@ unreleased - supports array of paths - supports `RegExp` * router: fix optimization on router exit + * router: speed up standard `app.use(fn)` * deps: debug@1.0.3 - Add support for multiple wildcards in namespaces * deps: methods@1.1.0 diff --git a/lib/router/index.js b/lib/router/index.js index c88ce9310c9..81f712ea36c 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -149,6 +149,10 @@ proto.handle = function(req, res, done) { }); } + // setup basic req values + req.baseUrl = parentUrl; + req.originalUrl = req.originalUrl || req.url; + next(); function next(err) { @@ -159,23 +163,23 @@ proto.handle = function(req, res, done) { var layer = stack[idx++]; var layerPath; - if (!layer) { - return done(err); - } - if (slashAdded) { req.url = req.url.substr(1); slashAdded = false; } - req.baseUrl = parentUrl; - req.url = protohost + removed + req.url.substr(protohost.length); - req.originalUrl = req.originalUrl || req.url; - removed = ''; + if (removed.length !== 0) { + req.baseUrl = parentUrl; + req.url = protohost + removed + req.url.substr(protohost.length); + removed = ''; + } + + if (!layer) { + return done(err); + } try { var path = parseUrl(req).pathname; - if (undefined == path) path = '/'; if (!layer.match(path)) return next(err); @@ -235,23 +239,21 @@ proto.handle = function(req, res, done) { // Trim off the part of the url that matches the route // middleware (.use stuff) needs to have the path stripped - removed = layerPath; - if (removed.length) { + if (layerPath.length !== 0) { debug('trim prefix (%s) from url %s', layerPath, req.url); + removed = layerPath; req.url = protohost + req.url.substr(protohost.length + removed.length); - } - // Ensure leading slash - if (!fqdn && req.url[0] !== '/') { - req.url = '/' + req.url; - slashAdded = true; - } + // Ensure leading slash + if (!fqdn && req.url[0] !== '/') { + req.url = '/' + req.url; + slashAdded = true; + } - // Setup base URL (no trailing slash) - if (removed.length && removed.substr(-1) === '/') { - req.baseUrl = parentUrl + removed.substring(0, removed.length - 1); - } else { - req.baseUrl = parentUrl + removed; + // Setup base URL (no trailing slash) + req.baseUrl = parentUrl + (removed[removed.length - 1] === '/' + ? removed.substring(0, removed.length - 1) + : removed); } debug('%s %s : %s', layer.handle.name || 'anonymous', layerPath, req.originalUrl); diff --git a/lib/router/layer.js b/lib/router/layer.js index 80625fb4e16..4d02ee076ac 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -18,8 +18,15 @@ function Layer(path, options, fn) { debug('new %s', path); options = options || {}; - this.regexp = pathRegexp(path, this.keys = [], options); + this.handle = fn; + this.params = undefined; + this.path = undefined; + this.regexp = pathRegexp(path, this.keys = [], options); + + if (path === '/' && options.end === false) { + this.regexp.fast_slash = true; + } } /** @@ -31,18 +38,32 @@ function Layer(path, options, fn) { * @api private */ -Layer.prototype.match = function(path){ - var keys = this.keys; - var params = this.params = {}; +Layer.prototype.match = function match(path) { + if (this.regexp.fast_slash) { + // fast path non-ending match for / (everything matches) + this.params = {}; + this.path = ''; + return true; + } + var m = this.regexp.exec(path); - var n = 0; - var key; - var val; - if (!m) return false; + if (!m) { + this.params = undefined; + this.path = undefined; + return false; + } + // store values + this.params = {}; this.path = m[0]; + var keys = this.keys; + var params = this.params; + var n = 0; + var key; + var val; + for (var i = 1, len = m.length; i < len; ++i) { key = keys[i - 1]; val = decode_param(m[i]); diff --git a/lib/router/match.js b/lib/router/match.js new file mode 100644 index 00000000000..ce308c41486 --- /dev/null +++ b/lib/router/match.js @@ -0,0 +1,61 @@ +/** + * Module dependencies. + */ + +var pathRegexp = require('path-to-regexp'); + +/** + * Expose `Layer`. + */ + +module.exports = Match; + +function Match(layer, path, params) { + this.layer = layer; + this.params = {}; + this.path = path || ''; + + if (!params) { + return this; + } + + var keys = layer.keys; + var n = 0; + var prop; + var key; + var val; + + for (var i = 0; i < params.length; i++) { + key = keys[i]; + val = decode_param(params[i]); + prop = key + ? key.name + : n++; + + this.params[prop] = val; + } + + return this; +}; + +/** + * Decode param value. + * + * @param {string} val + * @return {string} + * @api private + */ + +function decode_param(val){ + if (typeof val !== 'string') { + return val; + } + + try { + return decodeURIComponent(val); + } catch (e) { + var err = new TypeError("Failed to decode param '" + val + "'"); + err.status = 400; + throw err; + } +} From 76e8bfa1dcb7b29389c55d55d2072491edbccd91 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 8 Jul 2014 01:50:57 -0400 Subject: [PATCH 0394/1265] router: refactor location of try blocks --- History.md | 1 + lib/router/index.js | 119 +++++++++++++++++++++++++------------------- lib/router/layer.js | 50 +++++++++++++++++++ lib/router/route.js | 48 +++++++----------- 4 files changed, 136 insertions(+), 82 deletions(-) diff --git a/History.md b/History.md index beeab59be04..294ca2d823e 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,7 @@ unreleased - supports array of paths - supports `RegExp` * router: fix optimization on router exit + * router: refactor location of `try` blocks * router: speed up standard `app.use(fn)` * deps: debug@1.0.3 - Add support for multiple wildcards in namespaces diff --git a/lib/router/index.js b/lib/router/index.js index 81f712ea36c..b1496c7f28e 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -156,12 +156,11 @@ proto.handle = function(req, res, done) { next(); function next(err) { - if (err === 'route') { - err = undefined; - } + var layerError = err === 'route' + ? null + : err; var layer = stack[idx++]; - var layerPath; if (slashAdded) { req.url = req.url.substr(1); @@ -175,13 +174,13 @@ proto.handle = function(req, res, done) { } if (!layer) { - return done(err); + return done(layerError); } - try { - var path = parseUrl(req).pathname; - - if (!layer.match(path)) return next(err); + self.match_layer(layer, req, res, function (err, path) { + if (err || path === undefined) { + return next(layerError || err); + } // route object and not middleware var route = layer.route; @@ -189,8 +188,8 @@ proto.handle = function(req, res, done) { // if final route, then we support options if (route) { // we don't run any routes with error first - if (err) { - return next(err); + if (layerError) { + return next(layerError); } var method = req.method; @@ -214,63 +213,77 @@ proto.handle = function(req, res, done) { req.params = self.mergeParams ? mergeParams(layer.params, parentParams) : layer.params; - layerPath = layer.path; + var layerPath = layer.path; // this should be done for the layer - return self.process_params(layer, paramcalled, req, res, function(err) { + self.process_params(layer, paramcalled, req, res, function (err) { if (err) { - return next(err); + return next(layerError || err); } if (route) { - return layer.handle(req, res, next); + return layer.handle_request(req, res, next); } - trim_prefix(); + trim_prefix(layer, layerError, layerPath, path); }); + }); + } - } catch (err) { - next(err); + function trim_prefix(layer, layerError, layerPath, path) { + var c = path[layerPath.length]; + if (c && '/' !== c && '.' !== c) return next(layerError); + + // Trim off the part of the url that matches the route + // middleware (.use stuff) needs to have the path stripped + if (layerPath.length !== 0) { + debug('trim prefix (%s) from url %s', layerPath, req.url); + removed = layerPath; + req.url = protohost + req.url.substr(protohost.length + removed.length); + + // Ensure leading slash + if (!fqdn && req.url[0] !== '/') { + req.url = '/' + req.url; + slashAdded = true; + } + + // Setup base URL (no trailing slash) + req.baseUrl = parentUrl + (removed[removed.length - 1] === '/' + ? removed.substring(0, removed.length - 1) + : removed); } - function trim_prefix() { - var c = path[layerPath.length]; - if (c && '/' != c && '.' != c) return next(err); - - // Trim off the part of the url that matches the route - // middleware (.use stuff) needs to have the path stripped - if (layerPath.length !== 0) { - debug('trim prefix (%s) from url %s', layerPath, req.url); - removed = layerPath; - req.url = protohost + req.url.substr(protohost.length + removed.length); - - // Ensure leading slash - if (!fqdn && req.url[0] !== '/') { - req.url = '/' + req.url; - slashAdded = true; - } + debug('%s %s : %s', layer.name, layerPath, req.originalUrl); - // Setup base URL (no trailing slash) - req.baseUrl = parentUrl + (removed[removed.length - 1] === '/' - ? removed.substring(0, removed.length - 1) - : removed); - } + if (layerError) { + layer.handle_error(layerError, req, res, next); + } else { + layer.handle_request(req, res, next); + } + } +}; - debug('%s %s : %s', layer.handle.name || 'anonymous', layerPath, req.originalUrl); - var arity = layer.handle.length; - try { - if (err && arity === 4) { - layer.handle(err, req, res, next); - } else if (!err && arity < 4) { - layer.handle(req, res, next); - } else { - next(err); - } - } catch (err) { - next(err); - } +/** + * Match request to a layer. + * + * @api private + */ + +proto.match_layer = function match_layer(layer, req, res, done) { + var error = null; + var path; + + try { + path = parseUrl(req).pathname; + + if (!layer.match(path)) { + path = undefined; } + } catch (err) { + error = err; } + + done(error, path); }; /** @@ -406,6 +419,8 @@ proto.use = function(path, fn){ end: false }, fn); + layer.route = undefined; + // add the middleware debug('use %s %s', path || '/', fn.name || 'anonymous'); diff --git a/lib/router/layer.js b/lib/router/layer.js index 4d02ee076ac..e292a13a895 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -20,6 +20,7 @@ function Layer(path, options, fn) { options = options || {}; this.handle = fn; + this.name = fn.name || ''; this.params = undefined; this.path = undefined; this.regexp = pathRegexp(path, this.keys = [], options); @@ -29,6 +30,55 @@ function Layer(path, options, fn) { } } +/** + * Handle the error for the layer. + * + * @param {Error} error + * @param {Request} req + * @param {Response} res + * @param {function} next + * @api private + */ + +Layer.prototype.handle_error = function handle_error(error, req, res, next) { + var fn = this.handle; + + if (fn.length !== 4) { + // not a standard error handler + return next(error); + } + + try { + fn(error, req, res, next); + } catch (err) { + next(err); + } +}; + +/** + * Handle the request for the layer. + * + * @param {Request} req + * @param {Response} res + * @param {function} next + * @api private + */ + +Layer.prototype.handle_request = function handle(req, res, next) { + var fn = this.handle; + + if (fn.length > 3) { + // not a standard request handler + return next(); + } + + try { + fn(req, res, next); + } catch (err) { + next(err); + } +}; + /** * Check if this route matches `path`, if so * populate `.params`. diff --git a/lib/router/route.js b/lib/router/route.js index e9cf1a95abd..6b39211921a 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -3,6 +3,7 @@ */ var debug = require('debug')('express:router:route'); +var Layer = require('./layer'); var methods = require('methods'); var utils = require('../utils'); @@ -64,6 +65,7 @@ Route.prototype._options = function(){ */ Route.prototype.dispatch = function(req, res, done){ + var idx = 0; var stack = this.stack; if (stack.length === 0) { return done(); @@ -76,8 +78,9 @@ Route.prototype.dispatch = function(req, res, done){ req.route = this; - var idx = 0; - (function next_layer(err) { + next(); + + function next(err) { if (err && err === 'route') { return done(); } @@ -88,33 +91,15 @@ Route.prototype.dispatch = function(req, res, done){ } if (layer.method && layer.method !== method) { - return next_layer(err); + return next(err); } - var arity = layer.handle.length; if (err) { - if (arity < 4) { - return next_layer(err); - } - - try { - layer.handle(err, req, res, next_layer); - } catch (err) { - next_layer(err); - } - return; + layer.handle_error(err, req, res, next); + } else { + layer.handle_request(req, res, next); } - - if (arity > 3) { - return next_layer(); - } - - try { - layer.handle(req, res, next_layer); - } catch (err) { - next_layer(err); - } - })(); + } }; /** @@ -155,8 +140,11 @@ Route.prototype.all = function(){ throw new Error(msg); } + var layer = Layer('/', {}, fn); + layer.method = undefined; + self.methods._all = true; - self.stack.push({ handle: fn }); + self.stack.push(layer); }); return self; @@ -176,11 +164,11 @@ methods.forEach(function(method){ debug('%s %s', method, self.path); - if (!self.methods[method]) { - self.methods[method] = true; - } + var layer = Layer('/', {}, fn); + layer.method = method; - self.stack.push({ method: method, handle: fn }); + self.methods[method] = true; + self.stack.push(layer); }); return self; }; From a01326adac588006a823746238ca90ade63e4580 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 8 Jul 2014 01:15:31 -0400 Subject: [PATCH 0395/1265] Catch errors in multiple req.param(name, fn) handlers --- History.md | 1 + lib/router/index.js | 12 ++++++------ test/app.param.js | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index 294ca2d823e..ebd34a5beb1 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ unreleased * add explicit "Rosetta Flash JSONP abuse" protection - previous versions are not vulnerable; this is just explicit protection + * catch errors in multiple `req.param(name, fn)` handlers * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead * fix `res.send(status, num)` to send `num` as json (not error) * remove unnecessary escaping when `res.jsonp` returns JSON response diff --git a/lib/router/index.js b/lib/router/index.js index b1496c7f28e..4b6f39af220 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -353,11 +353,7 @@ proto.process_params = function(layer, called, req, res, done) { value: paramVal }; - try { - return paramCallback(); - } catch (err) { - return done(err); - } + paramCallback(); } // single param callbacks @@ -376,7 +372,11 @@ proto.process_params = function(layer, called, req, res, done) { if (!fn) return param(); - fn(req, res, paramCallback, paramVal, key.name); + try { + fn(req, res, paramCallback, paramVal, key.name); + } catch (e) { + paramCallback(e); + } } param(); diff --git a/test/app.param.js b/test/app.param.js index cd5bc9b298b..858ea2d5f6a 100644 --- a/test/app.param.js +++ b/test/app.param.js @@ -237,6 +237,27 @@ describe('app', function(){ .expect(500, done); }) + it('should catch thrown secondary error', function(done){ + var app = express(); + + app.param('id', function(req, res, next, val){ + process.nextTick(next); + }); + + app.param('id', function(req, res, next, id){ + throw new Error('err!'); + }); + + app.get('/user/:id', function(req, res){ + var id = req.params.id; + res.send('' + id); + }); + + request(app) + .get('/user/123') + .expect(500, done); + }) + it('should defer to next route', function(done){ var app = express(); From 997a558a73eb49d7f3b99ceec82c4c88bd3424a0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 9 Jul 2014 20:04:24 -0400 Subject: [PATCH 0396/1265] Accept multiple callbacks to app.use() fixes #2224 --- History.md | 1 + lib/application.js | 48 ++++++++++++++++++++++---------------- lib/router/index.js | 52 +++++++++++++++++++++++++---------------- test/app.use.js | 56 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 115 insertions(+), 42 deletions(-) diff --git a/History.md b/History.md index ebd34a5beb1..3e6ca2136b9 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * accept multiple callbacks to `app.use()` * add explicit "Rosetta Flash JSONP abuse" protection - previous versions are not vulnerable; this is just explicit protection * catch errors in multiple `req.param(name, fn)` handlers diff --git a/lib/application.js b/lib/application.js index 5c11196ee25..352d57e3041 100644 --- a/lib/application.js +++ b/lib/application.js @@ -147,41 +147,49 @@ app.handle = function(req, res, done) { * @api public */ -app.use = function use(path, fn){ +app.use = function use(path, fn) { var mount_app; - - // default path to '/' - if (arguments.length < 2) { - fn = path; - path = '/'; + var mount_path; + + // check for .use(path, app) or .use(app) signature + if (arguments.length <= 2) { + mount_path = typeof path === 'string' + ? path + : '/'; + mount_app = typeof path === 'function' + ? path + : fn; } - // express app - if (fn.handle && fn.set) mount_app = fn; + // setup router + this.lazyrouter(); + var router = this._router; - // restore .app property on req and res - if (mount_app) { - debug('.use app under %s', path); + // express app + if (mount_app && mount_app.handle && mount_app.set) { + debug('.use app under %s', mount_path); mount_app.mountpath = path; - fn = function(req, res, next) { + mount_app.parent = this; + + // restore .app property on req and res + router.use(mount_path, function mounted_app(req, res, next) { var orig = req.app; mount_app.handle(req, res, function(err) { req.__proto__ = orig.request; res.__proto__ = orig.response; next(err); }); - }; - } - - this.lazyrouter(); - this._router.use(path, fn); + }); - // mounted an app - if (mount_app) { - mount_app.parent = this; + // mounted an app mount_app.emit('mount', this); + + return this; } + // pass-through use + router.use.apply(router, arguments); + return this; }; diff --git a/lib/router/index.js b/lib/router/index.js index 4b6f39af220..4e63eb1060f 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -9,6 +9,8 @@ var mixin = require('utils-merge'); var debug = require('debug')('express:router'); var parseUrl = require('parseurl'); var slice = Array.prototype.slice; +var toString = Object.prototype.toString; +var utils = require('../utils'); /** * Initialize a new `Router` with the given `options`. @@ -394,37 +396,47 @@ proto.process_params = function(layer, called, req, res, done) { * handlers can operate without any code changes regardless of the "prefix" * pathname. * - * @param {String|Function} route - * @param {Function} fn - * @return {app} for chaining * @api public */ -proto.use = function(path, fn){ +proto.use = function use(fn) { + var offset = 0; + var path = '/'; + var self = this; + // default path to '/' - if (arguments.length < 2) { - fn = path; - path = '/'; + if (typeof fn !== 'function') { + offset = 1; + path = fn; } - if (typeof fn !== 'function') { - var type = {}.toString.call(fn); - var msg = 'Router.use() requires callback functions but got a ' + type; - throw new Error(msg); + var callbacks = utils.flatten(slice.call(arguments, offset)); + + if (callbacks.length === 0) { + throw new TypeError('Router.use() requires callback function'); } - var layer = new Layer(path, { - sensitive: this.caseSensitive, - strict: false, - end: false - }, fn); + callbacks.forEach(function (fn) { + if (typeof fn !== 'function') { + var type = toString.call(fn); + var msg = 'Router.use() requires callback function but got a ' + type; + throw new TypeError(msg); + } - layer.route = undefined; + // add the middleware + debug('use %s %s', path, fn.name || ''); - // add the middleware - debug('use %s %s', path || '/', fn.name || 'anonymous'); + var layer = new Layer(path, { + sensitive: self.caseSensitive, + strict: false, + end: false + }, fn); + + layer.route = undefined; + + self.stack.push(layer); + }); - this.stack.push(layer); return this; }; diff --git a/test/app.use.js b/test/app.use.js index 7ef6896c799..681a6a911de 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -16,9 +16,9 @@ describe('app', function(){ app.use(blog); }) - it('should reject numbers', function(){ + it('should reject missing functions', function(){ var app = express(); - app.use.bind(app, 3).should.throw(/Number/); + app.use.bind(app, 3).should.throw(/requires callback function/); }) describe('.use(app)', function(){ @@ -87,6 +87,32 @@ describe('app', function(){ }) describe('.use(middleware)', function(){ + it('should accept multiple arguments', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + app.use(fn1, fn2, function fn3(req, res) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + }); + + request(app) + .get('/') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) + it('should invoke middleware for all requests', function (done) { var app = express(); var cb = after(3, done); @@ -122,6 +148,32 @@ describe('app', function(){ .expect(200, 'saw GET /bar', done); }) + it('should accept multiple arguments', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + app.use('/foo', fn1, fn2, function fn3(req, res) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + }); + + request(app) + .get('/foo') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) + it('should invoke middleware for all requests starting with path', function (done) { var app = express(); var cb = after(3, done); From c6e620302097838e37663e3cb23168b29f641ad0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 10 Jul 2014 01:02:57 -0400 Subject: [PATCH 0397/1265] perf: fix arguments reassign deopt in some res methods --- History.md | 1 + lib/response.js | 133 ++++++++++++++++++++++++++++-------------------- 2 files changed, 79 insertions(+), 55 deletions(-) diff --git a/History.md b/History.md index 3e6ca2136b9..0c3cd8a7c2d 100644 --- a/History.md +++ b/History.md @@ -21,6 +21,7 @@ unreleased * deps: parseurl@~1.1.3 - faster parsing of href-only URLs * deps: path-to-regexp@0.1.3 + * perf: fix arguments reassign deopt in some `res` methods 4.5.1 / 2014-07-06 ================== diff --git a/lib/response.js b/lib/response.js index 7ba47b26aee..4ea938e32df 100644 --- a/lib/response.js +++ b/lib/response.js @@ -78,70 +78,77 @@ res.links = function(links){ * @api public */ -res.send = function(body){ - var req = this.req; - var head = 'HEAD' == req.method; - var type; +res.send = function send(body) { + var chunk = body; var encoding; var len; + var req = this.req; + var type; // settings var app = this.app; // allow status / body - if (2 == arguments.length) { + if (arguments.length === 2) { // res.send(body, status) backwards compat - if ('number' != typeof body && 'number' == typeof arguments[1]) { + if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') { deprecate('res.send(body, status): Use res.send(status, body) instead'); this.statusCode = arguments[1]; } else { - this.statusCode = body; - body = arguments[1]; + this.statusCode = arguments[0]; + chunk = arguments[1]; } } // disambiguate res.send(status) and res.send(status, num) - if (typeof body === 'number' && arguments.length === 1) { + if (typeof chunk === 'number' && arguments.length === 1) { // res.send(status) will set status message as text string - this.get('Content-Type') || this.type('txt'); - this.statusCode = body; - body = http.STATUS_CODES[body]; + if (!this.get('Content-Type')) { + this.type('txt'); + } + + this.statusCode = chunk; + chunk = http.STATUS_CODES[chunk]; } - switch (typeof body) { + switch (typeof chunk) { // string defaulting to html case 'string': - if (!this.get('Content-Type')) this.type('html'); + if (!this.get('Content-Type')) { + this.type('html'); + } break; case 'boolean': case 'number': case 'object': - if (null == body) { - body = ''; - } else if (Buffer.isBuffer(body)) { - this.get('Content-Type') || this.type('bin'); + if (chunk === null) { + chunk = ''; + } else if (Buffer.isBuffer(chunk)) { + if (!this.get('Content-Type')) { + this.type('bin'); + } } else { - return this.json(body); + return this.json(chunk); } break; } // write strings in utf-8 - if ('string' === typeof body) { + if (typeof chunk === 'string') { encoding = 'utf8'; type = this.get('Content-Type'); // reflect this in content-type - if ('string' === typeof type) { + if (typeof type === 'string') { this.set('Content-Type', setCharset(type, 'utf-8')); } } // populate Content-Length - if (undefined !== body && !this.get('Content-Length')) { - len = Buffer.isBuffer(body) - ? body.length - : Buffer.byteLength(body, encoding); + if (chunk !== undefined && !this.get('Content-Length')) { + len = Buffer.isBuffer(chunk) + ? chunk.length + : Buffer.byteLength(chunk, encoding); this.set('Content-Length', len); } @@ -149,7 +156,7 @@ res.send = function(body){ var etag = len !== undefined && app.get('etag fn'); if (etag && ('GET' === req.method || 'HEAD' === req.method)) { if (!this.get('ETag')) { - etag = etag(body, encoding); + etag = etag(chunk, encoding); etag && this.set('ETag', etag); } } @@ -162,11 +169,16 @@ res.send = function(body){ this.removeHeader('Content-Type'); this.removeHeader('Content-Length'); this.removeHeader('Transfer-Encoding'); - body = ''; + chunk = ''; + } + + // skip body for HEAD + if (req.method === 'HEAD') { + this.end(); } // respond - this.end((head ? null : body), encoding); + this.end(chunk, encoding); return this; }; @@ -184,20 +196,22 @@ res.send = function(body){ * @api public */ -res.json = function(obj){ +res.json = function json(obj) { + var val = obj; + // allow status / body - if (2 == arguments.length) { + if (arguments.length === 2) { // res.json(body, status) backwards compat - if ('number' == typeof arguments[1]) { + if (typeof arguments[1] === 'number') { this.statusCode = arguments[1]; - if (typeof obj === 'number') { + if (typeof arguments[0] === 'number') { deprecate('res.json(obj, status): Use res.json(status, obj) instead'); } else { deprecate('res.json(num, status): Use res.status(status).json(num) instead'); } } else { - this.statusCode = obj; - obj = arguments[1]; + this.statusCode = arguments[0]; + val = arguments[1]; } } @@ -205,10 +219,12 @@ res.json = function(obj){ var app = this.app; var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = JSON.stringify(obj, replacer, spaces); + var body = JSON.stringify(val, replacer, spaces); // content-type - this.get('Content-Type') || this.set('Content-Type', 'application/json'); + if (!this.get('Content-Type')) { + this.set('Content-Type', 'application/json'); + } return this.send(body); }; @@ -226,20 +242,22 @@ res.json = function(obj){ * @api public */ -res.jsonp = function(obj){ +res.jsonp = function jsonp(obj) { + var val = obj; + // allow status / body - if (2 == arguments.length) { + if (arguments.length === 2) { // res.json(body, status) backwards compat - if ('number' == typeof arguments[1]) { + if (typeof arguments[1] === 'number') { this.statusCode = arguments[1]; - if (typeof obj === 'number') { + if (typeof arguments[0] === 'number') { deprecate('res.jsonp(obj, status): Use res.jsonp(status, obj) instead'); } else { deprecate('res.jsonp(num, status): Use res.status(status).jsonp(num) instead'); } } else { - this.statusCode = obj; - obj = arguments[1]; + this.statusCode = arguments[0]; + val = arguments[1]; } } @@ -247,7 +265,7 @@ res.jsonp = function(obj){ var app = this.app; var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = JSON.stringify(obj, replacer, spaces); + var body = JSON.stringify(val, replacer, spaces); var callback = this.req.query[app.get('jsonp callback name')]; // content-type @@ -566,8 +584,8 @@ res.attachment = function(filename){ */ res.set = -res.header = function(field, val){ - if (2 == arguments.length) { +res.header = function header(field, val) { + if (arguments.length === 2) { if (Array.isArray(val)) val = val.map(String); else val = String(val); if ('content-type' == field.toLowerCase() && !/;\s*charset\s*=/.test(val)) { @@ -708,16 +726,16 @@ res.location = function(url){ * @api public */ -res.redirect = function(url){ - var head = 'HEAD' == this.req.method; - var status = 302; +res.redirect = function redirect(url) { + var address = url; var body; + var status = 302; // allow status / url - if (2 == arguments.length) { - if ('number' == typeof url) { - status = url; - url = arguments[1]; + if (arguments.length === 2) { + if (typeof arguments[0] === 'number') { + status = arguments[0]; + address = arguments[1]; } else { deprecate('res.redirect(ur, status): Use res.redirect(status, url) instead'); status = arguments[1]; @@ -725,8 +743,8 @@ res.redirect = function(url){ } // Set location header - this.location(url); - url = this.get('Location'); + this.location(address); + address = this.get('Location'); // Support text/{plain,html} by default this.format({ @@ -747,7 +765,12 @@ res.redirect = function(url){ // Respond this.statusCode = status; this.set('Content-Length', Buffer.byteLength(body)); - this.end(head ? null : body); + + if (this.req.method === 'HEAD') { + this.end(); + } + + this.end(body); }; /** From fa6a40526a364a22976bd39cfbe94cc2674e6a7e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 22:46:25 -0400 Subject: [PATCH 0398/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3067eec54f5..2862413bf42 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,8 @@ "hjs": "~0.0.6", "body-parser": "~1.4.3", "cookie-parser": "~1.3.1", - "express-session": "~1.6.1", - "method-override": "2.0.2", + "express-session": "~1.6.5", + "method-override": "~2.1.1", "multiparty": "~3.3.0", "morgan": "1.1.1", "vhost": "2.0.0" From 1623936a258da0b17ff26072705756651e9c15a0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 22:48:42 -0400 Subject: [PATCH 0399/1265] deps: send@0.6.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0c3cd8a7c2d..1aea17c1639 100644 --- a/History.md +++ b/History.md @@ -21,6 +21,8 @@ unreleased * deps: parseurl@~1.1.3 - faster parsing of href-only URLs * deps: path-to-regexp@0.1.3 + * deps: send@0.6.0 + - deps: debug@1.0.3 * perf: fix arguments reassign deopt in some `res` methods 4.5.1 / 2014-07-06 diff --git a/package.json b/package.json index 2862413bf42..567e17c6cbd 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.5.0", + "send": "0.6.0", "serve-static": "~1.3.0", "type-is": "~1.3.2", "vary": "0.1.0", From d29cf4d5e3275fd628c84048f9307bed4cc777ae Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 22:49:49 -0400 Subject: [PATCH 0400/1265] deps: serve-static@~1.3.2 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1aea17c1639..93e5e21c13c 100644 --- a/History.md +++ b/History.md @@ -23,6 +23,9 @@ unreleased * deps: path-to-regexp@0.1.3 * deps: send@0.6.0 - deps: debug@1.0.3 + * deps: serve-static@~1.3.2 + - deps: parseurl@~1.1.3 + - deps: send@0.6.0 * perf: fix arguments reassign deopt in some `res` methods 4.5.1 / 2014-07-06 diff --git a/package.json b/package.json index 567e17c6cbd..976b8d95b63 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.6.0", - "serve-static": "~1.3.0", + "serve-static": "~1.3.2", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 82bdbad5e0a29cd9784f8e121d9209c2ec582c7d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 23:00:09 -0400 Subject: [PATCH 0401/1265] deps: finalhandler@0.0.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 93e5e21c13c..9f492c31d77 100644 --- a/History.md +++ b/History.md @@ -16,6 +16,8 @@ unreleased * router: speed up standard `app.use(fn)` * deps: debug@1.0.3 - Add support for multiple wildcards in namespaces + * deps: finalhandler@0.0.3 + - deps: debug@1.0.3 * deps: methods@1.1.0 - add `CONNECT` * deps: parseurl@~1.1.3 diff --git a/package.json b/package.json index 976b8d95b63..66377f30300 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "debug": "1.0.3", "depd": "0.3.0", "escape-html": "1.0.1", - "finalhandler": "0.0.2", + "finalhandler": "0.0.3", "media-typer": "0.2.0", "methods": "1.1.0", "parseurl": "~1.1.3", From 8ba3f39b33042f59d50ef5b5fb87109d3f3a2a26 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 11 Jul 2014 23:31:30 -0400 Subject: [PATCH 0402/1265] 4.6.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 9f492c31d77..cfc93072f56 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.6.0 / 2014-07-11 +================== * accept multiple callbacks to `app.use()` * add explicit "Rosetta Flash JSONP abuse" protection diff --git a/package.json b/package.json index 66377f30300..1de2b0af42d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.5.1", + "version": "4.6.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 3e32721e24bb0169cbb348ae4654caa90fdfb1c0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 12 Jul 2014 22:07:43 -0400 Subject: [PATCH 0403/1265] Fix subapp.mountpath regression for app.use(subapp) fixes #2233 --- History.md | 5 +++++ lib/application.js | 2 +- test/app.js | 13 ++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index cfc93072f56..b7a26bf42a3 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * fix `subapp.mountpath` regression for `app.use(subapp)` + 4.6.0 / 2014-07-11 ================== diff --git a/lib/application.js b/lib/application.js index 352d57e3041..2ab00b096bb 100644 --- a/lib/application.js +++ b/lib/application.js @@ -168,7 +168,7 @@ app.use = function use(path, fn) { // express app if (mount_app && mount_app.handle && mount_app.set) { debug('.use app under %s', mount_path); - mount_app.mountpath = path; + mount_app.mountpath = mount_path; mount_app.parent = this; // restore .app property on req and res diff --git a/test/app.js b/test/app.js index ec2a341d03a..117f4dffeb5 100644 --- a/test/app.js +++ b/test/app.js @@ -39,16 +39,19 @@ describe('app.parent', function(){ describe('app.mountpath', function(){ it('should return the mounted path', function(){ - var app = express() - , blog = express() - , blogAdmin = express(); + var admin = express(); + var app = express(); + var blog = express(); + var fallback = express(); app.use('/blog', blog); - blog.use('/admin', blogAdmin); + app.use(fallback); + blog.use('/admin', admin); + admin.mountpath.should.equal('/admin'); app.mountpath.should.equal('/'); blog.mountpath.should.equal('/blog'); - blogAdmin.mountpath.should.equal('/admin'); + fallback.mountpath.should.equal('/'); }) }) From 112dbb2ab40a6ecdd7ed0de4503dfc56655a24a3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 12 Jul 2014 22:11:48 -0400 Subject: [PATCH 0404/1265] 4.6.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b7a26bf42a3..3f7b577af49 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.6.1 / 2014-07-12 +================== * fix `subapp.mountpath` regression for `app.use(subapp)` diff --git a/package.json b/package.json index 1de2b0af42d..927ebe2eb68 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.6.0", + "version": "4.6.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From b43205ca98a7f78d802b93cd15bb67a60ae437cc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 12 Jul 2014 00:18:38 -0400 Subject: [PATCH 0405/1265] perf: prevent multiple Buffer creation in res.send --- History.md | 5 +++++ lib/response.js | 23 +++++++++++++++-------- test/res.send.js | 6 ++++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/History.md b/History.md index 3f7b577af49..a576fd6a0b3 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * perf: prevent multiple `Buffer` creation in `res.send` + 4.6.1 / 2014-07-12 ================== diff --git a/lib/response.js b/lib/response.js index 4ea938e32df..155bf3980dc 100644 --- a/lib/response.js +++ b/lib/response.js @@ -145,17 +145,24 @@ res.send = function send(body) { } // populate Content-Length - if (chunk !== undefined && !this.get('Content-Length')) { - len = Buffer.isBuffer(chunk) - ? chunk.length - : Buffer.byteLength(chunk, encoding); + if (chunk !== undefined) { + if (!Buffer.isBuffer(chunk)) { + // convert chunk to Buffer; saves later double conversions + chunk = new Buffer(chunk, encoding); + encoding = undefined; + } + + len = chunk.length; this.set('Content-Length', len); } + // method check + var isHead = req.method === 'HEAD'; + // ETag support - var etag = len !== undefined && app.get('etag fn'); - if (etag && ('GET' === req.method || 'HEAD' === req.method)) { - if (!this.get('ETag')) { + if (len !== undefined && (isHead || req.method === 'GET')) { + var etag = app.get('etag fn'); + if (etag && !this.get('ETag')) { etag = etag(chunk, encoding); etag && this.set('ETag', etag); } @@ -173,7 +180,7 @@ res.send = function send(body) { } // skip body for HEAD - if (req.method === 'HEAD') { + if (isHead) { this.end(); } diff --git a/test/res.send.js b/test/res.send.js index 9ad00b9e8ff..a3d9d2178c5 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -512,8 +512,10 @@ describe('res', function(){ var app = express() app.set('etag', function(body, encoding){ - body.should.equal('hello, world!') - encoding.should.equal('utf8') + var chunk = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body; + chunk.toString().should.equal('hello, world!') return '"custom"' }); From e29fa25bb49c8266041f36ceac90751706225338 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 13 Jul 2014 23:15:00 -0400 Subject: [PATCH 0406/1265] Add configurable query parser closes #2215 --- History.md | 5 +++ lib/application.js | 8 +++- lib/middleware/query.js | 31 +++++-------- lib/utils.js | 48 +++++++++++++++++++++ test/req.query.js | 96 +++++++++++++++++++++++++++++++++-------- 5 files changed, 148 insertions(+), 40 deletions(-) diff --git a/History.md b/History.md index a576fd6a0b3..a0d62026ba6 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,11 @@ unreleased ========== + * configurable query parser with `app.set('query parser', parser)` + - `app.set('query parser', 'extended')` parse with "qs" module + - `app.set('query parser', 'simple')` parse with "querystring" core module + - `app.set('query parser', false)` disable query string parsing + - `app.set('query parser', true)` enable simple parsing * perf: prevent multiple `Buffer` creation in `res.send` 4.6.1 / 2014-07-12 diff --git a/lib/application.js b/lib/application.js index 2ab00b096bb..b8b69c0670b 100644 --- a/lib/application.js +++ b/lib/application.js @@ -12,6 +12,7 @@ var debug = require('debug')('express:application'); var View = require('./view'); var http = require('http'); var compileETag = require('./utils').compileETag; +var compileQueryParser = require('./utils').compileQueryParser; var compileTrust = require('./utils').compileTrust; var deprecate = require('depd')('express'); var resolve = require('path').resolve; @@ -51,6 +52,7 @@ app.defaultConfiguration = function(){ this.set('etag', 'weak'); var env = process.env.NODE_ENV || 'development'; this.set('env', env); + this.set('query parser', 'extended'); this.set('subdomain offset', 2); this.set('trust proxy', false); @@ -104,7 +106,7 @@ app.lazyrouter = function() { strict: this.enabled('strict routing') }); - this._router.use(query()); + this._router.use(query(this.get('query parser fn'))); this._router.use(middleware.init(this)); } }; @@ -306,6 +308,10 @@ app.set = function(setting, val){ debug('compile etag %s', val); this.set('etag fn', compileETag(val)); break; + case 'query parser': + debug('compile query parser %s', val); + this.set('query parser fn', compileQueryParser(val)); + break; case 'trust proxy': debug('compile trust proxy %s', val); this.set('trust proxy fn', compileTrust(val)); diff --git a/lib/middleware/query.js b/lib/middleware/query.js index b828c85ef08..092bbd9985d 100644 --- a/lib/middleware/query.js +++ b/lib/middleware/query.js @@ -2,36 +2,27 @@ * Module dependencies. */ -var qs = require('qs'); var parseUrl = require('parseurl'); +var qs = require('qs'); /** - * Query: - * - * Automatically parse the query-string when available, - * populating the `req.query` object using - * [qs](https://github.com/visionmedia/node-querystring). - * - * Examples: - * - * .use(connect.query()) - * .use(function(req, res){ - * res.end(JSON.stringify(req.query)); - * }); - * - * The `options` passed are provided to qs.parse function. - * * @param {Object} options * @return {Function} * @api public */ -module.exports = function query(options){ +module.exports = function query(options) { + var queryparse = qs.parse; + + if (typeof options === 'function') { + queryparse = options; + options = undefined; + } + return function query(req, res, next){ if (!req.query) { - req.query = ~req.url.indexOf('?') - ? qs.parse(parseUrl(req).query, options) - : {}; + var val = parseUrl(req).query; + req.query = queryparse(val, options); } next(); diff --git a/lib/utils.js b/lib/utils.js index d6e6e614869..9f9fdfd6d0e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -7,6 +7,8 @@ var crc32 = require('buffer-crc32'); var crypto = require('crypto'); var basename = require('path').basename; var proxyaddr = require('proxy-addr'); +var qs = require('qs'); +var querystring = require('querystring'); var typer = require('media-typer'); /** @@ -202,6 +204,41 @@ exports.compileETag = function(val) { return fn; } +/** + * Compile "query parser" value to function. + * + * @param {String|Function} val + * @return {Function} + * @api private + */ + +exports.compileQueryParser = function compileQueryParser(val) { + var fn; + + if (typeof val === 'function') { + return val; + } + + switch (val) { + case true: + fn = querystring.parse; + break; + case false: + fn = newObject; + break; + case 'extended': + fn = qs.parse; + break; + case 'simple': + fn = querystring.parse; + break; + default: + throw new TypeError('unknown value for query parser function: ' + val); + } + + return fn; +} + /** * Compile "proxy trust" value to function. * @@ -252,3 +289,14 @@ exports.setCharset = function(type, charset){ // format type return typer.format(parsed); }; + +/** + * Return new empty objet. + * + * @return {Object} + * @api private + */ + +function newObject() { + return {}; +} diff --git a/test/req.query.js b/test/req.query.js index 10547e4a117..f243293125b 100644 --- a/test/req.query.js +++ b/test/req.query.js @@ -5,33 +5,91 @@ var express = require('../') describe('req', function(){ describe('.query', function(){ it('should default to {}', function(done){ - var app = express(); - - app.use(function(req, res){ - req.query.should.eql({}); - res.end(); - }); + var app = createApp(); request(app) .get('/') - .end(function(res){ - done(); + .expect(200, '{}', done); + }); + + it('should default to parse complex keys', function (done) { + var app = createApp(); + + request(app) + .get('/?user[name]=tj') + .expect(200, '{"user":{"name":"tj"}}', done); + }); + + describe('when "query parser" is extended', function () { + it('should parse complex keys', function (done) { + var app = createApp('extended'); + + request(app) + .get('/?user[name]=tj') + .expect(200, '{"user":{"name":"tj"}}', done); }); - }) + }); - it('should contain the parsed query-string', function(done){ - var app = express(); + describe('when "query parser" is simple', function () { + it('should not parse complex keys', function (done) { + var app = createApp('simple'); - app.use(function(req, res){ - req.query.should.eql({ user: { name: 'tj' }}); - res.end(); + request(app) + .get('/?user[name]=tj') + .expect(200, '{"user[name]":"tj"}', done); }); + }); - request(app) - .get('/?user[name]=tj') - .end(function(res){ - done(); + describe('when "query parser" is a function', function () { + it('should parse using function', function (done) { + var app = createApp(function (str) { + return {'length': (str || '').length}; + }); + + request(app) + .get('/?user[name]=tj') + .expect(200, '{"length":17}', done); }); - }) + }); + + describe('when "query parser" disabled', function () { + it('should not parse query', function (done) { + var app = createApp(false); + + request(app) + .get('/?user[name]=tj') + .expect(200, '{}', done); + }); + }); + + describe('when "query parser" disabled', function () { + it('should not parse complex keys', function (done) { + var app = createApp(true); + + request(app) + .get('/?user[name]=tj') + .expect(200, '{"user[name]":"tj"}', done); + }); + }); + + describe('when "query parser" an unknown value', function () { + it('should throw', function () { + createApp.bind(null, 'bogus').should.throw(/unknown value.*query parser/); + }); + }); }) }) + +function createApp(setting) { + var app = express(); + + if (setting !== undefined) { + app.set('query parser', setting); + } + + app.use(function (req, res) { + res.send(req.query); + }); + + return app; +} From fd86ab8da22b847b160ef7b5c17cb39481ea4f38 Mon Sep 17 00:00:00 2001 From: Vasilyev Dmitry Date: Wed, 16 Jul 2014 14:07:31 +0600 Subject: [PATCH 0407/1265] build: fix up jsdoc return values closes #2243 --- lib/response.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/response.js b/lib/response.js index 155bf3980dc..1654faf2ca9 100644 --- a/lib/response.js +++ b/lib/response.js @@ -625,7 +625,7 @@ res.get = function(field){ * * @param {String} name * @param {Object} options - * @param {ServerResponse} for chaining + * @return {ServerResponse} for chaining * @api public */ @@ -656,6 +656,7 @@ res.clearCookie = function(name, options){ * @param {String} name * @param {String|Object} val * @param {Options} options + * @return {ServerResponse} for chaining * @api public */ @@ -701,6 +702,7 @@ res.cookie = function(name, val, options){ * res.location('../login'); * * @param {String} url + * @return {ServerResponse} for chaining * @api public */ @@ -785,7 +787,7 @@ res.redirect = function redirect(url) { * this call is simply ignored. * * @param {Array|String} field - * @param {ServerResponse} for chaining + * @return {ServerResponse} for chaining * @api public */ From 04f383087fc00981d57035129457d053eaad058b Mon Sep 17 00:00:00 2001 From: Young Jae Sim Date: Thu, 17 Jul 2014 00:56:30 +0900 Subject: [PATCH 0408/1265] docs: add expressjs.kr(expressjs.com in Korean) closes #2242 closes #2244 --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index 6940c71efdd..4718b833a85 100644 --- a/Readme.md +++ b/Readme.md @@ -82,6 +82,7 @@ $ npm start * Visit the [Wiki](https://github.com/visionmedia/express/wiki) * [Google Group](https://groups.google.com/group/express-js) for discussion * [Русскоязычная документация](http://jsman.ru/express/) + * [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)] * Run express examples [online](https://runnable.com/express) ## Viewing Examples From d046208ca24000cfd83e474bf2d4340c60ffb520 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 16 Jul 2014 13:10:19 -0400 Subject: [PATCH 0409/1265] build: add Young Jae Sim as contributor --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 927ebe2eb68..a6d9a005a94 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "Douglas Christopher Wilson ", "Guillermo Rauch ", "Jonathan Ong ", - "Roman Shtylman ", + "Young Jae Sim " ], "keywords": [ "express", From da4c6399546c254952c45242e28d999ada31e611 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 16 Jul 2014 20:44:17 -0400 Subject: [PATCH 0410/1265] deps: debug@1.0.4 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a0d62026ba6..fb02d0f1c15 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,7 @@ unreleased - `app.set('query parser', 'simple')` parse with "querystring" core module - `app.set('query parser', false)` disable query string parsing - `app.set('query parser', true)` enable simple parsing + * deps: debug@1.0.4 * perf: prevent multiple `Buffer` creation in `res.send` 4.6.1 / 2014-07-12 diff --git a/package.json b/package.json index a6d9a005a94..713a68bde20 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "accepts": "~1.0.7", "buffer-crc32": "0.2.3", - "debug": "1.0.3", + "debug": "1.0.4", "depd": "0.3.0", "escape-html": "1.0.1", "finalhandler": "0.0.3", From 21bb2ef30e46eff8216c5fa177997239e7abebc2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 16 Jul 2014 20:47:24 -0400 Subject: [PATCH 0411/1265] deps: finalhandler@0.1.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index fb02d0f1c15..114d1cd26b4 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,9 @@ unreleased - `app.set('query parser', false)` disable query string parsing - `app.set('query parser', true)` enable simple parsing * deps: debug@1.0.4 + * deps: finalhandler@0.1.0 + - Respond after request fully read + - deps: debug@1.0.4 * perf: prevent multiple `Buffer` creation in `res.send` 4.6.1 / 2014-07-12 diff --git a/package.json b/package.json index 713a68bde20..c5888f2efb5 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "debug": "1.0.4", "depd": "0.3.0", "escape-html": "1.0.1", - "finalhandler": "0.0.3", + "finalhandler": "0.1.0", "media-typer": "0.2.0", "methods": "1.1.0", "parseurl": "~1.1.3", From fd3b40533bafa7e136f68354d0be470bfe60a51c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 17 Jul 2014 22:49:41 -0400 Subject: [PATCH 0412/1265] Deprecate combined status, response signatures closes #2227 --- History.md | 3 +++ lib/response.js | 27 ++++++++++----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/History.md b/History.md index 114d1cd26b4..37c785197b6 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,9 @@ unreleased - `app.set('query parser', 'simple')` parse with "querystring" core module - `app.set('query parser', false)` disable query string parsing - `app.set('query parser', true)` enable simple parsing + * deprecate `res.json(status, obj)` -- use `res.status(status).json(obj)` instead + * deprecate `res.jsonp(status, obj)` -- use `res.status(status).jsonp(obj)` instead + * deprecate `res.send(status, body)` -- use `res.status(status).send(body)` instead * deps: debug@1.0.4 * deps: finalhandler@0.1.0 - Respond after request fully read diff --git a/lib/response.js b/lib/response.js index 1654faf2ca9..6a1db729ee1 100644 --- a/lib/response.js +++ b/lib/response.js @@ -72,9 +72,8 @@ res.links = function(links){ * res.send(new Buffer('wahoo')); * res.send({ some: 'json' }); * res.send('

some html

'); - * res.send(404, 'Sorry, cant find that'); - * res.send(404); * + * @param {string|number|boolean|object|Buffer} body * @api public */ @@ -92,9 +91,10 @@ res.send = function send(body) { if (arguments.length === 2) { // res.send(body, status) backwards compat if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') { - deprecate('res.send(body, status): Use res.send(status, body) instead'); + deprecate('res.send(body, status): Use res.status(status).send(body) instead'); this.statusCode = arguments[1]; } else { + deprecate('res.send(status, body): Use res.status(status).send(body) instead'); this.statusCode = arguments[0]; chunk = arguments[1]; } @@ -107,6 +107,7 @@ res.send = function send(body) { this.type('txt'); } + deprecate('res.send(status): Use res.status(status).end() instead'); this.statusCode = chunk; chunk = http.STATUS_CODES[chunk]; } @@ -197,9 +198,8 @@ res.send = function send(body) { * * res.json(null); * res.json({ user: 'tj' }); - * res.json(500, 'oh noes!'); - * res.json(404, 'I dont have that'); * + * @param {string|number|boolean|object} obj * @api public */ @@ -210,13 +210,10 @@ res.json = function json(obj) { if (arguments.length === 2) { // res.json(body, status) backwards compat if (typeof arguments[1] === 'number') { + deprecate('res.json(obj, status): Use res.status(status).json(obj) instead'); this.statusCode = arguments[1]; - if (typeof arguments[0] === 'number') { - deprecate('res.json(obj, status): Use res.json(status, obj) instead'); - } else { - deprecate('res.json(num, status): Use res.status(status).json(num) instead'); - } } else { + deprecate('res.json(status, obj): Use res.status(status).json(obj) instead'); this.statusCode = arguments[0]; val = arguments[1]; } @@ -243,9 +240,8 @@ res.json = function json(obj) { * * res.jsonp(null); * res.jsonp({ user: 'tj' }); - * res.jsonp(500, 'oh noes!'); - * res.jsonp(404, 'I dont have that'); * + * @param {string|number|boolean|object} obj * @api public */ @@ -256,13 +252,10 @@ res.jsonp = function jsonp(obj) { if (arguments.length === 2) { // res.json(body, status) backwards compat if (typeof arguments[1] === 'number') { + deprecate('res.jsonp(obj, status): Use res.status(status).json(obj) instead'); this.statusCode = arguments[1]; - if (typeof arguments[0] === 'number') { - deprecate('res.jsonp(obj, status): Use res.jsonp(status, obj) instead'); - } else { - deprecate('res.jsonp(num, status): Use res.status(status).jsonp(num) instead'); - } } else { + deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead'); this.statusCode = arguments[0]; val = arguments[1]; } From 7414a1f46326669661f5a6190d458531a4fdf11e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 18 Jul 2014 14:18:35 -0400 Subject: [PATCH 0413/1265] deps: debug@1.0.4 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7bd01d44c65..b8e1af853a6 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.x +=== + + * deps: debug@1.0.4 + 3.14.0 / 2014-07-11 =================== diff --git a/package.json b/package.json index 12780bd7552..fb8ce3f64dc 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "buffer-crc32": "0.2.3", "connect": "2.23.0", "commander": "1.3.2", - "debug": "1.0.3", + "debug": "1.0.4", "depd": "0.3.0", "escape-html": "1.0.1", "media-typer": "0.2.0", From e4ff5281c9e8d6425096b69171d424d14d650a9c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 22 Jul 2014 23:50:36 -0400 Subject: [PATCH 0414/1265] deps: connect@2.24.0 --- History.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b8e1af853a6..c41022258f1 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,19 @@ 3.x === + * deps: connect@2.24.0 + - deps: body-parser@~1.5.0 + - deps: compression@~1.0.9 + - deps: connect-timeout@~1.2.1 + - deps: debug@1.0.4 + - deps: depd@0.4.2 + - deps: express-session@~1.7.0 + - deps: finalhandler@0.1.0 + - deps: method-override@~2.1.2 + - deps: morgan@~1.2.0 + - deps: multiparty@3.3.1 + - deps: parseurl@~1.2.0 + - deps: serve-static@~1.4.0 * deps: debug@1.0.4 3.14.0 / 2014-07-11 diff --git a/package.json b/package.json index fb8ce3f64dc..52aa7104220 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.23.0", + "connect": "2.24.0", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.3.0", From 683ba1cd7547de87d3e5da7e7c55293a6b738a91 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 22 Jul 2014 23:52:44 -0400 Subject: [PATCH 0415/1265] deps: depd@0.4.2 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c41022258f1..98a1209b131 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,11 @@ - deps: parseurl@~1.2.0 - deps: serve-static@~1.4.0 * deps: debug@1.0.4 + * deps: depd@0.4.2 + - Add `TRACE_DEPRECATION` environment variable + - Remove non-standard grey color from color output + - Support `--no-deprecation` argument + - Support `--trace-deprecation` argument 3.14.0 / 2014-07-11 =================== diff --git a/package.json b/package.json index 52aa7104220..258b1342830 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "connect": "2.24.0", "commander": "1.3.2", "debug": "1.0.4", - "depd": "0.3.0", + "depd": "0.4.2", "escape-html": "1.0.1", "media-typer": "0.2.0", "methods": "1.1.0", From 1d0da9036b76a25cd1d92d3ea2ce2af060c1d52c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 22 Jul 2014 23:53:50 -0400 Subject: [PATCH 0416/1265] deps: parseurl@~1.2.0 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 98a1209b131..49e0a19e0b0 100644 --- a/History.md +++ b/History.md @@ -20,6 +20,10 @@ - Remove non-standard grey color from color output - Support `--no-deprecation` argument - Support `--trace-deprecation` argument + * deps: parseurl@~1.2.0 + - Cache URLs based on original value + - Remove no-longer-needed URL mis-parse work-around + - Simplify the "fast-path" `RegExp` 3.14.0 / 2014-07-11 =================== diff --git a/package.json b/package.json index 258b1342830..e2c16102cc3 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "media-typer": "0.2.0", "methods": "1.1.0", "mkdirp": "0.5.0", - "parseurl": "~1.1.3", + "parseurl": "~1.2.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.5.0", From 323c185079b7fad7d331d04652cbde6e77694869 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 22 Jul 2014 23:55:17 -0400 Subject: [PATCH 0417/1265] deps: send@0.7.0 --- History.md | 5 +++++ lib/response.js | 7 ++++--- package.json | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 49e0a19e0b0..872e6ced5a8 100644 --- a/History.md +++ b/History.md @@ -24,6 +24,11 @@ - Cache URLs based on original value - Remove no-longer-needed URL mis-parse work-around - Simplify the "fast-path" `RegExp` + * deps: send@0.7.0 + - Add `dotfiles` option + - Cap `maxAge` value to 1 year + - deps: debug@1.0.4 + - deps: depd@0.4.2 3.14.0 / 2014-07-11 =================== diff --git a/lib/response.js b/lib/response.js index 2e4b35cb747..fd0318589ba 100644 --- a/lib/response.js +++ b/lib/response.js @@ -385,9 +385,10 @@ res.sendfile = function(path, options, fn){ } // transfer - var file = send(req, path); - if (options.root) file.root(options.root); - file.maxage(options.maxAge || 0); + var file = send(req, path, { + maxAge: options.maxAge || 0, + root: options.root + }); file.on('error', error); file.on('directory', next); file.on('stream', stream); diff --git a/package.json b/package.json index e2c16102cc3..7a5ef69fa18 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.2.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.5.0", + "send": "0.7.0", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From 0d77305a1adf860220d61f4bfa2015dafb2a7f70 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 00:08:15 -0400 Subject: [PATCH 0418/1265] Pass options from res.sendfile to send fixes #2017 --- History.md | 1 + lib/response.js | 12 ++++++------ test/fixtures/.name | 1 + test/res.sendfile.js | 24 ++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/.name diff --git a/History.md b/History.md index 872e6ced5a8..e16e92babee 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Pass options from `res.sendfile` to `send` * deps: connect@2.24.0 - deps: body-parser@~1.5.0 - deps: compression@~1.0.9 diff --git a/lib/response.js b/lib/response.js index fd0318589ba..61c7f16c3ce 100644 --- a/lib/response.js +++ b/lib/response.js @@ -308,8 +308,11 @@ res.jsonp = function(obj){ * * Options: * - * - `maxAge` defaulting to 0 - * - `root` root directory for relative filenames + * - `maxAge` defaulting to 0 + * - `root` root directory for relative filenames + * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them + * + * Other options are passed along to `send`. * * Examples: * @@ -385,10 +388,7 @@ res.sendfile = function(path, options, fn){ } // transfer - var file = send(req, path, { - maxAge: options.maxAge || 0, - root: options.root - }); + var file = send(req, path, options); file.on('error', error); file.on('directory', next); file.on('stream', stream); diff --git a/test/fixtures/.name b/test/fixtures/.name new file mode 100644 index 00000000000..fa66f37ff21 --- /dev/null +++ b/test/fixtures/.name @@ -0,0 +1 @@ +tobi \ No newline at end of file diff --git a/test/res.sendfile.js b/test/res.sendfile.js index 8603f2057ba..27ffba69865 100644 --- a/test/res.sendfile.js +++ b/test/res.sendfile.js @@ -106,6 +106,30 @@ describe('res', function(){ }) describe('.sendfile(path)', function(){ + it('should not serve dotfiles', function(done){ + var app = express(); + + app.use(function(req, res){ + res.sendfile('test/fixtures/.name'); + }); + + request(app) + .get('/') + .expect(404, done); + }) + + it('should accept dotfiles option', function(done){ + var app = express(); + + app.use(function(req, res){ + res.sendfile('test/fixtures/.name', { dotfiles: 'allow' }); + }); + + request(app) + .get('/') + .expect(200, 'tobi', done); + }) + describe('with an absolute path', function(){ it('should transfer the file', function(done){ var app = express(); From 3fc8dc54ee2075b397c2d16c641e761a29fec4ad Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 00:13:21 -0400 Subject: [PATCH 0419/1265] docs: replace Gittip badge --- Readme.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 2ce672040ae..e9e45b91eb7 100644 --- a/Readme.md +++ b/Readme.md @@ -2,7 +2,10 @@ Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). - [![NPM version](https://badge.fury.io/js/express.svg)](http://badge.fury.io/js/express) [![Build Status](https://travis-ci.org/visionmedia/express.svg?branch=master)](https://travis-ci.org/visionmedia/express) [![Coverage Status](https://img.shields.io/coveralls/visionmedia/express.svg)](https://coveralls.io/r/visionmedia/express) [![Gittip](http://img.shields.io/gittip/visionmedia.svg)](https://www.gittip.com/visionmedia/) + [![NPM version](https://badge.fury.io/js/express.svg)](http://badge.fury.io/js/express) + [![Build Status](https://travis-ci.org/visionmedia/express.svg?branch=master)](https://travis-ci.org/visionmedia/express) + [![Coverage Status](https://img.shields.io/coveralls/visionmedia/express.svg)](https://coveralls.io/r/visionmedia/express) + [![Gittip](http://img.shields.io/gittip/dougwilson.svg)](https://www.gittip.com/dougwilson/) ```js var express = require('express'); From a28b7a85cf3fc71e1a1bda8d90338741eba8c92b Mon Sep 17 00:00:00 2001 From: Ashley Streb Date: Fri, 18 Jul 2014 11:33:16 -0400 Subject: [PATCH 0420/1265] Fix req.protocol for proxy-direct connections fixes #2252 --- History.md | 1 + lib/request.js | 13 ++++++++----- test/req.protocol.js | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index e16e92babee..dd015b9a2d8 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Fix `req.protocol` for proxy-direct connections * Pass options from `res.sendfile` to `send` * deps: connect@2.24.0 - deps: body-parser@~1.5.0 diff --git a/lib/request.js b/lib/request.js index 065e4c6fe3c..35c48a77dbf 100644 --- a/lib/request.js +++ b/lib/request.js @@ -341,7 +341,9 @@ req.is = function(type){ * Return the protocol string "http" or "https" * when requested with TLS. When the "trust proxy" * setting trusts the socket address, the - * "X-Forwarded-Proto" header field will be trusted. + * "X-Forwarded-Proto" header field will be trusted + * and used if present. + * * If you're running behind a reverse proxy that * supplies https for you this may be enabled. * @@ -350,17 +352,18 @@ req.is = function(type){ */ req.__defineGetter__('protocol', function(){ + var proto = this.connection.encrypted + ? 'https' + : 'http'; var trust = this.app.get('trust proxy fn'); if (!trust(this.connection.remoteAddress)) { - return this.connection.encrypted - ? 'https' - : 'http'; + return proto; } // Note: X-Forwarded-Proto is normally only ever a // single value, but this is to be safe. - var proto = this.get('X-Forwarded-Proto') || 'http'; + proto = this.get('X-Forwarded-Proto') || proto; return proto.split(/\s*,\s*/)[0]; }); diff --git a/test/req.protocol.js b/test/req.protocol.js index 9a44aeb54c4..80cad8a975f 100644 --- a/test/req.protocol.js +++ b/test/req.protocol.js @@ -32,6 +32,21 @@ describe('req', function(){ .expect('https', done); }) + it('should default to the socket addr if X-Forwarded-Proto not present', function(done){ + var app = express(); + + app.enable('trust proxy'); + + app.use(function(req, res){ + req.connection.encrypted = true; + res.end(req.protocol); + }); + + request(app) + .get('/') + .expect('https', done); + }) + it('should ignore X-Forwarded-Proto if socket addr not trusted', function(done){ var app = express(); From 928952e7f0f3490619d3c1cd4f98c9de887ffc00 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 00:53:19 -0400 Subject: [PATCH 0421/1265] 3.15.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index dd015b9a2d8..353d8cb9780 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.15.0 / 2014-07-22 +=================== * Fix `req.protocol` for proxy-direct connections * Pass options from `res.sendfile` to `send` diff --git a/package.json b/package.json index 7a5ef69fa18..2a36da5c2c4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.14.0", + "version": "3.15.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 90194247253deabfa5fa90322925daab76681fb6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 22 Jul 2014 23:52:44 -0400 Subject: [PATCH 0422/1265] deps: depd@0.4.2 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 37c785197b6..1f0896af5c1 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,11 @@ unreleased * deprecate `res.jsonp(status, obj)` -- use `res.status(status).jsonp(obj)` instead * deprecate `res.send(status, body)` -- use `res.status(status).send(body)` instead * deps: debug@1.0.4 + * deps: depd@0.4.2 + - Add `TRACE_DEPRECATION` environment variable + - Remove non-standard grey color from color output + - Support `--no-deprecation` argument + - Support `--trace-deprecation` argument * deps: finalhandler@0.1.0 - Respond after request fully read - deps: debug@1.0.4 diff --git a/package.json b/package.json index c5888f2efb5..95928ea7b93 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "accepts": "~1.0.7", "buffer-crc32": "0.2.3", "debug": "1.0.4", - "depd": "0.3.0", + "depd": "0.4.2", "escape-html": "1.0.1", "finalhandler": "0.1.0", "media-typer": "0.2.0", From dc054d190aa33b31d5bd15a48d5349f483383e89 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 22 Jul 2014 23:53:50 -0400 Subject: [PATCH 0423/1265] deps: parseurl@~1.2.0 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1f0896af5c1..a6fff42beed 100644 --- a/History.md +++ b/History.md @@ -18,6 +18,10 @@ unreleased * deps: finalhandler@0.1.0 - Respond after request fully read - deps: debug@1.0.4 + * deps: parseurl@~1.2.0 + - Cache URLs based on original value + - Remove no-longer-needed URL mis-parse work-around + - Simplify the "fast-path" `RegExp` * perf: prevent multiple `Buffer` creation in `res.send` 4.6.1 / 2014-07-12 diff --git a/package.json b/package.json index 95928ea7b93..d1728b2b8b8 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "finalhandler": "0.1.0", "media-typer": "0.2.0", "methods": "1.1.0", - "parseurl": "~1.1.3", + "parseurl": "~1.2.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", "range-parser": "1.0.0", From 7cd86a01da1c0bc8a845ae358edbc92f6fd06086 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 13:04:07 -0400 Subject: [PATCH 0424/1265] deps: update example dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d1728b2b8b8..445d0d82f62 100644 --- a/package.json +++ b/package.json @@ -60,12 +60,12 @@ "jade": "~1.3.1", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.4.3", + "body-parser": "~1.5.0", "cookie-parser": "~1.3.1", - "express-session": "~1.6.5", + "express-session": "~1.7.0", "method-override": "~2.1.1", - "multiparty": "~3.3.0", - "morgan": "1.1.1", + "morgan": "~1.2.0", + "multiparty": "~3.3.1", "vhost": "2.0.0" }, "engines": { From 3b7ca4317047c916681bb9f50c4cf5c2f9caeca9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 14:01:44 -0400 Subject: [PATCH 0425/1265] deps: jade@~1.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 445d0d82f62..7a7160ba82f 100644 --- a/package.json +++ b/package.json @@ -57,12 +57,12 @@ "supertest": "~0.13.0", "connect-redis": "~2.0.0", "ejs": "~1.0.0", - "jade": "~1.3.1", "marked": "0.3.2", "hjs": "~0.0.6", "body-parser": "~1.5.0", "cookie-parser": "~1.3.1", "express-session": "~1.7.0", + "jade": "~1.5.0", "method-override": "~2.1.1", "morgan": "~1.2.0", "multiparty": "~3.3.1", From 88cffadcaabf7d7a398e5f612bcd27ed2a4f80b3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 22 Jul 2014 23:55:17 -0400 Subject: [PATCH 0426/1265] deps: send@0.7.0 --- History.md | 5 +++++ lib/response.js | 3 --- package.json | 2 +- test/res.sendfile.js | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/History.md b/History.md index a6fff42beed..5a4c5ce17e7 100644 --- a/History.md +++ b/History.md @@ -22,6 +22,11 @@ unreleased - Cache URLs based on original value - Remove no-longer-needed URL mis-parse work-around - Simplify the "fast-path" `RegExp` + * deps: send@0.7.0 + - Add `dotfiles` option + - Cap `maxAge` value to 1 year + - deps: debug@1.0.4 + - deps: depd@0.4.2 * perf: prevent multiple `Buffer` creation in `res.send` 4.6.1 / 2014-07-12 diff --git a/lib/response.js b/lib/response.js index 6a1db729ee1..f8baa7065fb 100644 --- a/lib/response.js +++ b/lib/response.js @@ -386,9 +386,6 @@ res.sendfile = function(path, options, fn){ req.socket.removeListener('error', error); } - // Back-compat - options.maxage = options.maxage || options.maxAge || 0; - // transfer var file = send(req, path, options); file.on('error', error); diff --git a/package.json b/package.json index 7a7160ba82f..2c12c7e61d4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.6.0", + "send": "0.7.0", "serve-static": "~1.3.2", "type-is": "~1.3.2", "vary": "0.1.0", diff --git a/test/res.sendfile.js b/test/res.sendfile.js index 45e55845bb8..667c83a1624 100644 --- a/test/res.sendfile.js +++ b/test/res.sendfile.js @@ -106,7 +106,7 @@ describe('res', function(){ }) describe('.sendfile(path)', function(){ - it('should not serve hidden files', function(done){ + it('should not serve dotfiles', function(done){ var app = express(); app.use(function(req, res){ @@ -118,11 +118,11 @@ describe('res', function(){ .expect(404, done); }) - it('should accept hidden option', function(done){ + it('should accept dotfiles option', function(done){ var app = express(); app.use(function(req, res){ - res.sendfile('test/fixtures/.name', { hidden: true }); + res.sendfile('test/fixtures/.name', { dotfiles: 'allow' }); }); request(app) From 035685918c556783f7d8d4150f0a410d2e9d7b42 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 14:56:27 -0400 Subject: [PATCH 0427/1265] deps: serve-static@~1.4.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5a4c5ce17e7..d7e3b12bcb5 100644 --- a/History.md +++ b/History.md @@ -27,6 +27,9 @@ unreleased - Cap `maxAge` value to 1 year - deps: debug@1.0.4 - deps: depd@0.4.2 + * deps: serve-static@~1.4.0 + - deps: parseurl@~1.2.0 + - deps: send@0.7.0 * perf: prevent multiple `Buffer` creation in `res.send` 4.6.1 / 2014-07-12 diff --git a/package.json b/package.json index 2c12c7e61d4..728522e8aef 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.7.0", - "serve-static": "~1.3.2", + "serve-static": "~1.4.0", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 11c74d72ebee6d75d5a1bb6d553a4d49a0aa9628 Mon Sep 17 00:00:00 2001 From: Ashley Streb Date: Fri, 18 Jul 2014 11:33:16 -0400 Subject: [PATCH 0428/1265] Fix req.protocol for proxy-direct connections fixes #2252 --- History.md | 1 + lib/request.js | 13 ++++++++----- test/req.protocol.js | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index d7e3b12bcb5..47874e18cdf 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * fix `req.protocol` for proxy-direct connections * configurable query parser with `app.set('query parser', parser)` - `app.set('query parser', 'extended')` parse with "qs" module - `app.set('query parser', 'simple')` parse with "querystring" core module diff --git a/lib/request.js b/lib/request.js index 514175b0037..ea5d03722ee 100644 --- a/lib/request.js +++ b/lib/request.js @@ -244,7 +244,9 @@ req.is = function(types){ * Return the protocol string "http" or "https" * when requested with TLS. When the "trust proxy" * setting trusts the socket address, the - * "X-Forwarded-Proto" header field will be trusted. + * "X-Forwarded-Proto" header field will be trusted + * and used if present. + * * If you're running behind a reverse proxy that * supplies https for you this may be enabled. * @@ -253,17 +255,18 @@ req.is = function(types){ */ defineGetter(req, 'protocol', function protocol(){ + var proto = this.connection.encrypted + ? 'https' + : 'http'; var trust = this.app.get('trust proxy fn'); if (!trust(this.connection.remoteAddress)) { - return this.connection.encrypted - ? 'https' - : 'http'; + return proto; } // Note: X-Forwarded-Proto is normally only ever a // single value, but this is to be safe. - var proto = this.get('X-Forwarded-Proto') || 'http'; + proto = this.get('X-Forwarded-Proto') || proto; return proto.split(/\s*,\s*/)[0]; }); diff --git a/test/req.protocol.js b/test/req.protocol.js index 9a44aeb54c4..80cad8a975f 100644 --- a/test/req.protocol.js +++ b/test/req.protocol.js @@ -32,6 +32,21 @@ describe('req', function(){ .expect('https', done); }) + it('should default to the socket addr if X-Forwarded-Proto not present', function(done){ + var app = express(); + + app.enable('trust proxy'); + + app.use(function(req, res){ + req.connection.encrypted = true; + res.end(req.protocol); + }); + + request(app) + .get('/') + .expect('https', done); + }) + it('should ignore X-Forwarded-Proto if socket addr not trusted', function(done){ var app = express(); From d0b6b3dfcf4f19eb8af7b4a445fa72ef437d3098 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 17:28:14 -0400 Subject: [PATCH 0429/1265] tests: change Route tests to use callback --- test/Route.js | 132 +++++++++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 55 deletions(-) diff --git a/test/Route.js b/test/Route.js index 8d37a0bb9c1..c979fb110c6 100644 --- a/test/Route.js +++ b/test/Route.js @@ -1,4 +1,5 @@ +var after = require('after'); var should = require('should'); var express = require('../') , Route = express.Route @@ -9,167 +10,182 @@ describe('Route', function(){ describe('.all', function(){ it('should add handler', function(done){ + var req = { method: 'GET', url: '/' }; var route = new Route('/foo'); route.all(function(req, res, next) { - assert.equal(req.a, 1); - assert.equal(res.b, 2); + req.called = true; next(); }); - route.dispatch({ a:1, method: 'GET' }, { b:2 }, done); + route.dispatch(req, {}, function (err) { + if (err) return done(err); + should(req.called).be.ok; + done(); + }); }) it('should handle VERBS', function(done) { + var count = 0; var route = new Route('/foo'); + var cb = after(methods.length, function (err) { + if (err) return done(err); + count.should.equal(methods.length); + done(); + }); - var count = 0; route.all(function(req, res, next) { count++; + next(); }); methods.forEach(function testMethod(method) { - route.dispatch({ method: method }, {}); + var req = { method: method, url: '/' }; + route.dispatch(req, {}, cb); }); - - assert.equal(count, methods.length); - done(); }) it('should stack', function(done) { + var req = { count: 0, method: 'GET', url: '/' }; var route = new Route('/foo'); - var count = 0; route.all(function(req, res, next) { - count++; + req.count++; next(); }); route.all(function(req, res, next) { - count++; + req.count++; next(); }); - route.dispatch({ method: 'GET' }, {}, function(err) { - assert.ifError(err); - count++; + route.dispatch(req, {}, function (err) { + if (err) return done(err); + req.count.should.equal(2); + done(); }); - - assert.equal(count, 3); - done(); }) }) describe('.VERB', function(){ it('should support .get', function(done){ + var req = { method: 'GET', url: '/' }; var route = new Route(''); - var count = 0; route.get(function(req, res, next) { - count++; + req.called = true; + next(); }) - route.dispatch({ method: 'GET' }, {}); - assert(count); - done(); + route.dispatch(req, {}, function (err) { + if (err) return done(err); + should(req.called).be.ok; + done(); + }); }) it('should limit to just .VERB', function(done){ + var req = { method: 'POST', url: '/' }; var route = new Route(''); route.get(function(req, res, next) { - assert(false); - done(); + throw new Error('not me!'); }) route.post(function(req, res, next) { - assert(true); + req.called = true; + next(); }) - route.dispatch({ method: 'post' }, {}); - done(); + route.dispatch(req, {}, function (err) { + if (err) return done(err); + should(req.called).be.true; + done(); + }); }) it('should allow fallthrough', function(done){ + var req = { order: '', method: 'GET', url: '/' }; var route = new Route(''); - var order = ''; route.get(function(req, res, next) { - order += 'a'; + req.order += 'a'; next(); }) route.all(function(req, res, next) { - order += 'b'; + req.order += 'b'; next(); }); route.get(function(req, res, next) { - order += 'c'; + req.order += 'c'; + next(); }) - route.dispatch({ method: 'get' }, {}); - assert.equal(order, 'abc'); - done(); + route.dispatch(req, {}, function (err) { + if (err) return done(err); + req.order.should.equal('abc'); + done(); + }); }) }) describe('errors', function(){ it('should handle errors via arity 4 functions', function(done){ + var req = { order: '', method: 'GET', url: '/' }; var route = new Route(''); - var order = ''; route.all(function(req, res, next){ next(new Error('foobar')); }); route.all(function(req, res, next){ - order += '0'; + req.order += '0'; next(); }); route.all(function(err, req, res, next){ - order += 'a'; + req.order += 'a'; next(err); }); - route.all(function(err, req, res, next){ - assert.equal(err.message, 'foobar'); - assert.equal(order, 'a'); + route.dispatch(req, {}, function (err) { + should(err).be.ok; + should(err.message).equal('foobar'); + req.order.should.equal('a'); done(); }); - - route.dispatch({ method: 'get' }, {}); }) it('should handle throw', function(done) { + var req = { order: '', method: 'GET', url: '/' }; var route = new Route(''); - var order = ''; route.all(function(req, res, next){ throw new Error('foobar'); }); route.all(function(req, res, next){ - order += '0'; + req.order += '0'; next(); }); route.all(function(err, req, res, next){ - order += 'a'; + req.order += 'a'; next(err); }); - route.all(function(err, req, res, next){ - assert.equal(err.message, 'foobar'); - assert.equal(order, 'a'); + route.dispatch(req, {}, function (err) { + should(err).be.ok; + should(err.message).equal('foobar'); + req.order.should.equal('a'); done(); }); - - route.dispatch({ method: 'get' }, {}); }); it('should handle throwing inside error handlers', function(done) { + var req = { method: 'GET', url: '/' }; var route = new Route(''); route.get(function(req, res, next){ @@ -181,21 +197,26 @@ describe('Route', function(){ }); route.get(function(err, req, res, next){ - assert.equal(err.message, 'oops'); - done(); + req.message = err.message; + next(); }); - route.dispatch({ url: '/', method: 'GET' }, {}); + route.dispatch(req, {}, function (err) { + if (err) return done(err); + should(req.message).equal('oops'); + done(); + }); }); it('should handle throw in .all', function(done) { + var req = { method: 'GET', url: '/' }; var route = new Route(''); route.all(function(req, res, next){ throw new Error('boom!'); }); - route.dispatch({ url: '/', method: 'GET' }, {}, function(err){ + route.dispatch(req, {}, function(err){ should(err).be.ok; err.message.should.equal('boom!'); done(); @@ -203,6 +224,7 @@ describe('Route', function(){ }); it('should handle single error handler', function(done) { + var req = { method: 'GET', url: '/' }; var route = new Route(''); route.all(function(err, req, res, next){ @@ -210,7 +232,7 @@ describe('Route', function(){ true.should.be.false; }); - route.dispatch({ url: '/', method: 'GET' }, {}, done); + route.dispatch(req, {}, done); }); }) }) From ab8d116f4289bc7c3c1936df1825b3d26caa8738 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Jul 2014 18:17:31 -0400 Subject: [PATCH 0430/1265] tests: bail on failed test for developer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 728522e8aef..f3a96c3074a 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ }, "scripts": { "prepublish": "npm prune", - "test": "mocha --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", + "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" } From 1a9a837c45a66ee0ea95362cbb077388a3df33dc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 25 Jul 2014 20:26:11 -0400 Subject: [PATCH 0431/1265] 4.7.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 05d0f6d1b2b..eff780c4dfb 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.7.0 / 2014-07-25 +================== * fix `req.protocol` for proxy-direct connections * configurable query parser with `app.set('query parser', parser)` diff --git a/package.json b/package.json index f3a96c3074a..fb44aad2a0d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.6.1", + "version": "4.7.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From e7a3fbaf48502341d6317b53d553628c92cc192f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 17:30:13 -0400 Subject: [PATCH 0432/1265] deps: connect@2.24.1 --- History.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 353d8cb9780..0961e4cdd2c 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,14 @@ +3.x +=== + + * deps: connect@2.24.1 + - deps: body-parser@~1.5.0 + - deps: depd@0.4.3 + - deps: express-session@~1.7.1 + - deps: morgan@~1.2.1 + - deps: serve-index@~1.1.4 + - deps: serve-static@~1.4.1 + 3.15.0 / 2014-07-22 =================== diff --git a/package.json b/package.json index 2a36da5c2c4..1d1dca3a4b4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.24.0", + "connect": "2.24.1", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.2", From e49d0dc9e3abcd094884064ad152cbc7ce9d6f68 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 17:31:22 -0400 Subject: [PATCH 0433/1265] deps: depd@0.4.3 fixes #2262 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0961e4cdd2c..1bf67fd7da3 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ - deps: morgan@~1.2.1 - deps: serve-index@~1.1.4 - deps: serve-static@~1.4.1 + * deps: depd@0.4.3 + - Fix exception when global `Error.stackTraceLimit` is too low 3.15.0 / 2014-07-22 =================== diff --git a/package.json b/package.json index 1d1dca3a4b4..c4ef08bea5b 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "connect": "2.24.1", "commander": "1.3.2", "debug": "1.0.4", - "depd": "0.4.2", + "depd": "0.4.3", "escape-html": "1.0.1", "media-typer": "0.2.0", "methods": "1.1.0", From f724730e1ab259a66f6a0445161261555b6d733f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 17:33:12 -0400 Subject: [PATCH 0434/1265] Adjust wording on deprecation messages --- History.md | 6 +++--- lib/request.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 1bf67fd7da3..b9728664019 100644 --- a/History.md +++ b/History.md @@ -114,8 +114,8 @@ * deprecate things with `depd` module * deps: buffer-crc32@0.2.3 * deps: connect@2.20.2 - - deprecate `verify` option to `json` -- use `body-parser` module directly - - deprecate `verify` option to `urlencoded` -- use `body-parser` module directly + - deprecate `verify` option to `json` -- use `body-parser` npm module instead + - deprecate `verify` option to `urlencoded` -- use `body-parser` npm module instead - deprecate things with `depd` module - use `finalhandler` for final response handling - use `media-typer` to parse `content-type` for charset @@ -189,7 +189,7 @@ =================== * deps: connect@2.19.1 - - deprecate `methodOverride()` -- use `method-override` module directly + - deprecate `methodOverride()` -- use `method-override` npm module instead - deps: body-parser@1.3.0 - deps: method-override@2.0.1 - deps: multiparty@3.2.8 diff --git a/lib/request.js b/lib/request.js index 35c48a77dbf..03f7cbdabba 100644 --- a/lib/request.js +++ b/lib/request.js @@ -427,7 +427,7 @@ req.__defineGetter__('ips', function(){ */ req.__defineGetter__('auth', function(){ - deprecate('req.auth: Use basic-auth module directly'); + deprecate('req.auth: Use basic-auth npm module instead'); // credentials var creds = auth(this); From edaabe66cf180b49919e772bba2150666c54251e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 17:34:29 -0400 Subject: [PATCH 0435/1265] deps: send@0.7.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b9728664019..e5759dad2e3 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,8 @@ - deps: serve-static@~1.4.1 * deps: depd@0.4.3 - Fix exception when global `Error.stackTraceLimit` is too low + * deps: send@0.7.1 + - deps: depd@0.4.3 3.15.0 / 2014-07-22 =================== diff --git a/package.json b/package.json index c4ef08bea5b..e335db7e617 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.2.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.7.0", + "send": "0.7.1", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From afea3c0ae88a1c304fb4d424d02220a6538aff26 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 17:35:00 -0400 Subject: [PATCH 0436/1265] deps: mocha@~1.21.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e335db7e617..81ab0b022eb 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "devDependencies": { "istanbul": "0.3.0", - "mocha": "~1.20.0", + "mocha": "~1.21.0", "should": "~4.0.0", "ejs": "~1.0.0", "jade": "~1.3.1", From 9f4968aaa3db6d9fe94be83f95d354be86812aee Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 17:42:18 -0400 Subject: [PATCH 0437/1265] 3.15.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index e5759dad2e3..86274b90c22 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.15.1 / 2014-07-26 +=================== * deps: connect@2.24.1 - deps: body-parser@~1.5.0 diff --git a/package.json b/package.json index 81ab0b022eb..b87d69b2ae1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.15.0", + "version": "3.15.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 65f67e2ec0f846338766c9e334a4fe45c8f83b8b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 18:08:02 -0400 Subject: [PATCH 0438/1265] deps: serve-static@~1.4.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7751effbcac..5f602445e7d 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased - Fix exception when global `Error.stackTraceLimit` is too low * deps: send@0.7.1 - deps: depd@0.4.3 + * deps: serve-static@~1.4.1 4.7.0 / 2014-07-25 ================== diff --git a/package.json b/package.json index 6382648f2a4..0cc47847bb3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.7.1", - "serve-static": "~1.4.0", + "serve-static": "~1.4.1", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 8858f20d9399d6eeb01e70475c58bb1da9eb3ef4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 26 Jul 2014 18:53:26 -0400 Subject: [PATCH 0439/1265] 4.7.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 5f602445e7d..00bae2ef2c0 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.7.1 / 2014-07-26 +================== * deps: depd@0.4.3 - Fix exception when global `Error.stackTraceLimit` is too low diff --git a/package.json b/package.json index 0cc47847bb3..0f5a81a21c0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.7.0", + "version": "4.7.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 06e7685d65581e03c6572ba8cb4eadaab4750d4b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 27 Jul 2014 15:40:19 -0400 Subject: [PATCH 0440/1265] deps: connect@2.24.2 --- History.md | 12 +++++++++++- package.json | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 86274b90c22..80960e91b61 100644 --- a/History.md +++ b/History.md @@ -1,8 +1,18 @@ +3.x +=== + + * deps: connect@2.24.2 + - deps: body-parser@~1.5.2 + - deps: depd@0.4.4 + - deps: express-session@~1.7.2 + - deps: morgan@~1.2.2 + - deps: serve-static@~1.4.2 + 3.15.1 / 2014-07-26 =================== * deps: connect@2.24.1 - - deps: body-parser@~1.5.0 + - deps: body-parser@~1.5.1 - deps: depd@0.4.3 - deps: express-session@~1.7.1 - deps: morgan@~1.2.1 diff --git a/package.json b/package.json index b87d69b2ae1..018032a6e2f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.24.1", + "connect": "2.24.2", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.3", From baf8b14a71885f6255b2fc484b33440a0f0613d9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 27 Jul 2014 15:41:19 -0400 Subject: [PATCH 0441/1265] deps: depd@0.4.4 fixes #2262 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 80960e91b61..046270241d9 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ - deps: express-session@~1.7.2 - deps: morgan@~1.2.2 - deps: serve-static@~1.4.2 + * deps: depd@0.4.4 + - Work-around v8 generating empty stack traces 3.15.1 / 2014-07-26 =================== diff --git a/package.json b/package.json index 018032a6e2f..983cce1f5ad 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "connect": "2.24.2", "commander": "1.3.2", "debug": "1.0.4", - "depd": "0.4.3", + "depd": "0.4.4", "escape-html": "1.0.1", "media-typer": "0.2.0", "methods": "1.1.0", From 819265c7ae8c6731a4cea1c887d729fe0e9c2e9a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 27 Jul 2014 15:41:54 -0400 Subject: [PATCH 0442/1265] deps: send@0.7.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 046270241d9..b5331aee2c9 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,8 @@ - deps: serve-static@~1.4.2 * deps: depd@0.4.4 - Work-around v8 generating empty stack traces + * deps: send@0.7.2 + - deps: depd@0.4.4 3.15.1 / 2014-07-26 =================== diff --git a/package.json b/package.json index 983cce1f5ad..00368c9d190 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.2.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.7.1", + "send": "0.7.2", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From 696e150f0ab7b11fd7a58832809f2f6393c74186 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 27 Jul 2014 15:53:45 -0400 Subject: [PATCH 0443/1265] 3.15.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b5331aee2c9..26f9d218eb1 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.15.2 / 2014-07-27 +=================== * deps: connect@2.24.2 - deps: body-parser@~1.5.2 diff --git a/package.json b/package.json index 00368c9d190..0fb201d86f7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.15.1", + "version": "3.15.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 0ee4dd82b5a8f0e116fe8d421e207973989a3596 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 27 Jul 2014 15:59:19 -0400 Subject: [PATCH 0444/1265] deps: serve-static@~1.4.2 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ea96f615b82..e370ed4a2a5 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased - Work-around v8 generating empty stack traces * deps: send@0.7.2 - deps: depd@0.4.4 + * deps: serve-static@~1.4.2 4.7.1 / 2014-07-26 ================== diff --git a/package.json b/package.json index 1cb37475b9d..e0483918f70 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.7.2", - "serve-static": "~1.4.1", + "serve-static": "~1.4.2", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 54d3ffa9a0e987bf3eee2d0d715fdb1fb8619832 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 27 Jul 2014 16:00:17 -0400 Subject: [PATCH 0445/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e0483918f70..1f106b3bac2 100644 --- a/package.json +++ b/package.json @@ -59,12 +59,12 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.5.0", + "body-parser": "~1.5.2", "cookie-parser": "~1.3.1", - "express-session": "~1.7.0", + "express-session": "~1.7.2", "jade": "~1.5.0", "method-override": "~2.1.1", - "morgan": "~1.2.0", + "morgan": "~1.2.2", "multiparty": "~3.3.1", "vhost": "2.0.0" }, From 1854a5d35f28aad84fd47d7484b3d5afd171be88 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 27 Jul 2014 16:00:54 -0400 Subject: [PATCH 0446/1265] 4.7.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index e370ed4a2a5..ad56b365af0 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.7.2 / 2014-07-27 +================== * deps: depd@0.4.4 - Work-around v8 generating empty stack traces diff --git a/package.json b/package.json index 1f106b3bac2..b261d8dc36c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.7.1", + "version": "4.7.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From d8df26680ffb7095f1204946b39d6b9432bc4f2b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 16:10:32 -0400 Subject: [PATCH 0447/1265] deps: send@0.7.3 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ad56b365af0..b836d22315f 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: send@0.7.3 + - Fix incorrect 403 on Windows and Node.js 0.11 + 4.7.2 / 2014-07-27 ================== diff --git a/package.json b/package.json index b261d8dc36c..ba7cb0a5b12 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.7.2", + "send": "0.7.3", "serve-static": "~1.4.2", "type-is": "~1.3.2", "vary": "0.1.0", From 112bc92d78c9cd2d013b8f01839b201eef9d8904 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 16:11:52 -0400 Subject: [PATCH 0448/1265] deps: serve-static@~1.4.3 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b836d22315f..4d4b36a4b49 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,9 @@ unreleased * deps: send@0.7.3 - Fix incorrect 403 on Windows and Node.js 0.11 + * deps: serve-static@~1.4.3 + - Fix incorrect 403 on Windows and Node.js 0.11 + - deps: send@0.7.3 4.7.2 / 2014-07-27 ================== diff --git a/package.json b/package.json index ba7cb0a5b12..ff8dca71d73 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.7.3", - "serve-static": "~1.4.2", + "serve-static": "~1.4.3", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 52775a52ad9e00fbd38056af6ed0cddb4286d3d2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 16:14:29 -0400 Subject: [PATCH 0449/1265] 4.7.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 4d4b36a4b49..83aafc258cd 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.7.3 / 2014-08-04 +================== * deps: send@0.7.3 - Fix incorrect 403 on Windows and Node.js 0.11 diff --git a/package.json b/package.json index ff8dca71d73..543403fb4d5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.7.2", + "version": "4.7.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From df413a41f3bde919ece284c52a61bbe038728755 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 17:14:32 -0400 Subject: [PATCH 0450/1265] deps: serve-static@~1.4.4 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 83aafc258cd..8c83d5e47e2 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: serve-static@~1.4.4 + - deps: send@0.7.4 + 4.7.3 / 2014-08-04 ================== diff --git a/package.json b/package.json index 543403fb4d5..681d40df035 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.7.3", - "serve-static": "~1.4.3", + "serve-static": "~1.4.4", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 767db01b7954a9cc6b6ccea769ccc0072de85f4f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 17:26:43 -0400 Subject: [PATCH 0451/1265] deps: connect@2.24.3 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 26f9d218eb1..7b74aa2f8d7 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.24.3 + - deps: serve-index@~1.1.5 + - deps: serve-static@~1.4.4 + 3.15.2 / 2014-07-27 =================== diff --git a/package.json b/package.json index 0fb201d86f7..25911bfbe77 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.24.2", + "connect": "2.24.3", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From e8b471ff4f8511209cdc9c4d7da62469a4a8e9a2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 17:09:48 -0400 Subject: [PATCH 0452/1265] fix res.sendfile regression for serving directory index files --- History.md | 4 ++++ package.json | 2 +- test/fixtures/blog/index.html | 1 + test/res.sendfile.js | 24 ++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/blog/index.html diff --git a/History.md b/History.md index 7b74aa2f8d7..67bd5eaf98a 100644 --- a/History.md +++ b/History.md @@ -1,9 +1,13 @@ 3.x === + * fix `res.sendfile` regression for serving directory index files * deps: connect@2.24.3 - deps: serve-index@~1.1.5 - deps: serve-static@~1.4.4 + * deps: send@0.7.4 + - Fix incorrect 403 on Windows and Node.js 0.11 + - Fix serving index files without root dir 3.15.2 / 2014-07-27 =================== diff --git a/package.json b/package.json index 25911bfbe77..b51c2d0fc5c 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.2.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.7.2", + "send": "0.7.4", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", diff --git a/test/fixtures/blog/index.html b/test/fixtures/blog/index.html new file mode 100644 index 00000000000..bcc6b1822ff --- /dev/null +++ b/test/fixtures/blog/index.html @@ -0,0 +1 @@ +index \ No newline at end of file diff --git a/test/res.sendfile.js b/test/res.sendfile.js index 27ffba69865..24ee88a31da 100644 --- a/test/res.sendfile.js +++ b/test/res.sendfile.js @@ -130,6 +130,30 @@ describe('res', function(){ .expect(200, 'tobi', done); }) + it('should transfer a file', function (done) { + var app = express(); + + app.use(function (req, res) { + res.sendfile('test/fixtures/name.txt'); + }); + + request(app) + .get('/') + .expect(200, 'tobi', done); + }); + + it('should transfer a directory index file', function (done) { + var app = express(); + + app.use(function (req, res) { + res.sendfile('test/fixtures/blog/'); + }); + + request(app) + .get('/') + .expect(200, 'index', done); + }); + describe('with an absolute path', function(){ it('should transfer the file', function(done){ var app = express(); From 15590d75b26f1e4b95b565f8306c763ee860d3e2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 17:31:52 -0400 Subject: [PATCH 0453/1265] 3.15.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 67bd5eaf98a..01bb244c235 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.15.3 / 2014-08-04 +=================== * fix `res.sendfile` regression for serving directory index files * deps: connect@2.24.3 diff --git a/package.json b/package.json index b51c2d0fc5c..3fdc0036c29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.15.2", + "version": "3.15.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From b886eb52cf955c2f29ad31b514607d4e38c1dbaf Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 17:36:37 -0400 Subject: [PATCH 0454/1265] 4.7.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index c7735d41802..c82e97a937b 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.7.4 / 2014-08-04 +================== * fix `res.sendfile` regression for serving directory index files * deps: send@0.7.4 diff --git a/package.json b/package.json index 10156dcf97a..460c2e89f00 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.7.3", + "version": "4.7.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 12e070e39ad98597e9875491055b5d2edde26ba8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Aug 2014 15:34:24 -0400 Subject: [PATCH 0455/1265] tests: add encoding tests for res.sendfile --- test/fixtures/% of dogs.txt | 1 + test/res.sendfile.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/fixtures/% of dogs.txt diff --git a/test/fixtures/% of dogs.txt b/test/fixtures/% of dogs.txt new file mode 100644 index 00000000000..3a4d1342e8b --- /dev/null +++ b/test/fixtures/% of dogs.txt @@ -0,0 +1 @@ +20% \ No newline at end of file diff --git a/test/res.sendfile.js b/test/res.sendfile.js index 58755ede59d..c6e2fce9927 100644 --- a/test/res.sendfile.js +++ b/test/res.sendfile.js @@ -189,6 +189,18 @@ describe('res', function(){ .expect(200, 'index', done); }); + it('should transfer a file with urlencoded name', function (done) { + var app = express(); + + app.use(function (req, res) { + res.sendfile('test/fixtures/%25%20of%20dogs.txt'); + }); + + request(app) + .get('/') + .expect(200, '20%', done); + }); + describe('with an absolute path', function(){ it('should transfer the file', function(done){ var app = express(); From b24ed1587829185bc5b3ca702807dc40f17872db Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:35:00 -0400 Subject: [PATCH 0456/1265] deps: connect@2.25.0 --- History.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 01bb244c235..b8d52ddad1c 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,14 @@ +3.x +=== + + * deps: connect@2.25.0 + - deps: body-parser@~1.6.0 + - deps: compression@~1.0.10 + - deps: csurf@~1.4.0 + - deps: express-session@~1.7.4 + - deps: qs@1.0.2 + - deps: serve-static@~1.5.0 + 3.15.3 / 2014-08-04 =================== diff --git a/package.json b/package.json index 3fdc0036c29..612507d6738 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.24.3", + "connect": "2.25.0", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 0e42a37edd5b7dd2b66a1ca62927384dfbab4303 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:37:13 -0400 Subject: [PATCH 0457/1265] deps: send@0.8.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b8d52ddad1c..0c22683a3d4 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ - deps: express-session@~1.7.4 - deps: qs@1.0.2 - deps: serve-static@~1.5.0 + * deps: send@0.8.1 + - Add `extensions` option 3.15.3 / 2014-08-04 =================== diff --git a/package.json b/package.json index 612507d6738..6bb519e1512 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.2.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.7.4", + "send": "0.8.1", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From b6c5b0511f5a2e6f2da8d5b371d30618e1616327 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:37:58 -0400 Subject: [PATCH 0458/1265] deps: jade@~1.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6bb519e1512..6c6465e3536 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "mocha": "~1.21.0", "should": "~4.0.0", "ejs": "~1.0.0", - "jade": "~1.3.1", + "jade": "~1.5.0", "hjs": "~0.0.6", "marked": "0.3.2", "connect-redis": "~1.4.5", From 19fd6f85b0d534930352f263bf2b15fe288237e5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:39:12 -0400 Subject: [PATCH 0459/1265] deps: connect-redis@~1.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c6465e3536..2a81ff6f47e 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "merge-descriptors": "0.0.2" }, "devDependencies": { + "connect-redis": "~1.5.0", "istanbul": "0.3.0", "mocha": "~1.21.0", "should": "~4.0.0", @@ -53,7 +54,6 @@ "jade": "~1.5.0", "hjs": "~0.0.6", "marked": "0.3.2", - "connect-redis": "~1.4.5", "supertest": "~0.13.0" }, "engines": { From c652cf7eedc3f4b9eb6de6c1c8c31fcf33f33c85 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:40:46 -0400 Subject: [PATCH 0460/1265] 3.16.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 0c22683a3d4..3b0306e578b 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.0 / 2014-08-05 +=================== * deps: connect@2.25.0 - deps: body-parser@~1.6.0 diff --git a/package.json b/package.json index 2a81ff6f47e..a7243182b04 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.15.3", + "version": "3.16.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 7d0f1c3db9d467e68e2ecb59e2d97e647ca99e8b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:57:15 -0400 Subject: [PATCH 0461/1265] deps: serve-static@~1.5.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d1f19a40e9a..13868283338 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,9 @@ unreleased * deps: send@0.8.1 - Add `extensions` option + * deps: serve-static@~1.5.0 + - Add `extensions` option + - deps: send@0.8.1 4.7.4 / 2014-08-04 ================== diff --git a/package.json b/package.json index 336ae236b7e..d815814767c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.8.1", - "serve-static": "~1.4.4", + "serve-static": "~1.5.0", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 1168d0bb8b787bd3a132e605be9c81f207fe2b3f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:58:32 -0400 Subject: [PATCH 0462/1265] deps: qs@1.0.2 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 13868283338..1ea2930a3a6 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,11 @@ unreleased ========== + * deps: qs@1.0.2 + - Complete rewrite + - Limits array length to 20 + - Limits object depth to 5 + - Limits parameters to 1,000 * deps: send@0.8.1 - Add `extensions` option * deps: serve-static@~1.5.0 diff --git a/package.json b/package.json index d815814767c..a2691339a83 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "parseurl": "~1.2.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", + "qs": "1.0.2", "range-parser": "1.0.0", "send": "0.8.1", "serve-static": "~1.5.0", @@ -46,7 +47,6 @@ "fresh": "0.2.2", "cookie-signature": "1.0.4", "merge-descriptors": "0.0.2", - "qs": "0.6.6", "utils-merge": "1.0.0" }, "devDependencies": { From 7e32fa1be647515c183d0ef831c391c66f25e69c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 01:59:09 -0400 Subject: [PATCH 0463/1265] deps: update example dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a2691339a83..6ef39435ea5 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.5.2", + "body-parser": "~1.6.0", "cookie-parser": "~1.3.1", "express-session": "~1.7.2", "jade": "~1.5.0", From 2cb029f896dff3a488dfd0c745997183525b8c05 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 02:09:25 -0400 Subject: [PATCH 0464/1265] Add res.sendFile fixes #1906 closes #2266 --- History.md | 3 + lib/response.js | 118 ++++++++++++++++ test/{res.sendfile.js => res.sendFile.js} | 159 ++++++++++++++++++++++ 3 files changed, 280 insertions(+) rename test/{res.sendfile.js => res.sendFile.js} (65%) diff --git a/History.md b/History.md index 1ea2930a3a6..d283004df61 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,9 @@ unreleased ========== + * add `res.sendFile` + - accepts a file system path instead of a URL + - requires an absolute path or `root` option specified * deps: qs@1.0.2 - Complete rewrite - Limits array length to 20 diff --git a/lib/response.js b/lib/response.js index eff48d74100..ec44796fe5c 100644 --- a/lib/response.js +++ b/lib/response.js @@ -5,6 +5,7 @@ var deprecate = require('depd')('express'); var escapeHtml = require('escape-html'); var http = require('http'); +var isAbsolute = require('./utils').isAbsolute; var path = require('path'); var mixin = require('utils-merge'); var sign = require('cookie-signature').sign; @@ -301,6 +302,123 @@ res.jsonp = function jsonp(obj) { return this.send(body); }; +/** + * Transfer the file at the given `path`. + * + * Automatically sets the _Content-Type_ response header field. + * The callback `fn(err)` is invoked when the transfer is complete + * or when an error occurs. Be sure to check `res.sentHeader` + * if you wish to attempt responding, as the header and some data + * may have already been transferred. + * + * Options: + * + * - `maxAge` defaulting to 0 (can be string converted by `ms`) + * - `root` root directory for relative filenames + * - `headers` object of headers to serve with file + * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them + * + * Other options are passed along to `send`. + * + * Examples: + * + * The following example illustrates how `res.sendFile()` may + * be used as an alternative for the `static()` middleware for + * dynamic situations. The code backing `res.sendFile()` is actually + * the same code, so HTTP cache support etc is identical. + * + * app.get('/user/:uid/photos/:file', function(req, res){ + * var uid = req.params.uid + * , file = req.params.file; + * + * req.user.mayViewFilesFrom(uid, function(yes){ + * if (yes) { + * res.sendFile('/uploads/' + uid + '/' + file); + * } else { + * res.send(403, 'Sorry! you cant see that.'); + * } + * }); + * }); + * + * @api public + */ + +res.sendFile = function sendFile(path, options, fn) { + var done; + var req = this.req; + var next = req.next; + + if (!path) { + throw new TypeError('path argument is required to res.sendFile'); + } + + // support function as second arg + if (typeof options === 'function') { + fn = options; + options = {}; + } + + options = options || {}; + + if (!options.root && !isAbsolute(path)) { + throw new TypeError('path must be absolute or specify root to res.sendFile'); + } + + // socket errors + req.socket.on('error', onerror); + + // errors + function onerror(err) { + if (done) return; + done = true; + + // clean up + cleanup(); + + // callback available + if (fn) return fn(err); + + // delegate + next(err); + } + + // streaming + function onstream(stream) { + if (done) return; + cleanup(); + if (fn) stream.on('end', fn); + } + + // cleanup + function cleanup() { + req.socket.removeListener('error', onerror); + } + + // transfer + var pathname = encodeURI(path); + var file = send(req, pathname, options); + file.on('error', onerror); + file.on('directory', next); + file.on('stream', onstream); + + if (options.headers) { + // set headers on successful transfer + file.on('headers', function headers(res) { + var obj = options.headers; + var keys = Object.keys(obj); + + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + res.setHeader(k, obj[k]); + } + }); + } + + // pipe + file.pipe(this); + this.on('finish', cleanup); +}; + /** * Transfer the file at the given `path`. * diff --git a/test/res.sendfile.js b/test/res.sendFile.js similarity index 65% rename from test/res.sendfile.js rename to test/res.sendFile.js index c6e2fce9927..b9e6007833b 100644 --- a/test/res.sendfile.js +++ b/test/res.sendFile.js @@ -1,9 +1,158 @@ +var after = require('after'); var express = require('../') , request = require('supertest') , assert = require('assert'); +var path = require('path'); +var should = require('should'); +var fixtures = path.join(__dirname, 'fixtures'); describe('res', function(){ + describe('.sendFile(path)', function () { + it('should transfer a file', function (done) { + var app = createApp(path.resolve(fixtures, 'name.txt')); + + request(app) + .get('/') + .expect(200, 'tobi', done); + }); + + it('should transfer a file with special characters in string', function (done) { + var app = createApp(path.resolve(fixtures, '% of dogs.txt')); + + request(app) + .get('/') + .expect(200, '20%', done); + }); + + it('should 404 when not found', function (done) { + var app = createApp(path.resolve(fixtures, 'does-no-exist')); + + app.use(function (req, res) { + res.statusCode = 200; + res.send('no!'); + }); + + request(app) + .get('/') + .expect(404, done); + }); + + it('should not override manual content-types', function (done) { + var app = express(); + + app.use(function (req, res) { + res.contentType('application/x-bogus'); + res.sendFile(path.resolve(fixtures, 'name.txt')); + }); + + request(app) + .get('/') + .expect('Content-Type', 'application/x-bogus') + .end(done); + }) + + describe('with "dotfiles" option', function () { + it('should not serve dotfiles by default', function (done) { + var app = createApp(path.resolve(__dirname, 'fixtures/.name')); + + request(app) + .get('/') + .expect(404, done); + }); + + it('should accept dotfiles option', function(done){ + var app = createApp(path.resolve(__dirname, 'fixtures/.name'), { dotfiles: 'allow' }); + + request(app) + .get('/') + .expect(200, 'tobi', done); + }); + }); + + describe('with "headers" option', function () { + it('should accept headers option', function (done) { + var headers = { + 'x-success': 'sent', + 'x-other': 'done' + }; + var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), { headers: headers }); + + request(app) + .get('/') + .expect('x-success', 'sent') + .expect('x-other', 'done') + .expect(200, done); + }); + + it('should ignore headers option on 404', function (done) { + var headers = { 'x-success': 'sent' }; + var app = createApp(path.resolve(__dirname, 'fixtures/does-not-exist'), { headers: headers }); + + request(app) + .get('/') + .expect(404, function (err, res) { + if (err) return done(err); + res.headers.should.not.have.property('x-success'); + done(); + }); + }); + }); + + describe('with "root" option', function () { + it('should not transfer relative with without', function (done) { + var app = createApp('test/fixtures/name.txt'); + + request(app) + .get('/') + .expect(500, /must be absolute/, done); + }) + + it('should serve relative to "root"', function (done) { + var app = createApp('name.txt', {root: fixtures}); + + request(app) + .get('/') + .expect(200, 'tobi', done); + }) + + it('should disallow requesting out of "root"', function (done) { + var app = createApp('foo/../../user.html', {root: fixtures}); + + request(app) + .get('/') + .expect(403, done); + }) + }) + }) + + describe('.sendFile(path, fn)', function () { + it('should invoke the callback when complete', function (done) { + var cb = after(2, done); + var app = createApp(path.resolve(fixtures, 'name.txt'), cb); + + request(app) + .get('/') + .expect(200, cb); + }) + + it('should invoke the callback on 404', function(done){ + var app = express(); + + app.use(function (req, res) { + res.sendFile(path.resolve(fixtures, 'does-not-exist'), function (err) { + should(err).be.ok; + err.status.should.equal(404); + res.send('got it'); + }); + }); + + request(app) + .get('/') + .expect(200, 'got it', done); + }) + }) + describe('.sendfile(path, fn)', function(){ it('should invoke the callback when complete', function(done){ var app = express(); @@ -331,3 +480,13 @@ describe('res', function(){ }) }) }) + +function createApp(path, options, fn) { + var app = express(); + + app.use(function (req, res) { + res.sendFile(path, options, fn); + }); + + return app; +} From 8449f23f0d74b0f3159f8652a6bc019cb3678847 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 02:27:16 -0400 Subject: [PATCH 0465/1265] Deprecate res.sendfile --- History.md | 1 + lib/response.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/History.md b/History.md index d283004df61..3c3bf8a53c5 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * add `res.sendFile` - accepts a file system path instead of a URL - requires an absolute path or `root` option specified + * deprecate `res.sendfile` -- use `res.sendFile` instead * deps: qs@1.0.2 - Complete rewrite - Limits array length to 20 diff --git a/lib/response.js b/lib/response.js index ec44796fe5c..30cd4004c09 100644 --- a/lib/response.js +++ b/lib/response.js @@ -528,6 +528,9 @@ res.sendfile = function(path, options, fn){ this.on('finish', cleanup); }; +res.sendfile = deprecate.function(res.sendfile, + 'res.sendfile: Use res.sendFile instead'); + /** * Transfer the file at the given `path` as an attachment. * From 17cea29013c64b169e3fa8ddde903e05ce533ab0 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Sat, 2 Aug 2014 11:41:35 +0200 Subject: [PATCH 0466/1265] Support mounted app as any argument to app.use() fixes #2277 --- History.md | 1 + lib/application.js | 60 ++++++++++++++++++++++++---------------------- test/app.use.js | 40 ++++++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 29 deletions(-) diff --git a/History.md b/History.md index 3c3bf8a53c5..96b64966b9e 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased - accepts a file system path instead of a URL - requires an absolute path or `root` option specified * deprecate `res.sendfile` -- use `res.sendFile` instead + * support mounted app as any argument to `app.use()` * deps: qs@1.0.2 - Complete rewrite - Limits array length to 20 diff --git a/lib/application.js b/lib/application.js index b8b69c0670b..2214bf6c1f3 100644 --- a/lib/application.js +++ b/lib/application.js @@ -3,6 +3,7 @@ */ var finalhandler = require('finalhandler'); +var flatten = require('./utils').flatten; var mixin = require('utils-merge'); var Router = require('./router'); var methods = require('methods'); @@ -16,6 +17,7 @@ var compileQueryParser = require('./utils').compileQueryParser; var compileTrust = require('./utils').compileTrust; var deprecate = require('depd')('express'); var resolve = require('path').resolve; +var slice = Array.prototype.slice; /** * Application prototype. @@ -149,34 +151,41 @@ app.handle = function(req, res, done) { * @api public */ -app.use = function use(path, fn) { - var mount_app; - var mount_path; - - // check for .use(path, app) or .use(app) signature - if (arguments.length <= 2) { - mount_path = typeof path === 'string' - ? path - : '/'; - mount_app = typeof path === 'function' - ? path - : fn; +app.use = function use(fn) { + var offset = 0; + var path = '/'; + var self = this; + + // default path to '/' + if (typeof fn !== 'function') { + offset = 1; + path = fn; + } + + var fns = flatten(slice.call(arguments, offset)); + + if (fns.length === 0) { + throw new TypeError('app.use() requires middleware functions'); } // setup router this.lazyrouter(); var router = this._router; - // express app - if (mount_app && mount_app.handle && mount_app.set) { - debug('.use app under %s', mount_path); - mount_app.mountpath = mount_path; - mount_app.parent = this; + fns.forEach(function (fn) { + // non-express app + if (!fn || !fn.handle || !fn.set) { + return router.use(path, fn); + } + + debug('.use app under %s', path); + fn.mountpath = path; + fn.parent = self; // restore .app property on req and res - router.use(mount_path, function mounted_app(req, res, next) { + router.use(path, function mounted_app(req, res, next) { var orig = req.app; - mount_app.handle(req, res, function(err) { + fn.handle(req, res, function (err) { req.__proto__ = orig.request; res.__proto__ = orig.response; next(err); @@ -184,13 +193,8 @@ app.use = function use(path, fn) { }); // mounted an app - mount_app.emit('mount', this); - - return this; - } - - // pass-through use - router.use.apply(router, arguments); + fn.emit('mount', self); + }); return this; }; @@ -414,7 +418,7 @@ methods.forEach(function(method){ this.lazyrouter(); var route = this._router.route(path); - route[method].apply(route, [].slice.call(arguments, 1)); + route[method].apply(route, slice.call(arguments, 1)); return this; }; }); @@ -433,7 +437,7 @@ app.all = function(path){ this.lazyrouter(); var route = this._router.route(path); - var args = [].slice.call(arguments, 1); + var args = slice.call(arguments, 1); methods.forEach(function(method){ route[method].apply(route, args); }); diff --git a/test/app.use.js b/test/app.use.js index 681a6a911de..ee237c88507 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -18,7 +18,7 @@ describe('app', function(){ it('should reject missing functions', function(){ var app = express(); - app.use.bind(app, 3).should.throw(/requires callback function/); + app.use.bind(app, 3).should.throw(/requires middleware function/); }) describe('.use(app)', function(){ @@ -84,6 +84,44 @@ describe('app', function(){ .get('/post/once-upon-a-time') .expect('success', done); }) + + it('should support mounted app anywhere', function(done){ + var cb = after(3, done); + var blog = express() + , other = express() + , app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + blog.get('/', function(req, res){ + res.end('success'); + }); + + blog.once('mount', function (parent) { + parent.should.equal(app); + cb(); + }); + other.once('mount', function (parent) { + parent.should.equal(app); + cb(); + }); + + app.use('/post/:article', fn1, other, fn2, blog); + + request(app) + .get('/post/once-upon-a-time') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('success', cb); + }) }) describe('.use(middleware)', function(){ From 4aea02310ad7738fb1b3bac08de5424d82bfe4c6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 02:50:59 -0400 Subject: [PATCH 0467/1265] 4.8.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 96b64966b9e..347d24f5e82 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.0 / 2014-08-05 +================== * add `res.sendFile` - accepts a file system path instead of a URL diff --git a/package.json b/package.json index 6ef39435ea5..718ef05713d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.7.4", + "version": "4.8.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 1150ca7264fe868a7685302987edb5bb564b0faf Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 17:48:36 -0400 Subject: [PATCH 0468/1265] Fix incorrect deprecation warnings on res.download fixes #2284 --- History.md | 5 +++++ lib/response.js | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 347d24f5e82..b89ac19c918 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * fix incorrect deprecation warnings on `res.download` + 4.8.0 / 2014-08-05 ================== diff --git a/lib/response.js b/lib/response.js index 30cd4004c09..e929291da39 100644 --- a/lib/response.js +++ b/lib/response.js @@ -19,6 +19,7 @@ var send = require('send'); var basename = path.basename; var extname = path.extname; var mime = send.mime; +var resolve = path.resolve; var vary = require('vary'); /** @@ -544,9 +545,9 @@ res.sendfile = deprecate.function(res.sendfile, * @api public */ -res.download = function(path, filename, fn){ +res.download = function download(path, filename, fn) { // support function as second arg - if ('function' == typeof filename) { + if (typeof filename === 'function') { fn = filename; filename = null; } @@ -558,7 +559,10 @@ res.download = function(path, filename, fn){ 'Content-Disposition': contentDisposition(filename) }; - return this.sendfile(path, { headers: headers }, fn); + // Resolve the full path for sendFile + var fullPath = resolve(path); + + return this.sendFile(fullPath, { headers: headers }, fn); }; /** From a3b5adcf4aa5bd7df9a0ebc2c870c02bec764ad0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 17:50:08 -0400 Subject: [PATCH 0469/1265] deps: qs@1.1.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b89ac19c918..c7b3603a2d1 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,9 @@ unreleased ========== * fix incorrect deprecation warnings on `res.download` + * deps: qs@1.1.0 + - Accept urlencoded square brackets + - Accept empty values in implicit array notation 4.8.0 / 2014-08-05 ================== diff --git a/package.json b/package.json index 718ef05713d..664a3b560f2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "parseurl": "~1.2.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", - "qs": "1.0.2", + "qs": "1.1.0", "range-parser": "1.0.0", "send": "0.8.1", "serve-static": "~1.5.0", From 7f606ebf29f3a0d5fdad8de77f26d757dfb83022 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 18:05:50 -0400 Subject: [PATCH 0470/1265] deps: connect@2.25.1 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3b0306e578b..3aa1ef5d38f 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.25.1 + - deps: body-parser@~1.6.1 + - deps: qs@1.1.0 + 3.16.0 / 2014-08-05 =================== diff --git a/package.json b/package.json index a7243182b04..0d8cdb324a6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.0", + "connect": "2.25.1", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 0bd6c311cffc79e5ed14434604c4fb19541378a0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 18:06:19 -0400 Subject: [PATCH 0471/1265] deps: mocha@~1.21.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d8cdb324a6..edf7d31a57d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "devDependencies": { "connect-redis": "~1.5.0", "istanbul": "0.3.0", - "mocha": "~1.21.0", + "mocha": "~1.21.4", "should": "~4.0.0", "ejs": "~1.0.0", "jade": "~1.5.0", From ea427c1bb4667be345d786c5120c435dbca3d13a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 18:07:31 -0400 Subject: [PATCH 0472/1265] 3.16.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 3aa1ef5d38f..546e4a0de9e 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.1 / 2014-08-06 +=================== * deps: connect@2.25.1 - deps: body-parser@~1.6.1 diff --git a/package.json b/package.json index edf7d31a57d..3a3eb89cf17 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.0", + "version": "3.16.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 4f5b27dd81e15f4d6c8dc551b2d5bd3757579a23 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 18:10:32 -0400 Subject: [PATCH 0473/1265] deps: update example dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 55a1ef9f3fd..8d516dcd5cb 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.6.0", + "body-parser": "~1.6.1", "cookie-parser": "~1.3.1", "express-session": "~1.7.2", "jade": "~1.5.0", From e8f8ea7e05c27eb10286ec62a5f4df533deeeff8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 18:13:54 -0400 Subject: [PATCH 0474/1265] docs: update examples for deprecations --- examples/error/index.js | 3 ++- examples/search/index.js | 4 ++-- examples/web-service/index.js | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/error/index.js b/examples/error/index.js index 35ba486982f..d7db5015a13 100644 --- a/examples/error/index.js +++ b/examples/error/index.js @@ -20,7 +20,8 @@ function error(err, req, res, next) { if (!test) console.error(err.stack); // respond with 500 "Internal Server Error". - res.send(500); + res.status(500); + res.send('Internal Server Error'); } app.get('/', function(req, res){ diff --git a/examples/search/index.js b/examples/search/index.js index cc470c66f29..d614ac24076 100644 --- a/examples/search/index.js +++ b/examples/search/index.js @@ -47,14 +47,14 @@ app.get('/search/:query?', function(req, res){ }); /** - * GET client javascript. Here we use sendfile() + * GET client javascript. Here we use sendFile() * because serving __dirname with the static() middleware * would also mean serving our server "index.js" and the "search.jade" * template. */ app.get('/client.js', function(req, res){ - res.sendfile(__dirname + '/client.js'); + res.sendFile(__dirname + '/client.js'); }); /* istanbul ignore next */ diff --git a/examples/web-service/index.js b/examples/web-service/index.js index 27e746c7c7e..7e51d4fa060 100644 --- a/examples/web-service/index.js +++ b/examples/web-service/index.js @@ -93,14 +93,16 @@ app.get('/api/user/:name/repos', function(req, res, next){ app.use(function(err, req, res, next){ // whatever you want here, feel free to populate // properties on `err` to treat it differently in here. - res.send(err.status || 500, { error: err.message }); + res.status(err.status || 500); + res.send({ error: err.message }); }); // our custom JSON 404 middleware. Since it's placed last // it will be the last middleware called, if all others // invoke next() and do not respond. app.use(function(req, res){ - res.send(404, { error: "Lame, can't find that" }); + res.status(404); + res.send({ error: "Lame, can't find that" }); }); /* istanbul ignore next */ From 552b441f8ab3457c284a8d6dc5eeaedc51d52df4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 6 Aug 2014 18:21:55 -0400 Subject: [PATCH 0475/1265] 4.8.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 102f9f1bb67..d0bf6a66f62 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.1 / 2014-08-06 +================== * fix incorrect deprecation warnings on `res.download` * deps: qs@1.1.0 diff --git a/package.json b/package.json index 8d516dcd5cb..c998ab53640 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.0", + "version": "4.8.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 982d24b47553f72195d0f83581b48f32cb50591a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Aug 2014 11:53:40 -0400 Subject: [PATCH 0476/1265] deps: connect@2.25.2 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 546e4a0de9e..2d18e60b816 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.25.2 + - deps: body-parser@~1.6.2 + - deps: qs@1.2.0 + 3.16.1 / 2014-08-06 =================== diff --git a/package.json b/package.json index 3a3eb89cf17..17052a0025f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.1", + "connect": "2.25.2", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From ddac571fdf36aef1381c53dd4766f5e9054b1aa3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Aug 2014 11:59:54 -0400 Subject: [PATCH 0477/1265] 3.16.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 2d18e60b816..1e4e0cf8159 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.2 / 2014-08-07 +=================== * deps: connect@2.25.2 - deps: body-parser@~1.6.2 diff --git a/package.json b/package.json index 17052a0025f..3cca5e52c73 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.1", + "version": "3.16.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 7989c883feacb9de542ce03be372173daebf69d1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Aug 2014 12:03:53 -0400 Subject: [PATCH 0478/1265] deps: qs@1.2.0 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b9ef0068c3e..6088b540a4f 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: qs@1.2.0 + - Fix parsing array of objects + 4.8.1 / 2014-08-06 ================== diff --git a/package.json b/package.json index c998ab53640..9179139bf80 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "parseurl": "~1.2.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", - "qs": "1.1.0", + "qs": "1.2.0", "range-parser": "1.0.0", "send": "0.8.1", "serve-static": "~1.5.0", From 22ca953e96e66e142e2e89ba1fa3386a876ce55f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Aug 2014 12:05:02 -0400 Subject: [PATCH 0479/1265] 4.8.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 6088b540a4f..f0ba9ba50e3 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.2 / 2014-08-07 +================== * deps: qs@1.2.0 - Fix parsing array of objects diff --git a/package.json b/package.json index 9179139bf80..fca184e2971 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.1", + "version": "4.8.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 9204e1f42ab0019dfed3298db96af7646079ebbd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Aug 2014 22:31:53 -0400 Subject: [PATCH 0480/1265] deps: connect@2.25.3 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1e4e0cf8159..b3173d6ff69 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +3.x +=== + + * deps: connect@2.25.3 + - deps: multiparty@3.3.2 + 3.16.2 / 2014-08-07 =================== diff --git a/package.json b/package.json index 3cca5e52c73..b9ca3e6072f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.2", + "connect": "2.25.3", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From d13e6135844e1c949ac0f10f307130c4df153085 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Aug 2014 22:32:16 -0400 Subject: [PATCH 0481/1265] 3.16.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b3173d6ff69..cc26e9e2698 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.3 / 2014-08-07 +=================== * deps: connect@2.25.3 - deps: multiparty@3.3.2 diff --git a/package.json b/package.json index b9ca3e6072f..ffd3e0a3f99 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.2", + "version": "3.16.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 570f60d36eea61d410e952c57583f6c7b8117cdd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 10 Aug 2014 22:18:12 -0400 Subject: [PATCH 0482/1265] deps: connect@2.25.4 --- History.md | 17 +++++++++++++++++ package.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index cc26e9e2698..a8997ae6a36 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,20 @@ +3.x +=== + + * deps: connect@2.25.4 + - Fix `query` middleware breaking with argument + - deps: body-parser@~1.6.3 + - deps: compression@~1.0.11 + - deps: connect-timeout@~1.2.2 + - deps: express-session@~1.7.5 + - deps: method-override@~2.1.3 + - deps: on-headers@~1.0.0 + - deps: parseurl@~1.3.0 + - deps: qs@1.2.1 + - deps: response-time@~2.0.1 + - deps: serve-index@~1.1.6 + - deps: serve-static@~1.5.1 + 3.16.3 / 2014-08-07 =================== diff --git a/package.json b/package.json index ffd3e0a3f99..37697f27c99 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.3", + "connect": "2.25.4", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 4a4ca7347a8ada0de14b83503c9e5c50d4fc97e8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 10 Aug 2014 22:19:10 -0400 Subject: [PATCH 0483/1265] deps: parseurl@~1.3.0 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a8997ae6a36..9222b1382ee 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,7 @@ - deps: response-time@~2.0.1 - deps: serve-index@~1.1.6 - deps: serve-static@~1.5.1 + * deps: parseurl@~1.3.0 3.16.3 / 2014-08-07 =================== diff --git a/package.json b/package.json index 37697f27c99..6b1226c15b2 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "media-typer": "0.2.0", "methods": "1.1.0", "mkdirp": "0.5.0", - "parseurl": "~1.2.0", + "parseurl": "~1.3.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.8.1", From a57efea173240961cd038b2336f36183054d7d97 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 10 Aug 2014 22:20:54 -0400 Subject: [PATCH 0484/1265] Fix original URL parsing in res.location --- History.md | 1 + lib/response.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9222b1382ee..0a13e9020ca 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Fix original URL parsing in `res.location` * deps: connect@2.25.4 - Fix `query` middleware breaking with argument - deps: body-parser@~1.6.3 diff --git a/lib/response.js b/lib/response.js index 61c7f16c3ce..822b849187e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -4,6 +4,7 @@ var deprecate = require('depd')('express'); var escapeHtml = require('escape-html'); +var parseUrl = require('parseurl'); var vary = require('vary'); var http = require('http') , path = require('path') @@ -693,7 +694,7 @@ res.location = function(url){ if (!~url.indexOf('://') && 0 != url.indexOf('//')) { // relative to path if ('.' == url[0]) { - path = req.originalUrl.split('?')[0]; + path = parseUrl.original(req).pathname; path = path + ('/' == path[path.length - 1] ? '' : '/'); url = resolve(path, url); // relative to mount-point From 7119f2b16d610af6e4eb6d79292c52e2e8c506d9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 10 Aug 2014 22:22:58 -0400 Subject: [PATCH 0485/1265] 3.16.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 0a13e9020ca..5b078665702 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.4 / 2014-08-10 +=================== * Fix original URL parsing in `res.location` * deps: connect@2.25.4 diff --git a/package.json b/package.json index 6b1226c15b2..6a815860d85 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.3", + "version": "3.16.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 8473b3c3386fa81f3a3b89cb952fd45304430a80 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 10 Aug 2014 22:27:42 -0400 Subject: [PATCH 0486/1265] deps: qs@1.2.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 626bc6a2f4f..ffdac98e56a 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * deps: parseurl@~1.3.0 + * deps: qs@1.2.1 4.8.2 / 2014-08-07 ================== diff --git a/package.json b/package.json index f3ad70d4db8..55c6093daae 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", - "qs": "1.2.0", + "qs": "1.2.1", "range-parser": "1.0.0", "send": "0.8.1", "serve-static": "~1.5.0", From 2594f3103b0a0410aaaa8c1385f82c326afb839e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 10 Aug 2014 22:29:24 -0400 Subject: [PATCH 0487/1265] deps: serve-static@~1.5.1 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ffdac98e56a..88c809173f1 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,10 @@ unreleased * deps: parseurl@~1.3.0 * deps: qs@1.2.1 + * deps: serve-static@~1.5.1 + - Fix parsing of weird `req.originalUrl` values + - deps: parseurl@~1.3.0 + - deps: utils-merge@1.0.0 4.8.2 / 2014-08-07 ================== diff --git a/package.json b/package.json index 55c6093daae..e6df7cd0869 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "qs": "1.2.1", "range-parser": "1.0.0", "send": "0.8.1", - "serve-static": "~1.5.0", + "serve-static": "~1.5.1", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From 1643ae442c724e1ea14383b62675cb13c49e3f49 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 10 Aug 2014 22:30:07 -0400 Subject: [PATCH 0488/1265] 4.8.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 88c809173f1..228e6175e4d 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.3 / 2014-08-10 +================== * deps: parseurl@~1.3.0 * deps: qs@1.2.1 diff --git a/package.json b/package.json index e6df7cd0869..8cf9a5d0957 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.2", + "version": "4.8.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 0f87c6f3929427e07914b77a0e1c28385ab76e02 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 11 Aug 2014 22:29:35 -0400 Subject: [PATCH 0489/1265] deps: connect@2.25.5 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5b078665702..43b7ec81519 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +3.x +=== + + * deps: connect@2.25.5 + - Fix backwards compatibility in `logger` + 3.16.4 / 2014-08-10 =================== diff --git a/package.json b/package.json index 6a815860d85..3d2dd22d7a8 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.4", + "connect": "2.25.5", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 0dddd772c0096b62ab67295083fb1795c353f0ff Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 11 Aug 2014 22:30:09 -0400 Subject: [PATCH 0490/1265] 3.16.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 43b7ec81519..c4f63d1c268 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.5 / 2014-08-11 +=================== * deps: connect@2.25.5 - Fix backwards compatibility in `logger` diff --git a/package.json b/package.json index 3d2dd22d7a8..38bcc58f1fb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.4", + "version": "3.16.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 49947f1476b35276cb280d5a0f7c117020caff57 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 14 Aug 2014 23:49:39 -0400 Subject: [PATCH 0491/1265] deps: connect@2.25.6 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c4f63d1c268..7ad8528a31f 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +3.x +=== + + * deps: connect@2.25.6 + - deps: body-parser@~1.6.4 + - deps: qs@1.2.2 + - deps: serve-static@~1.5.2 + 3.16.5 / 2014-08-11 =================== diff --git a/package.json b/package.json index 38bcc58f1fb..f8b018293d2 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.5", + "connect": "2.25.6", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 059c068c7be185a48935bfb94dc024aaaf7389f5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 14 Aug 2014 23:50:31 -0400 Subject: [PATCH 0492/1265] deps: send@0.8.2 fixes #2300 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7ad8528a31f..ce9cb5d93fc 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,8 @@ - deps: body-parser@~1.6.4 - deps: qs@1.2.2 - deps: serve-static@~1.5.2 + * deps: send@0.8.2 + - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` 3.16.5 / 2014-08-11 =================== diff --git a/package.json b/package.json index f8b018293d2..bef56cf789a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.3.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.8.1", + "send": "0.8.2", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From f13f4652da58c42e30c59e2b0b5b0d58b1d97bb7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 14 Aug 2014 23:53:32 -0400 Subject: [PATCH 0493/1265] 3.16.6 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index ce9cb5d93fc..0fcbf87c30f 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.6 / 2014-08-14 +=================== * deps: connect@2.25.6 - deps: body-parser@~1.6.4 diff --git a/package.json b/package.json index bef56cf789a..f7a4ca679d6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.5", + "version": "3.16.6", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 666ffc62d8b3e44da98a3d55aa6cdaa48726e108 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 15 Aug 2014 00:15:28 -0400 Subject: [PATCH 0494/1265] deps: serve-static@~1.5.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 47f626d8c30..4bcaaddde27 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,8 @@ unreleased * deps: send@0.8.2 - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` + * deps: serve-static@~1.5.2 + - deps: send@0.8.2 4.8.3 / 2014-08-10 ================== diff --git a/package.json b/package.json index 17bbe130f79..9cac3ded082 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "qs": "1.2.1", "range-parser": "1.0.0", "send": "0.8.2", - "serve-static": "~1.5.1", + "serve-static": "~1.5.2", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From ad3ca25c581e9a32edf8abad8aff9d72d51257fd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 15 Aug 2014 00:16:20 -0400 Subject: [PATCH 0495/1265] deps: qs@1.2.2 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4bcaaddde27..0a0d6031945 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * deps: qs@1.2.2 * deps: send@0.8.2 - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` * deps: serve-static@~1.5.2 diff --git a/package.json b/package.json index 9cac3ded082..ee249abdda8 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", - "qs": "1.2.1", + "qs": "1.2.2", "range-parser": "1.0.0", "send": "0.8.2", "serve-static": "~1.5.2", From fbceae2716e94a69ba47cc7a688567b4392ab6a3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 15 Aug 2014 00:18:54 -0400 Subject: [PATCH 0496/1265] tests: add additional res.sendFile test closes #2298 --- test/res.sendFile.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/res.sendFile.js b/test/res.sendFile.js index b9e6007833b..eac1f97c259 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -9,6 +9,14 @@ var fixtures = path.join(__dirname, 'fixtures'); describe('res', function(){ describe('.sendFile(path)', function () { + it('should error missing path', function (done) { + var app = createApp(); + + request(app) + .get('/') + .expect(500, /path.*required/, done); + }); + it('should transfer a file', function (done) { var app = createApp(path.resolve(fixtures, 'name.txt')); From 1ca01c0c47ce16ca2dcc34442b1182ac5b4c9704 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 15 Aug 2014 00:22:54 -0400 Subject: [PATCH 0497/1265] tests: add router.use validation tests closes #2299 --- test/Router.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Router.js b/test/Router.js index e42d9520108..142b9b33faa 100644 --- a/test/Router.js +++ b/test/Router.js @@ -297,6 +297,18 @@ describe('Router', function(){ }) }) + describe('.use', function() { + it('should require arguments', function(){ + var router = new Router(); + router.use.bind(router).should.throw(/requires callback function/) + }) + + it('should not accept non-functions', function(){ + var router = new Router(); + router.use.bind(router, '/', 'hello').should.throw(/requires callback function/) + }) + }) + describe('.param', function() { it('should call param function when routing VERBS', function(done) { var router = new Router(); From ef52b80d750b978f65c00305ed73404f688d69ca Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 15 Aug 2014 00:24:28 -0400 Subject: [PATCH 0498/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ee249abdda8..14b1024ec88 100644 --- a/package.json +++ b/package.json @@ -59,13 +59,13 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.6.1", + "body-parser": "~1.6.4", "cookie-parser": "~1.3.1", - "express-session": "~1.7.2", + "express-session": "~1.7.5", "jade": "~1.5.0", "method-override": "~2.1.1", "morgan": "~1.2.2", - "multiparty": "~3.3.1", + "multiparty": "~3.3.2", "vhost": "2.0.0" }, "engines": { From 0cf02d4667264cea9682d49941f1242ac6f289df Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 15 Aug 2014 00:26:39 -0400 Subject: [PATCH 0499/1265] 4.8.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 0a0d6031945..847f3932647 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.4 / 2014-08-14 +================== * deps: qs@1.2.2 * deps: send@0.8.2 diff --git a/package.json b/package.json index 14b1024ec88..b7395839292 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.3", + "version": "4.8.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 7f92fe66e0dbd56629ec5da81ea8a4903044cf68 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 21:41:14 -0400 Subject: [PATCH 0500/1265] deps: connect@2.25.7 --- History.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0fcbf87c30f..49ac460b855 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,12 @@ +3.x +=== + + * deps: connect@2.25.7 + - deps: body-parser@~1.6.5 + - deps: express-session@~1.7.6 + - deps: morgan@~1.2.3 + - deps: serve-static@~1.5.3 + 3.16.6 / 2014-08-14 =================== diff --git a/package.json b/package.json index f7a4ca679d6..3e76378012a 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.6", + "connect": "2.25.7", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 1576a95e87672d1987e0f29c0dffa574b5acb007 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 21:57:29 -0400 Subject: [PATCH 0501/1265] deps: send@0.8.3 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 49ac460b855..1063403b0ba 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,9 @@ - deps: express-session@~1.7.6 - deps: morgan@~1.2.3 - deps: serve-static@~1.5.3 + * deps: send@0.8.3 + - deps: destroy@1.0.3 + - deps: on-finished@2.1.0 3.16.6 / 2014-08-14 =================== diff --git a/package.json b/package.json index 3e76378012a..6a5a57461c0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.3.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.8.2", + "send": "0.8.3", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From d7bef52591876e3fa86ed08b5ac0cb5447ba1684 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Wed, 30 Jul 2014 15:57:49 -0700 Subject: [PATCH 0502/1265] build: move repository closes #2268 closes #2270 --- Readme.md | 12 ++++++------ examples/view-constructor/index.js | 4 ++-- examples/web-service/index.js | 2 +- package.json | 2 +- test/acceptance/web-service.js | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Readme.md b/Readme.md index e9e45b91eb7..f39292d74b1 100644 --- a/Readme.md +++ b/Readme.md @@ -3,8 +3,8 @@ Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). [![NPM version](https://badge.fury.io/js/express.svg)](http://badge.fury.io/js/express) - [![Build Status](https://travis-ci.org/visionmedia/express.svg?branch=master)](https://travis-ci.org/visionmedia/express) - [![Coverage Status](https://img.shields.io/coveralls/visionmedia/express.svg)](https://coveralls.io/r/visionmedia/express) + [![Build Status](https://travis-ci.org/strongloop/express.svg?branch=master)](https://travis-ci.org/strongloop/express) + [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg)](https://coveralls.io/r/strongloop/express) [![Gittip](http://img.shields.io/gittip/dougwilson.svg)](https://www.gittip.com/dougwilson/) ```js @@ -65,11 +65,11 @@ app.listen(3000); ## More Information - * [Website and Documentation](http://expressjs.com/) stored at [visionmedia/expressjs.com](https://github.com/visionmedia/expressjs.com) + * [Website and Documentation](http://expressjs.com/) stored at [strongloop/expressjs.com](https://github.com/strongloop/expressjs.com) * Join #express on freenode * [Google Group](http://groups.google.com/group/express-js) for discussion * Follow [tjholowaychuk](http://twitter.com/tjholowaychuk) on twitter for updates - * Visit the [Wiki](http://github.com/visionmedia/express/wiki) + * Visit the [Wiki](http://github.com/strongloop/express/wiki) * [Русскоязычная документация](http://jsman.ru/express/) * Run express examples [online](https://runnable.com/express) @@ -77,7 +77,7 @@ app.listen(3000); Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies: - $ git clone git://github.com/visionmedia/express.git --depth 1 + $ git clone git://github.com/strongloop/express.git --depth 1 $ cd express $ npm install @@ -103,7 +103,7 @@ $ npm test ## Contributors - https://github.com/visionmedia/express/graphs/contributors + https://github.com/strongloop/express/graphs/contributors ## License diff --git a/examples/view-constructor/index.js b/examples/view-constructor/index.js index 000f419c04e..b09e1812fdc 100644 --- a/examples/view-constructor/index.js +++ b/examples/view-constructor/index.js @@ -24,7 +24,7 @@ app.engine('md', function(str, options, fn){ }) // pointing to a particular github repo to load files from it -app.set('views', 'visionmedia/express'); +app.set('views', 'strongloop/express'); // register a new view constructor app.set('view', GithubView); @@ -37,7 +37,7 @@ app.get('/', function(req, res){ }) app.get('/Readme.md', function(req, res){ - // rendering a view from https://github.com/visionmedia/express/blob/master/Readme.md + // rendering a view from https://github.com/strongloop/express/blob/master/Readme.md res.render('Readme.md'); }) diff --git a/examples/web-service/index.js b/examples/web-service/index.js index f7c990ab543..a81eb08c571 100644 --- a/examples/web-service/index.js +++ b/examples/web-service/index.js @@ -73,7 +73,7 @@ var apiKeys = ['foo', 'bar', 'baz']; // these two objects will serve as our faux database var repos = [ - { name: 'express', url: 'http://github.com/visionmedia/express' } + { name: 'express', url: 'http://github.com/strongloop/express' } , { name: 'stylus', url: 'http://github.com/learnboost/stylus' } , { name: 'cluster', url: 'http://github.com/learnboost/cluster' } ]; diff --git a/package.json b/package.json index 6a5a57461c0..9c905a6119a 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "app", "api" ], - "repository": "visionmedia/express", + "repository": "strongloop/express", "license": "MIT", "dependencies": { "basic-auth": "1.0.0", diff --git a/test/acceptance/web-service.js b/test/acceptance/web-service.js index e0f744adcee..5868e92df95 100644 --- a/test/acceptance/web-service.js +++ b/test/acceptance/web-service.js @@ -53,7 +53,7 @@ describe('web-service', function(){ .get('/api/repos?api-key=foo') .expect('Content-Type', 'application/json; charset=utf-8') .expect(/"name":"express"/) - .expect(/"url":"http:\/\/github.com\/visionmedia\/express"/) + .expect(/"url":"http:\/\/github.com\/strongloop\/express"/) .expect(200, done) }) }) From 5c145b5490bc00b382d82b52d4308fdfd615c70f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 22:17:25 -0400 Subject: [PATCH 0503/1265] build: add link to homepage --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 9c905a6119a..ac5d8bec33c 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ ], "repository": "strongloop/express", "license": "MIT", + "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", From 8c36eab67926a43a2021a9cc31d1137148a99c1b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 22:19:21 -0400 Subject: [PATCH 0504/1265] docs: use shields.io badges --- Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index f39292d74b1..5db6e3e6179 100644 --- a/Readme.md +++ b/Readme.md @@ -2,10 +2,10 @@ Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). - [![NPM version](https://badge.fury.io/js/express.svg)](http://badge.fury.io/js/express) - [![Build Status](https://travis-ci.org/strongloop/express.svg?branch=master)](https://travis-ci.org/strongloop/express) + [![NPM version](https://img.shields.io/npm/v/express.svg)](https://www.npmjs.org/package/express) + [![Build Status](https://img.shields.io/travis/strongloop/express.svg)](https://travis-ci.org/strongloop/express) [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg)](https://coveralls.io/r/strongloop/express) - [![Gittip](http://img.shields.io/gittip/dougwilson.svg)](https://www.gittip.com/dougwilson/) + [![Gittip](https://img.shields.io/gittip/dougwilson.svg)](https://www.gittip.com/dougwilson/) ```js var express = require('express'); From fdd0ccabe86ecd8ff5f007250961d0e6eba1d7fe Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 22:45:13 -0400 Subject: [PATCH 0505/1265] docs: flatten badges for github look --- Readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 5db6e3e6179..e63a689a13d 100644 --- a/Readme.md +++ b/Readme.md @@ -2,10 +2,10 @@ Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). - [![NPM version](https://img.shields.io/npm/v/express.svg)](https://www.npmjs.org/package/express) - [![Build Status](https://img.shields.io/travis/strongloop/express.svg)](https://travis-ci.org/strongloop/express) - [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg)](https://coveralls.io/r/strongloop/express) - [![Gittip](https://img.shields.io/gittip/dougwilson.svg)](https://www.gittip.com/dougwilson/) + [![NPM version](https://img.shields.io/npm/v/express.svg?style=flat)](https://www.npmjs.org/package/express) + [![Build Status](https://img.shields.io/travis/strongloop/express.svg?style=flat)](https://travis-ci.org/strongloop/express) + [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg?style=flat)](https://coveralls.io/r/strongloop/express) + [![Gittip](https://img.shields.io/gittip/dougwilson.svg?style=flat)](https://www.gittip.com/dougwilson/) ```js var express = require('express'); From 0b12cc0cacbd8948079a0ca78b87d540def950eb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 22:45:17 -0400 Subject: [PATCH 0506/1265] 3.16.7 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 1063403b0ba..6599cfe5ff1 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.7 / 2014-08-18 +=================== * deps: connect@2.25.7 - deps: body-parser@~1.6.5 diff --git a/package.json b/package.json index ac5d8bec33c..00695c5b88b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.6", + "version": "3.16.7", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From f4ddef1570d0dff3f7c5eb38d7b3f1a2b012e8c6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 22:58:47 -0400 Subject: [PATCH 0507/1265] deps: serve-static@~1.5.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 08ed77970d6..d70b2521b41 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * deps: send@0.8.3 - deps: destroy@1.0.3 - deps: on-finished@2.1.0 + * deps: serve-static@~1.5.3 + - deps: send@0.8.3 4.8.4 / 2014-08-14 ================== diff --git a/package.json b/package.json index b8098bcd06f..8d872e053af 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "qs": "1.2.2", "range-parser": "1.0.0", "send": "0.8.3", - "serve-static": "~1.5.2", + "serve-static": "~1.5.3", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From ff0de5eb27591917593bfbe0340923551aa14d26 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 23:00:01 -0400 Subject: [PATCH 0508/1265] deps: update example dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8d872e053af..b60d01fe85a 100644 --- a/package.json +++ b/package.json @@ -60,12 +60,12 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.6.4", + "body-parser": "~1.6.5", "cookie-parser": "~1.3.1", - "express-session": "~1.7.5", + "express-session": "~1.7.6", "jade": "~1.5.0", - "method-override": "~2.1.1", - "morgan": "~1.2.2", + "method-override": "~2.1.3", + "morgan": "~1.2.3", "multiparty": "~3.3.2", "vhost": "2.0.0" }, From 27f195374d7372f3270357873239f2c2962aafcc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 Aug 2014 23:05:16 -0400 Subject: [PATCH 0509/1265] 4.8.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index d70b2521b41..90643dabe25 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.5 / 2014-08-18 +================== * deps: send@0.8.3 - deps: destroy@1.0.3 diff --git a/package.json b/package.json index b60d01fe85a..77c942e0710 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.4", + "version": "4.8.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 3de4e4276d7c3c933fb27d5013c2b4926cb2ebe3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 24 Aug 2014 10:05:24 -0400 Subject: [PATCH 0510/1265] docs: fix logo link --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 654eab8c5df..426bb723f24 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,4 @@ -[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](https://expressjs.com/) +[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/) Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). From 4986b1cb4c62eb853c5666ed552617d6bb79f38a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Aug 2014 14:36:06 -0400 Subject: [PATCH 0511/1265] tests: add some res.sendfile directory tests --- test/res.sendFile.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/test/res.sendFile.js b/test/res.sendFile.js index eac1f97c259..5869503d30a 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -33,6 +33,14 @@ describe('res', function(){ .expect(200, '20%', done); }); + it('should 404 for directory', function (done) { + var app = createApp(path.resolve(fixtures, 'blog')); + + request(app) + .get('/') + .expect(404, done); + }); + it('should 404 when not found', function (done) { var app = createApp(path.resolve(fixtures, 'does-no-exist')); @@ -164,15 +172,15 @@ describe('res', function(){ describe('.sendfile(path, fn)', function(){ it('should invoke the callback when complete', function(done){ var app = express(); + var cb = after(2, done); app.use(function(req, res){ - res.sendfile('test/fixtures/user.html', done) + res.sendfile('test/fixtures/user.html', cb) }); request(app) .get('/') - .expect(200) - .end(function(){}); + .expect(200, cb); }) it('should utilize the same options as express.static()', function(done){ @@ -346,6 +354,18 @@ describe('res', function(){ .expect(200, 'index', done); }); + it('should 404 for directory without trailing slash', function (done) { + var app = express(); + + app.use(function (req, res) { + res.sendfile('test/fixtures/blog'); + }); + + request(app) + .get('/') + .expect(404, done); + }); + it('should transfer a file with urlencoded name', function (done) { var app = express(); From 6a581c99610f63d8b46b6ddae9de48aef27aa743 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Aug 2014 21:04:41 -0400 Subject: [PATCH 0512/1265] deps: connect@2.25.8 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6599cfe5ff1..86f697374ee 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +unreleased +========== + + * deps: connect@2.25.8 + - deps: body-parser@~1.6.6 + - deps: csurf@~1.4.1 + - deps: qs@2.2.0 + 3.16.7 / 2014-08-18 =================== diff --git a/package.json b/package.json index 00695c5b88b..8a9ca8a03b2 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.7", + "connect": "2.25.8", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 0299bee8fae527c02c42dee8ced22a1f63f05093 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Aug 2014 21:09:18 -0400 Subject: [PATCH 0513/1265] 3.16.8 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 86f697374ee..42d0b0b4a48 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +3.16.8 / 2014-08-27 +=================== * deps: connect@2.25.8 - deps: body-parser@~1.6.6 diff --git a/package.json b/package.json index 8a9ca8a03b2..c8ce7a03e7e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.7", + "version": "3.16.8", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 2b2733c2354996905931a9e410be303dedc50796 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Aug 2014 21:22:41 -0400 Subject: [PATCH 0514/1265] deps: qs@2.2.0 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2ef64355030..36db1eaf1ba 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +unreleased +========== + + * deps: qs@2.2.0 + - Array parsing fix + - Performance improvements + 4.8.5 / 2014-08-18 ================== diff --git a/package.json b/package.json index 77c942e0710..18e2e33b7ab 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", - "qs": "1.2.2", + "qs": "2.2.0", "range-parser": "1.0.0", "send": "0.8.3", "serve-static": "~1.5.3", From a206b4e27399bd5176d0d1d2d7328c65b81981a0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Aug 2014 21:25:56 -0400 Subject: [PATCH 0515/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 18e2e33b7ab..bd5fefc1a97 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.6.5", - "cookie-parser": "~1.3.1", + "body-parser": "~1.6.6", + "cookie-parser": "~1.3.2", "express-session": "~1.7.6", "jade": "~1.5.0", "method-override": "~2.1.3", From b6ae091bdfa5d1717b65eba8dbba3d67ad999438 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Aug 2014 21:51:37 -0400 Subject: [PATCH 0516/1265] 4.8.6 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 36db1eaf1ba..2a8b27df022 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.6 / 2014-08-27 +================== * deps: qs@2.2.0 - Array parsing fix diff --git a/package.json b/package.json index bd5fefc1a97..65d32c9b43b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.5", + "version": "4.8.6", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 4127ba10b02cbad9f07f6b4c42c94887d388260e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 30 Aug 2014 01:19:53 -0400 Subject: [PATCH 0517/1265] deps: connect@2.25.9 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 42d0b0b4a48..6d481530d46 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.25.9 + - deps: body-parser@~1.6.7 + - deps: qs@2.2.2 + 3.16.8 / 2014-08-27 =================== diff --git a/package.json b/package.json index c8ce7a03e7e..931c27a7fab 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.8", + "connect": "2.25.9", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From 4d032cda058596e1ae89924ff69e80c3849ef4ff Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 30 Aug 2014 01:22:06 -0400 Subject: [PATCH 0518/1265] 3.16.9 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 6d481530d46..f2a931ebeb7 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.9 / 2014-08-29 +=================== * deps: connect@2.25.9 - deps: body-parser@~1.6.7 diff --git a/package.json b/package.json index 931c27a7fab..89bd79b696a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.8", + "version": "3.16.9", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From f6f47f428c63af11a2ac081908483a56320fa89f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 30 Aug 2014 01:30:56 -0400 Subject: [PATCH 0519/1265] deps: qs@2.2.2 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3dd403591ae..177f30cd3cf 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: qs@2.2.2 + - Remove unnecessary cloning + 4.8.6 / 2014-08-27 ================== diff --git a/package.json b/package.json index 65d32c9b43b..bb4a3b9eded 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", - "qs": "2.2.0", + "qs": "2.2.2", "range-parser": "1.0.0", "send": "0.8.3", "serve-static": "~1.5.3", From 0b49e7f1fdd18e99d403c4543563628fb6fc8565 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 30 Aug 2014 01:33:05 -0400 Subject: [PATCH 0520/1265] deps: update example dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb4a3b9eded..91e0c7a7e4c 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.6.6", + "body-parser": "~1.6.7", "cookie-parser": "~1.3.2", "express-session": "~1.7.6", "jade": "~1.5.0", From 46f0bfc65f151a900e7c36a81b950c79b2c1a596 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 30 Aug 2014 01:37:52 -0400 Subject: [PATCH 0521/1265] 4.8.7 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 177f30cd3cf..ba13f08c839 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.7 / 2014-08-29 +================== * deps: qs@2.2.2 - Remove unnecessary cloning diff --git a/package.json b/package.json index 91e0c7a7e4c..01aac639775 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.6", + "version": "4.8.7", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 3ce5f9b493602827cf7f6ad2a78899cd09984286 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 5 Sep 2014 01:55:24 -0400 Subject: [PATCH 0522/1265] deps: connect@2.25.10 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f2a931ebeb7..4a516b302e1 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +3.x +=== + + * deps: connect@2.25.10 + - deps: serve-static@~1.5.4 + 3.16.9 / 2014-08-29 =================== diff --git a/package.json b/package.json index 89bd79b696a..9b7f06040d5 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.9", + "connect": "2.25.10", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From c8640b346530b1bbcb639319668120763372487c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 5 Sep 2014 01:56:27 -0400 Subject: [PATCH 0523/1265] deps: send@0.8.5 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4a516b302e1..74045f13f5f 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,9 @@ * deps: connect@2.25.10 - deps: serve-static@~1.5.4 + * deps: send@0.8.5 + - Fix a path traversal issue when using `root` + - Fix malicious path detection for empty string path 3.16.9 / 2014-08-29 =================== diff --git a/package.json b/package.json index 9b7f06040d5..8d641adbcd5 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "parseurl": "~1.3.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.8.3", + "send": "0.8.5", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From 8327708ec2504d41dbdd6fa6d8d006975a0a6b0a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 5 Sep 2014 01:57:02 -0400 Subject: [PATCH 0524/1265] deps: istanbul@0.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d641adbcd5..ce14ffe1160 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ }, "devDependencies": { "connect-redis": "~1.5.0", - "istanbul": "0.3.0", + "istanbul": "0.3.2", "mocha": "~1.21.4", "should": "~4.0.0", "ejs": "~1.0.0", From 3d188fe13e1901222cd830dcdc9772a34b9bd745 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 5 Sep 2014 02:17:55 -0400 Subject: [PATCH 0525/1265] 3.16.10 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 74045f13f5f..c6099feb0ee 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.16.10 / 2014-09-04 +==================== * deps: connect@2.25.10 - deps: serve-static@~1.5.4 diff --git a/package.json b/package.json index ce14ffe1160..3af4718a345 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.9", + "version": "3.16.10", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 2d6b735b4f0e21a6ef1c66b4feb157bd1e334868 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 5 Sep 2014 02:21:17 -0400 Subject: [PATCH 0526/1265] deps: serve-static@~1.5.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 16531f92e56..a9033130a65 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * deps: send@0.8.5 - Fix a path traversal issue when using `root` - Fix malicious path detection for empty string path + * deps: serve-static@~1.5.4 + - deps: send@0.8.5 4.8.7 / 2014-08-29 ================== diff --git a/package.json b/package.json index 46946fd745c..e27f90221de 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "qs": "2.2.2", "range-parser": "1.0.0", "send": "0.8.5", - "serve-static": "~1.5.3", + "serve-static": "~1.5.4", "type-is": "~1.3.2", "vary": "0.1.0", "cookie": "0.1.2", From d7e7b2e7d7da7e0ef4fb4fe9d67e65d50cf6e94b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 5 Sep 2014 02:24:02 -0400 Subject: [PATCH 0527/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e27f90221de..aac822f22cf 100644 --- a/package.json +++ b/package.json @@ -60,14 +60,14 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.6.7", + "body-parser": "~1.7.0", "cookie-parser": "~1.3.2", "express-session": "~1.7.6", "jade": "~1.5.0", "method-override": "~2.1.3", "morgan": "~1.2.3", "multiparty": "~3.3.2", - "vhost": "2.0.0" + "vhost": "~3.0.0" }, "engines": { "node": ">= 0.10.0" From 621d074bd87dd7a7064c5607dbed05b97f80fcc0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 5 Sep 2014 02:26:12 -0400 Subject: [PATCH 0528/1265] 4.8.8 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index a9033130a65..94f65088a54 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.8.8 / 2014-09-04 +================== * deps: send@0.8.5 - Fix a path traversal issue when using `root` diff --git a/package.json b/package.json index aac822f22cf..ecd60876a5f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.7", + "version": "4.8.8", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From b97f6eb5068f55b2465d546e9bd8d1b3aff2fc3a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 19:31:58 -0400 Subject: [PATCH 0529/1265] examples: fix github view example closes #2344 --- examples/view-constructor/github-view.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/view-constructor/github-view.js b/examples/view-constructor/github-view.js index d3fb6a1bf1d..d8bff7d080b 100644 --- a/examples/view-constructor/github-view.js +++ b/examples/view-constructor/github-view.js @@ -35,13 +35,13 @@ function GithubView(name, options){ GithubView.prototype.render = function(options, fn){ var self = this; var opts = { - host: 'rawgithub.com', - port: 80, + host: 'raw.githubusercontent.com', + port: 443, path: this.path, method: 'GET' }; - http.request(opts, function(res) { + https.request(opts, function(res) { var buf = ''; res.setEncoding('utf8'); res.on('data', function(str){ buf += str }); From 33bb8fc4b61e4d7efedfaadd704ac66d08c43e9e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 20:51:32 -0400 Subject: [PATCH 0530/1265] examples: fix up route-separation code closes #2341 --- examples/route-separation/index.js | 12 +++- examples/route-separation/user.js | 6 +- test/acceptance/route-separation.js | 97 +++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 test/acceptance/route-separation.js diff --git a/examples/route-separation/index.js b/examples/route-separation/index.js index 2559f788b89..bac61ea8944 100644 --- a/examples/route-separation/index.js +++ b/examples/route-separation/index.js @@ -7,15 +7,23 @@ var app = express(); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); +var methodOverride = require('method-override'); var site = require('./site'); var post = require('./post'); var user = require('./user'); +module.exports = app; + // Config app.set('view engine', 'jade'); app.set('views', __dirname + '/views'); -app.use(logger('dev')); + +/* istanbul ignore next */ +if (!module.parent) { + app.use(express.logger('dev')); +} + app.use(methodOverride('_method')); app.use(cookieParser()); app.use(bodyParser.urlencoded({ extended: true })); @@ -27,7 +35,7 @@ app.get('/', site.index); // User -app.all('/users', user.list); +app.get('/users', user.list); app.all('/user/:id/:op?', user.load); app.get('/user/:id', user.view); app.get('/user/:id/view', user.view); diff --git a/examples/route-separation/user.js b/examples/route-separation/user.js index a5c20410439..ef79b343a28 100644 --- a/examples/route-separation/user.js +++ b/examples/route-separation/user.js @@ -15,7 +15,9 @@ exports.load = function(req, res, next){ if (req.user) { next(); } else { - next(new Error('cannot find user ' + id)); + var err = new Error('cannot find user ' + id); + err.status = 404; + next(err); } }; @@ -40,4 +42,4 @@ exports.update = function(req, res){ req.user.name = user.name; req.user.email = user.email; res.redirect('back'); -}; \ No newline at end of file +}; diff --git a/test/acceptance/route-separation.js b/test/acceptance/route-separation.js new file mode 100644 index 00000000000..867fd295271 --- /dev/null +++ b/test/acceptance/route-separation.js @@ -0,0 +1,97 @@ + +var app = require('../../examples/route-separation') +var request = require('supertest') + +describe('route-separation', function () { + describe('GET /', function () { + it('should respond with index', function (done) { + request(app) + .get('/') + .expect(200, /Route Separation Example/, done) + }) + }) + + describe('GET /users', function () { + it('should list users', function (done) { + request(app) + .get('/users') + .expect(/TJ/) + .expect(/Tobi/) + .expect(200, done) + }) + }) + + describe('GET /user/:id', function () { + it('should get a user', function (done) { + request(app) + .get('/user/0') + .expect(200, /Viewing user TJ/, done) + }) + + it('should 404 on missing user', function (done) { + request(app) + .get('/user/10') + .expect(404, done) + }) + }) + + describe('GET /user/:id/view', function () { + it('should get a user', function (done) { + request(app) + .get('/user/0/view') + .expect(200, /Viewing user TJ/, done) + }) + + it('should 404 on missing user', function (done) { + request(app) + .get('/user/10/view') + .expect(404, done) + }) + }) + + describe('GET /user/:id/edit', function () { + it('should get a user to edit', function (done) { + request(app) + .get('/user/0/edit') + .expect(200, /Editing user TJ/, done) + }) + }) + + describe('PUT /user/:id/edit', function () { + it('should edit a user', function (done) { + request(app) + .put('/user/0/edit') + .set('Content-Type', 'application/x-www-form-urlencoded') + .send({ user: { name: 'TJ', email: 'tj-invalid@vision-media.ca' } }) + .expect(302, function (err) { + if (err) return done(err) + request(app) + .get('/user/0') + .expect(200, /tj-invalid@vision-media\.ca/, done) + }) + }) + }) + + describe('POST /user/:id/edit?_method=PUT', function () { + it('should edit a user', function (done) { + request(app) + .post('/user/1/edit?_method=PUT') + .set('Content-Type', 'application/x-www-form-urlencoded') + .send({ user: { name: 'Tobi', email: 'tobi-invalid@vision-media.ca' } }) + .expect(302, function (err) { + if (err) return done(err) + request(app) + .get('/user/1') + .expect(200, /tobi-invalid@vision-media\.ca/, done) + }) + }) + }) + + describe('GET /posts', function () { + it('should get a list of posts', function (done) { + request(app) + .get('/posts') + .expect(200, /Posts/, done) + }) + }) +}) From d2d0afff64d72f208a8aa2d9216debf5abef9e40 Mon Sep 17 00:00:00 2001 From: lemmy Date: Fri, 5 Sep 2014 20:34:19 +0400 Subject: [PATCH 0531/1265] Remove unused variable closes #2345 --- lib/response.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/response.js b/lib/response.js index e929291da39..27b62853e1e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -16,7 +16,6 @@ var contentDisposition = require('./utils').contentDisposition; var statusCodes = http.STATUS_CODES; var cookie = require('cookie'); var send = require('send'); -var basename = path.basename; var extname = path.extname; var mime = send.mime; var resolve = path.resolve; From 094ff1194907f3f3fc7db2121dd3f2ecbd4a7c49 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 21:09:22 -0400 Subject: [PATCH 0532/1265] deps: connect@2.26.0 --- History.md | 25 +++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c6099feb0ee..096d886655e 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,28 @@ +3.x +=== + + * deps: connect@2.26.0 + - deps: body-parser@~1.8.1 + - deps: compression@~1.1.0 + - deps: connect-timeout@~1.3.0 + - deps: cookie-parser@~1.3.3 + - deps: cookie-signature@1.0.5 + - deps: csurf@~1.6.1 + - deps: debug@~2.0.0 + - deps: errorhandler@~1.2.0 + - deps: express-session@~1.8.1 + - deps: finalhandler@0.2.0 + - deps: fresh@0.2.4 + - deps: media-typer@0.3.0 + - deps: method-override@~2.2.0 + - deps: morgan@~1.3.0 + - deps: qs@2.2.3 + - deps: serve-favicon@~2.1.3 + - deps: serve-index@~1.2.1 + - deps: serve-static@~1.6.1 + - deps: type-is@~1.5.1 + - deps: vhost@~3.0.0 + 3.16.10 / 2014-09-04 ==================== diff --git a/package.json b/package.json index 3af4718a345..a191a9dc6b2 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.25.10", + "connect": "2.26.0", "commander": "1.3.2", "debug": "1.0.4", "depd": "0.4.4", From be18487f7d58f340eb696b1e3edb66eb13b309c2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 21:10:57 -0400 Subject: [PATCH 0533/1265] deps: media-typer@0.3.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 096d886655e..dccc9c7245d 100644 --- a/History.md +++ b/History.md @@ -22,6 +22,8 @@ - deps: serve-static@~1.6.1 - deps: type-is@~1.5.1 - deps: vhost@~3.0.0 + * deps: media-typer@0.3.0 + - Throw error when parameter format invalid on parse 3.16.10 / 2014-09-04 ==================== diff --git a/package.json b/package.json index a191a9dc6b2..d9801e22e50 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "debug": "1.0.4", "depd": "0.4.4", "escape-html": "1.0.1", - "media-typer": "0.2.0", + "media-typer": "0.3.0", "methods": "1.1.0", "mkdirp": "0.5.0", "parseurl": "~1.3.0", From 49284c236bf263b4933cf0bea786c4044706b75d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 21:11:41 -0400 Subject: [PATCH 0534/1265] deps: debug@~2.0.0 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index dccc9c7245d..6ba9a011ae9 100644 --- a/History.md +++ b/History.md @@ -22,6 +22,7 @@ - deps: serve-static@~1.6.1 - deps: type-is@~1.5.1 - deps: vhost@~3.0.0 + * deps: debug@~2.0.0 * deps: media-typer@0.3.0 - Throw error when parameter format invalid on parse diff --git a/package.json b/package.json index d9801e22e50..9cc3ad00493 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "buffer-crc32": "0.2.3", "connect": "2.26.0", "commander": "1.3.2", - "debug": "1.0.4", + "debug": "~2.0.0", "depd": "0.4.4", "escape-html": "1.0.1", "media-typer": "0.3.0", From d6ed469de3a2210c7d6124bf29599bd039a79257 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 21:13:20 -0400 Subject: [PATCH 0535/1265] deps: send@0.9.1 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6ba9a011ae9..ca34e85669a 100644 --- a/History.md +++ b/History.md @@ -25,6 +25,11 @@ * deps: debug@~2.0.0 * deps: media-typer@0.3.0 - Throw error when parameter format invalid on parse + * deps: send@0.9.1 + - Add `lastModified` option + - Use `etag` to generate `ETag` header + - deps: debug@~2.0.0 + - deps: fresh@0.2.4 3.16.10 / 2014-09-04 ==================== diff --git a/package.json b/package.json index 9cc3ad00493..3f348bda19b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "parseurl": "~1.3.0", "proxy-addr": "1.0.1", "range-parser": "1.0.0", - "send": "0.8.5", + "send": "0.9.1", "vary": "0.1.0", "cookie": "0.1.2", "fresh": "0.2.2", From cbb251377ec47d29ae60b8a6e4744b52351677c8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 21:14:27 -0400 Subject: [PATCH 0536/1265] deps: fresh@0.2.4 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ca34e85669a..0200e40ced6 100644 --- a/History.md +++ b/History.md @@ -23,6 +23,7 @@ - deps: type-is@~1.5.1 - deps: vhost@~3.0.0 * deps: debug@~2.0.0 + * deps: fresh@0.2.4 * deps: media-typer@0.3.0 - Throw error when parameter format invalid on parse * deps: send@0.9.1 diff --git a/package.json b/package.json index 3f348bda19b..ecb233bab1a 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "debug": "~2.0.0", "depd": "0.4.4", "escape-html": "1.0.1", + "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", "mkdirp": "0.5.0", @@ -42,7 +43,6 @@ "send": "0.9.1", "vary": "0.1.0", "cookie": "0.1.2", - "fresh": "0.2.2", "cookie-signature": "1.0.4", "merge-descriptors": "0.0.2" }, From b77aa38c987fab2b1dc1b83747bb10811a5bf43f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 21:17:03 -0400 Subject: [PATCH 0537/1265] deps: cookie-signature@1.0.5 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0200e40ced6..cd129f193c2 100644 --- a/History.md +++ b/History.md @@ -22,6 +22,7 @@ - deps: serve-static@~1.6.1 - deps: type-is@~1.5.1 - deps: vhost@~3.0.0 + * deps: cookie-signature@1.0.5 * deps: debug@~2.0.0 * deps: fresh@0.2.4 * deps: media-typer@0.3.0 diff --git a/package.json b/package.json index ecb233bab1a..6472f7a9b5b 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "buffer-crc32": "0.2.3", "connect": "2.26.0", "commander": "1.3.2", + "cookie-signature": "1.0.5", "debug": "~2.0.0", "depd": "0.4.4", "escape-html": "1.0.1", @@ -43,7 +44,6 @@ "send": "0.9.1", "vary": "0.1.0", "cookie": "0.1.2", - "cookie-signature": "1.0.4", "merge-descriptors": "0.0.2" }, "devDependencies": { From 9b18461bbcb58450e265484169f143fa69c52a83 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 21:18:28 -0400 Subject: [PATCH 0538/1265] deps: vary@~1.0.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index cd129f193c2..d27cf9b5b8c 100644 --- a/History.md +++ b/History.md @@ -32,6 +32,8 @@ - Use `etag` to generate `ETag` header - deps: debug@~2.0.0 - deps: fresh@0.2.4 + * deps: vary@~1.0.0 + - Accept valid `Vary` header string as `field` 3.16.10 / 2014-09-04 ==================== diff --git a/package.json b/package.json index 6472f7a9b5b..1f8c5240544 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "proxy-addr": "1.0.1", "range-parser": "1.0.0", "send": "0.9.1", - "vary": "0.1.0", + "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2" }, From d7d6219a1e65a9151f8241753a9091ad9ca93628 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 22:47:54 -0400 Subject: [PATCH 0539/1265] deps: range-parser@~1.0.2 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d27cf9b5b8c..168953875f0 100644 --- a/History.md +++ b/History.md @@ -27,6 +27,7 @@ * deps: fresh@0.2.4 * deps: media-typer@0.3.0 - Throw error when parameter format invalid on parse + * deps: range-parser@~1.0.2 * deps: send@0.9.1 - Add `lastModified` option - Use `etag` to generate `ETag` header diff --git a/package.json b/package.json index 1f8c5240544..7c9cc972f73 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "mkdirp": "0.5.0", "parseurl": "~1.3.0", "proxy-addr": "1.0.1", - "range-parser": "1.0.0", + "range-parser": "~1.0.2", "send": "0.9.1", "vary": "~1.0.0", "cookie": "0.1.2", From 4e97533fd20fea890e14d6ca10e0bc49269b4630 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 22:48:47 -0400 Subject: [PATCH 0540/1265] deps: jade@~1.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c9cc972f73..0455c7c4eb7 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "mocha": "~1.21.4", "should": "~4.0.0", "ejs": "~1.0.0", - "jade": "~1.5.0", + "jade": "~1.6.0", "hjs": "~0.0.6", "marked": "0.3.2", "supertest": "~0.13.0" From d07c06363f00647ab0553ef227b9b65cb4a04ae9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 23:02:42 -0400 Subject: [PATCH 0541/1265] Support X-Forwarded-Host in req.subdomains --- History.md | 1 + lib/request.js | 8 ++++---- test/req.subdomains.js | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 168953875f0..0499b436335 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Support `X-Forwarded-Host` in `req.subdomains` * deps: connect@2.26.0 - deps: body-parser@~1.8.1 - deps: compression@~1.1.0 diff --git a/lib/request.js b/lib/request.js index 03f7cbdabba..485c2962eb9 100644 --- a/lib/request.js +++ b/lib/request.js @@ -452,11 +452,11 @@ req.__defineGetter__('auth', function(){ */ req.__defineGetter__('subdomains', function(){ + var host = this.host; var offset = this.app.get('subdomain offset'); - return (this.host || '') - .split('.') - .reverse() - .slice(offset); + var subdomains = host.split('.').reverse(); + + return subdomains.slice(offset); }); /** diff --git a/test/req.subdomains.js b/test/req.subdomains.js index ec851d2c01a..2ee4280377c 100644 --- a/test/req.subdomains.js +++ b/test/req.subdomains.js @@ -49,6 +49,22 @@ describe('req', function(){ }) }) + describe('with trusted X-Forwarded-Host', function () { + it('should return an array', function (done) { + var app = express(); + + app.set('trust proxy', true); + app.use(function (req, res) { + res.send(req.subdomains); + }); + + request(app) + .get('/') + .set('X-Forwarded-Host', 'tobi.ferrets.example.com') + .expect(['ferrets', 'tobi'], done); + }) + }) + describe('when subdomain offset is set', function(){ describe('when subdomain offset is zero', function(){ it('should return an array with the whole domain', function(done){ From 2de6514b4b4cc7e9629664faa56859da7e597265 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 23:03:48 -0400 Subject: [PATCH 0542/1265] Support IP address host in req.subdomains fixes #2308 --- History.md | 1 + lib/request.js | 5 +++- test/req.subdomains.js | 54 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0499b436335..60c04eebd38 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ === * Support `X-Forwarded-Host` in `req.subdomains` + * Support IP address host in `req.subdomains` * deps: connect@2.26.0 - deps: body-parser@~1.8.1 - deps: compression@~1.1.0 diff --git a/lib/request.js b/lib/request.js index 485c2962eb9..24e8748d211 100644 --- a/lib/request.js +++ b/lib/request.js @@ -13,6 +13,7 @@ var http = require('http') , parse = require('parseurl') , proxyaddr = require('proxy-addr') , mime = connect.mime; +var isIP = require('net').isIP; /** * Request prototype. @@ -454,7 +455,9 @@ req.__defineGetter__('auth', function(){ req.__defineGetter__('subdomains', function(){ var host = this.host; var offset = this.app.get('subdomain offset'); - var subdomains = host.split('.').reverse(); + var subdomains = !isIP(host) + ? host.split('.').reverse() + : [host]; return subdomains.slice(offset); }); diff --git a/test/req.subdomains.js b/test/req.subdomains.js index 2ee4280377c..7da382f4788 100644 --- a/test/req.subdomains.js +++ b/test/req.subdomains.js @@ -17,6 +17,32 @@ describe('req', function(){ .set('Host', 'tobi.ferrets.example.com') .expect(["ferrets","tobi"], done); }) + + it('should work with IPv4 address', function(done){ + var app = express(); + + app.use(function(req, res){ + res.send(req.subdomains); + }); + + request(app) + .get('/') + .set('Host', '127.0.0.1') + .expect([], done); + }) + + it('should work with IPv6 address', function(done){ + var app = express(); + + app.use(function(req, res){ + res.send(req.subdomains); + }); + + request(app) + .get('/') + .set('Host', '[::1]') + .expect([], done); + }) }) describe('otherwise', function(){ @@ -80,6 +106,34 @@ describe('req', function(){ .set('Host', 'tobi.ferrets.sub.example.com') .expect(["com","example","sub","ferrets","tobi"], done); }) + + it('should return an array with the whole IPv4', function (done) { + var app = express(); + app.set('subdomain offset', 0); + + app.use(function(req, res){ + res.send(req.subdomains); + }); + + request(app) + .get('/') + .set('Host', '127.0.0.1') + .expect(['127.0.0.1'], done); + }) + + it('should return an array with the whole IPv6', function (done) { + var app = express(); + app.set('subdomain offset', 0); + + app.use(function(req, res){ + res.send(req.subdomains); + }); + + request(app) + .get('/') + .set('Host', '[::1]') + .expect(['[::1]'], done); + }) }) describe('when present', function(){ From fa1fcd9fec14234f3fde38b6f4929bb2043fedef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 23:07:02 -0400 Subject: [PATCH 0543/1265] 3.17.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 60c04eebd38..0d6b71812ae 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.0 / 2014-09-08 +=================== * Support `X-Forwarded-Host` in `req.subdomains` * Support IP address host in `req.subdomains` diff --git a/package.json b/package.json index 0455c7c4eb7..2a2c2269f2b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.16.10", + "version": "3.17.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 7d277c1c156f0b6b0064500986f689e3d0c09a24 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 23:44:24 -0400 Subject: [PATCH 0544/1265] docs: remove erroneous from history --- History.md | 1 - 1 file changed, 1 deletion(-) diff --git a/History.md b/History.md index 0d6b71812ae..739302555ec 100644 --- a/History.md +++ b/History.md @@ -1,7 +1,6 @@ 3.17.0 / 2014-09-08 =================== - * Support `X-Forwarded-Host` in `req.subdomains` * Support IP address host in `req.subdomains` * deps: connect@2.26.0 - deps: body-parser@~1.8.1 From 70767b19aca926faf679d6ccdd068ba98c52d480 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 23:45:34 -0400 Subject: [PATCH 0545/1265] Fix error in req.subdomains on empty host --- History.md | 5 +++++ lib/request.js | 3 +++ test/req.subdomains.js | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/History.md b/History.md index 739302555ec..e4f2e7bc4b0 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.x +=== + + * Fix error in `req.subdomains` on empty host + 3.17.0 / 2014-09-08 =================== diff --git a/lib/request.js b/lib/request.js index 24e8748d211..683d54805c0 100644 --- a/lib/request.js +++ b/lib/request.js @@ -454,6 +454,9 @@ req.__defineGetter__('auth', function(){ req.__defineGetter__('subdomains', function(){ var host = this.host; + + if (!host) return []; + var offset = this.app.get('subdomain offset'); var subdomains = !isIP(host) ? host.split('.').reverse() diff --git a/test/req.subdomains.js b/test/req.subdomains.js index 7da382f4788..18e4d80ad32 100644 --- a/test/req.subdomains.js +++ b/test/req.subdomains.js @@ -15,7 +15,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', 'tobi.ferrets.example.com') - .expect(["ferrets","tobi"], done); + .expect(200, ['ferrets', 'tobi'], done); }) it('should work with IPv4 address', function(done){ @@ -28,7 +28,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', '127.0.0.1') - .expect([], done); + .expect(200, [], done); }) it('should work with IPv6 address', function(done){ @@ -41,7 +41,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', '[::1]') - .expect([], done); + .expect(200, [], done); }) }) @@ -56,7 +56,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', 'example.com') - .expect([], done); + .expect(200, [], done); }) }) @@ -71,7 +71,7 @@ describe('req', function(){ request(app) .get('/') - .expect([], done); + .expect(200, [], done); }) }) @@ -87,7 +87,7 @@ describe('req', function(){ request(app) .get('/') .set('X-Forwarded-Host', 'tobi.ferrets.example.com') - .expect(['ferrets', 'tobi'], done); + .expect(200, ['ferrets', 'tobi'], done); }) }) @@ -104,7 +104,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', 'tobi.ferrets.sub.example.com') - .expect(["com","example","sub","ferrets","tobi"], done); + .expect(200, ['com', 'example', 'sub', 'ferrets', 'tobi'], done); }) it('should return an array with the whole IPv4', function (done) { @@ -118,7 +118,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', '127.0.0.1') - .expect(['127.0.0.1'], done); + .expect(200, ['127.0.0.1'], done); }) it('should return an array with the whole IPv6', function (done) { @@ -132,7 +132,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', '[::1]') - .expect(['[::1]'], done); + .expect(200, ['[::1]'], done); }) }) @@ -148,7 +148,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', 'tobi.ferrets.sub.example.com') - .expect(["ferrets","tobi"], done); + .expect(200, ['ferrets', 'tobi'], done); }) }) @@ -164,7 +164,7 @@ describe('req', function(){ request(app) .get('/') .set('Host', 'sub.example.com') - .expect([], done); + .expect(200, [], done); }) }) }) From 4b1b8e420f4f4ee95e835e2eebc41a66dba556f2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Sep 2014 23:45:38 -0400 Subject: [PATCH 0546/1265] 3.17.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index e4f2e7bc4b0..416ab71b640 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.1 / 2014-09-08 +=================== * Fix error in `req.subdomains` on empty host diff --git a/package.json b/package.json index 2a2c2269f2b..7806cb8ccf1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.0", + "version": "3.17.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 6bc7574ab5ae85979551b6a2a037bb291a7f1e23 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Aug 2014 23:34:19 -0400 Subject: [PATCH 0547/1265] docs: typo fixes closes #2316 --- History.md | 4 ++-- examples/web-service/index.js | 2 +- test/app.router.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 705d38212fc..501f1d6d996 100644 --- a/History.md +++ b/History.md @@ -1978,7 +1978,7 @@ Shaw] * Added "encoding" option to Request#render(). Closes #299 * Added "dump exceptions" setting, which is enabled by default. * Added simple ejs template engine support - * Added error reponse support for text/plain, application/json. Closes #297 + * Added error response support for text/plain, application/json. Closes #297 * Added callback function param to Request#error() * Added Request#sendHead() * Added Request#stream() @@ -2192,7 +2192,7 @@ Shaw] * Updated sample chat app to show messages on load * Updated libxmljs parseString -> parseHtmlString * Fixed `make init` to work with older versions of git - * Fixed specs can now run independant specs for those who cant build deps. Closes #127 + * Fixed specs can now run independent specs for those who cant build deps. Closes #127 * Fixed issues introduced by the node url module changes. Closes 126. * Fixed two assertions failing due to Collection#keys() returning strings * Fixed faulty Collection#toArray() spec due to keys() returning strings diff --git a/examples/web-service/index.js b/examples/web-service/index.js index 73a02ca0b16..4958c22450c 100644 --- a/examples/web-service/index.js +++ b/examples/web-service/index.js @@ -28,7 +28,7 @@ function error(status, msg) { app.use('/api', function(req, res, next){ var key = req.query['api-key']; - // key isnt present + // key isn't present if (!key) return next(error(400, 'api key required')); // key is invalid diff --git a/test/app.router.js b/test/app.router.js index c0e13fdb75c..ad05a79f517 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -630,7 +630,7 @@ describe('app.router', function(){ .expect('', done); }) - it('should require a preceeding /', function(done){ + it('should require a preceding /', function(done){ var app = express(); app.get('/file/*', function(req, res){ From 1768d94a1a2051bf87267b92bd85ea0750847082 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 9 Sep 2014 00:04:08 -0400 Subject: [PATCH 0548/1265] deps: qs@2.2.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 501f1d6d996..e2e7d19848f 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ unreleased * deps: fresh@0.2.4 * deps: media-typer@0.3.0 - Throw error when parameter format invalid on parse + * deps: qs@2.2.3 + - Fix issue where first empty value in array is discarded * deps: range-parser@~1.0.2 * deps: send@0.9.1 - Add `lastModified` option diff --git a/package.json b/package.json index d52960c28f3..5ec96ef885c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", - "qs": "2.2.2", + "qs": "2.2.3", "range-parser": "~1.0.2", "send": "0.9.1", "serve-static": "~1.5.4", From 276db8c49a4f363d27bc948e554ac375ae92eb0a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 9 Sep 2014 00:06:27 -0400 Subject: [PATCH 0549/1265] deps: update example dependencies --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5ec96ef885c..619c33b7abe 100644 --- a/package.json +++ b/package.json @@ -56,16 +56,16 @@ "mocha": "~1.21.4", "should": "~4.0.4", "supertest": "~0.13.0", - "connect-redis": "~2.0.0", "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.7.0", + "body-parser": "~1.8.1", + "connect-redis": "~2.1.0", "cookie-parser": "~1.3.2", - "express-session": "~1.7.6", - "jade": "~1.5.0", - "method-override": "~2.1.3", - "morgan": "~1.2.3", + "express-session": "~1.8.1", + "jade": "~1.6.0", + "method-override": "~2.2.0", + "morgan": "~1.3.0", "multiparty": "~3.3.2", "vhost": "~3.0.0" }, From d9937c628ad31a04950a495fe5bfa17ccf229401 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 9 Sep 2014 00:08:07 -0400 Subject: [PATCH 0550/1265] deps: finalhandler@0.2.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e2e7d19848f..8ddd6edf207 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,9 @@ unreleased * Support IP address host in `req.subdomains` * deps: cookie-signature@1.0.5 * deps: debug@~2.0.0 + * deps: finalhandler@0.2.0 + - Set `X-Content-Type-Options: nosniff` header + - deps: debug@~2.0.0 * deps: fresh@0.2.4 * deps: media-typer@0.3.0 - Throw error when parameter format invalid on parse diff --git a/package.json b/package.json index 619c33b7abe..63ef13a3705 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "debug": "~2.0.0", "depd": "0.4.4", "escape-html": "1.0.1", - "finalhandler": "0.1.0", + "finalhandler": "0.2.0", "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", From d2b1a89b4a0caa59abc6808b6311cb34cdbf43c8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 9 Sep 2014 00:10:02 -0400 Subject: [PATCH 0551/1265] deps: type-is@~1.5.1 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 8ddd6edf207..1c2f7273340 100644 --- a/History.md +++ b/History.md @@ -18,6 +18,10 @@ unreleased - Use `etag` to generate `ETag` header - deps: debug@~2.0.0 - deps: fresh@0.2.4 + * deps: type-is@~1.5.1 + - fix `hasbody` to be true for `content-length: 0` + - deps: media-typer@0.3.0 + - deps: mime-types@~2.0.1 * deps: vary@~1.0.0 - Accept valid `Vary` header string as `field` diff --git a/package.json b/package.json index 63ef13a3705..9cff99bb49f 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "range-parser": "~1.0.2", "send": "0.9.1", "serve-static": "~1.5.4", - "type-is": "~1.3.2", + "type-is": "~1.5.1", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2", From e2102263ce08642f613667de0430e811470fce4b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 9 Sep 2014 00:11:04 -0400 Subject: [PATCH 0552/1265] deps: serve-static@~1.6.1 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1c2f7273340..25bfe6e6339 100644 --- a/History.md +++ b/History.md @@ -18,6 +18,9 @@ unreleased - Use `etag` to generate `ETag` header - deps: debug@~2.0.0 - deps: fresh@0.2.4 + * deps: serve-static@~1.6.1 + - Add `lastModified` option + - deps: send@0.9.1 * deps: type-is@~1.5.1 - fix `hasbody` to be true for `content-length: 0` - deps: media-typer@0.3.0 diff --git a/package.json b/package.json index 9cff99bb49f..f5f2637f5bf 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "qs": "2.2.3", "range-parser": "~1.0.2", "send": "0.9.1", - "serve-static": "~1.5.4", + "serve-static": "~1.6.1", "type-is": "~1.5.1", "vary": "~1.0.0", "cookie": "0.1.2", From d4de82b853ad5daa387b8853ed697134d9dbac28 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 9 Sep 2014 00:12:10 -0400 Subject: [PATCH 0553/1265] deps: accepts@~1.1.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 25bfe6e6339..35de5711ca0 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * Support IP address host in `req.subdomains` + * deps: accepts@~1.1.0 + - update `mime-types` * deps: cookie-signature@1.0.5 * deps: debug@~2.0.0 * deps: finalhandler@0.2.0 diff --git a/package.json b/package.json index f5f2637f5bf..9cdc28a0ffd 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "license": "MIT", "homepage": "http://expressjs.com/", "dependencies": { - "accepts": "~1.0.7", + "accepts": "~1.1.0", "buffer-crc32": "0.2.3", "cookie-signature": "1.0.5", "debug": "~2.0.0", From 2a0c35a10862c00b7d95ff1a088956ac8de2dac6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Aug 2014 14:43:38 -0400 Subject: [PATCH 0554/1265] Invoke callback for sendfile when client aborts fixes #2189 fixes #2300 closes #2303 closes #2305 --- History.md | 3 + lib/response.js | 198 ++++++++++++++++++++----------------------- package.json | 1 + test/res.sendFile.js | 77 +++++++++++++++++ 4 files changed, 174 insertions(+), 105 deletions(-) diff --git a/History.md b/History.md index 35de5711ca0..e3e5cc34199 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,9 @@ unreleased ========== + * Invoke callback for sendfile when client aborts + - Applies to `res.sendFile`, `res.sendfile`, and `res.download` + - `err` will be populated with request aborted error * Support IP address host in `req.subdomains` * deps: accepts@~1.1.0 - update `mime-types` diff --git a/lib/response.js b/lib/response.js index 27b62853e1e..49624eff8c7 100644 --- a/lib/response.js +++ b/lib/response.js @@ -6,6 +6,7 @@ var deprecate = require('depd')('express'); var escapeHtml = require('escape-html'); var http = require('http'); var isAbsolute = require('./utils').isAbsolute; +var onFinished = require('on-finished'); var path = require('path'); var mixin = require('utils-merge'); var sign = require('cookie-signature').sign; @@ -344,8 +345,8 @@ res.jsonp = function jsonp(obj) { */ res.sendFile = function sendFile(path, options, fn) { - var done; var req = this.req; + var res = this; var next = req.next; if (!path) { @@ -364,59 +365,20 @@ res.sendFile = function sendFile(path, options, fn) { throw new TypeError('path must be absolute or specify root to res.sendFile'); } - // socket errors - req.socket.on('error', onerror); - - // errors - function onerror(err) { - if (done) return; - done = true; - - // clean up - cleanup(); - - // callback available - if (fn) return fn(err); - - // delegate - next(err); - } - - // streaming - function onstream(stream) { - if (done) return; - cleanup(); - if (fn) stream.on('end', fn); - } - - // cleanup - function cleanup() { - req.socket.removeListener('error', onerror); - } - - // transfer + // create file stream var pathname = encodeURI(path); var file = send(req, pathname, options); - file.on('error', onerror); - file.on('directory', next); - file.on('stream', onstream); - - if (options.headers) { - // set headers on successful transfer - file.on('headers', function headers(res) { - var obj = options.headers; - var keys = Object.keys(obj); - for (var i = 0; i < keys.length; i++) { - var k = keys[i]; - res.setHeader(k, obj[k]); - } - }); - } + // transfer + sendfile(res, file, options, function (err) { + if (fn) return fn(err); + if (err && err.code === 'EISDIR') return next(); - // pipe - file.pipe(this); - this.on('finish', cleanup); + // next() all but aborted errors + if (err && err.code !== 'ECONNABORT') { + next(err); + } + }); }; /** @@ -461,71 +423,31 @@ res.sendFile = function sendFile(path, options, fn) { */ res.sendfile = function(path, options, fn){ - options = options || {}; - var self = this; - var req = self.req; - var next = this.req.next; - var done; - + var req = this.req; + var res = this; + var next = req.next; // support function as second arg - if ('function' == typeof options) { + if (typeof options === 'function') { fn = options; options = {}; } - // socket errors - req.socket.on('error', error); - - // errors - function error(err) { - if (done) return; - done = true; - - // clean up - cleanup(); - - // callback available - if (fn) return fn(err); - - // delegate - next(err); - } - - // streaming - function stream(stream) { - if (done) return; - cleanup(); - if (fn) stream.on('end', fn); - } - - // cleanup - function cleanup() { - req.socket.removeListener('error', error); - } + options = options || {}; - // transfer + // create file stream var file = send(req, path, options); - file.on('error', error); - file.on('directory', next); - file.on('stream', stream); - - if (options.headers) { - // set headers on successful transfer - file.on('headers', function headers(res) { - var obj = options.headers; - var keys = Object.keys(obj); - for (var i = 0; i < keys.length; i++) { - var k = keys[i]; - res.setHeader(k, obj[k]); - } - }); - } + // transfer + sendfile(res, file, options, function (err) { + if (fn) return fn(err); + if (err && err.code === 'EISDIR') return next(); - // pipe - file.pipe(this); - this.on('finish', cleanup); + // next() all but aborted errors + if (err && err.code !== 'ECONNABORT') { + next(err); + } + }); }; res.sendfile = deprecate.function(res.sendfile, @@ -953,3 +875,69 @@ res.render = function(view, options, fn){ // render app.render(view, options, fn); }; + +// pipe the send file stream +function sendfile(res, file, options, callback) { + var done = false; + + // directory + function ondirectory() { + if (done) return; + done = true; + + var err = new Error('EISDIR, read'); + err.code = 'EISDIR'; + callback(err); + } + + // errors + function onerror(err) { + if (done) return; + done = true; + callback(err); + } + + // ended + function onend() { + if (done) return; + done = true; + callback(); + } + + // finished + function onfinish(err) { + if (err) return onerror(err); + if (done) return; + + setImmediate(function () { + if (done) return; + done = true; + + // response finished before end of file + var err = new Error('Request aborted'); + err.code = 'ECONNABORT'; + callback(err); + }); + } + + file.on('end', onend); + file.on('error', onerror); + file.on('directory', ondirectory); + onFinished(res, onfinish); + + if (options.headers) { + // set headers on successful transfer + file.on('headers', function headers(res) { + var obj = options.headers; + var keys = Object.keys(obj); + + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + res.setHeader(k, obj[k]); + } + }); + } + + // pipe + file.pipe(res); +} diff --git a/package.json b/package.json index 9cdc28a0ffd..688e8b6d830 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", + "on-finished": "~2.1.0", "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "1.0.1", diff --git a/test/res.sendFile.js b/test/res.sendFile.js index 5869503d30a..779f6ca79f9 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -3,6 +3,7 @@ var after = require('after'); var express = require('../') , request = require('supertest') , assert = require('assert'); +var onFinished = require('on-finished'); var path = require('path'); var should = require('should'); var fixtures = path.join(__dirname, 'fixtures'); @@ -152,6 +153,44 @@ describe('res', function(){ .expect(200, cb); }) + it('should invoke the callback when client aborts', function (done) { + var cb = after(1, done); + var app = express(); + + app.use(function (req, res) { + setImmediate(function () { + res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { + should(err).be.ok; + err.code.should.equal('ECONNABORT'); + cb(); + }); + }); + test.abort(); + }); + + var test = request(app).get('/'); + test.expect(200, cb); + }) + + it('should invoke the callback when client already aborted', function (done) { + var cb = after(1, done); + var app = express(); + + app.use(function (req, res) { + onFinished(res, function () { + res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { + should(err).be.ok; + err.code.should.equal('ECONNABORT'); + cb(); + }); + }); + test.abort(); + }); + + var test = request(app).get('/'); + test.expect(200, cb); + }) + it('should invoke the callback on 404', function(done){ var app = express(); @@ -196,6 +235,44 @@ describe('res', function(){ .end(done); }) + it('should invoke the callback when client aborts', function (done) { + var cb = after(1, done); + var app = express(); + + app.use(function (req, res) { + setImmediate(function () { + res.sendfile('test/fixtures/name.txt', function (err) { + should(err).be.ok; + err.code.should.equal('ECONNABORT'); + cb(); + }); + }); + test.abort(); + }); + + var test = request(app).get('/'); + test.expect(200, cb); + }) + + it('should invoke the callback when client already aborted', function (done) { + var cb = after(1, done); + var app = express(); + + app.use(function (req, res) { + onFinished(res, function () { + res.sendfile('test/fixtures/name.txt', function (err) { + should(err).be.ok; + err.code.should.equal('ECONNABORT'); + cb(); + }); + }); + test.abort(); + }); + + var test = request(app).get('/'); + test.expect(200, cb); + }) + it('should invoke the callback on 404', function(done){ var app = express() , calls = 0; From 51d33edb7973cb9ecec404d03e62d1ef9dff4a92 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 25 Aug 2014 01:07:01 -0400 Subject: [PATCH 0555/1265] Use etag to generate ETag headers --- History.md | 1 + lib/utils.js | 31 ++++++++++--------------------- package.json | 1 + test/res.send.js | 26 ++++++++++++++------------ test/utils.js | 6 +++--- 5 files changed, 29 insertions(+), 36 deletions(-) diff --git a/History.md b/History.md index e3e5cc34199..5efd387bd8c 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased - Applies to `res.sendFile`, `res.sendfile`, and `res.download` - `err` will be populated with request aborted error * Support IP address host in `req.subdomains` + * Use `etag` to generate `ETag` headers * deps: accepts@~1.1.0 - update `mime-types` * deps: cookie-signature@1.0.5 diff --git a/lib/utils.js b/lib/utils.js index 9f9fdfd6d0e..8dd29664cb2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,9 +3,8 @@ */ var mime = require('send').mime; -var crc32 = require('buffer-crc32'); -var crypto = require('crypto'); var basename = require('path').basename; +var etag = require('etag'); var proxyaddr = require('proxy-addr'); var qs = require('qs'); var querystring = require('querystring'); @@ -20,17 +19,12 @@ var typer = require('media-typer'); * @api private */ -exports.etag = function etag(body, encoding){ - if (body.length === 0) { - // fast-path empty body - return '"1B2M2Y8AsgTpgAmY7PhCfg=="' - } +exports.etag = function (body, encoding) { + var buf = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body - var hash = crypto - .createHash('md5') - .update(body, encoding) - .digest('base64') - return '"' + hash + '"' + return etag(buf, {weak: false}) }; /** @@ -43,16 +37,11 @@ exports.etag = function etag(body, encoding){ */ exports.wetag = function wetag(body, encoding){ - if (body.length === 0) { - // fast-path empty body - return 'W/"0-0"' - } + var buf = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body - var buf = Buffer.isBuffer(body) - ? body - : new Buffer(body, encoding) - var len = buf.length - return 'W/"' + len.toString(16) + '-' + crc32.unsigned(buf) + '"' + return etag(buf, {weak: true}) }; /** diff --git a/package.json b/package.json index 688e8b6d830..d8dfc886522 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "debug": "~2.0.0", "depd": "0.4.4", "escape-html": "1.0.1", + "etag": "~1.3.0", "finalhandler": "0.2.0", "fresh": "0.2.4", "media-typer": "0.3.0", diff --git a/test/res.send.js b/test/res.send.js index a3d9d2178c5..6148e00207e 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -118,13 +118,13 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - var str = Array(1024 * 2).join('-'); + var str = Array(1000).join('-'); res.send(str); }); request(app) .get('/') - .expect('ETag', 'W/"7ff-2796319984"') + .expect('ETag', 'W/"3e7-8084ccd1"') .end(done); }) @@ -132,7 +132,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - var str = Array(1024 * 2).join('-'); + var str = Array(1000).join('-'); res.send(str); }); @@ -207,13 +207,13 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - var str = Array(1024 * 2).join('-'); + var str = Array(1000).join('-'); res.send(new Buffer(str)); }); request(app) .get('/') - .expect('ETag', 'W/"7ff-2796319984"') + .expect('ETag', 'W/"3e7-8084ccd1"') .end(done); }) @@ -321,15 +321,17 @@ describe('res', function(){ it('should respond with 304 Not Modified when fresh', function(done){ var app = express(); + var etag = '"asdf"'; app.use(function(req, res){ - var str = Array(1024 * 2).join('-'); + var str = Array(1000).join('-'); + res.set('ETag', etag); res.send(str); }); request(app) .get('/') - .set('If-None-Match', 'W/"7ff-2796319984"') + .set('If-None-Match', etag) .expect(304, done); }) @@ -375,7 +377,7 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"c-1525560792"', done) + .expect('etag', 'W/"c-5aee35d8"', done) }) it('should send ETag for empty string response', function(done){ @@ -396,7 +398,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - var str = Array(1024 * 2).join('-'); + var str = Array(1000).join('-'); res.send(str); }); @@ -404,7 +406,7 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"7ff-2796319984"', done) + .expect('etag', 'W/"3e7-8084ccd1"', done) }); it('should not override ETag when manually set', function(done){ @@ -445,7 +447,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - var str = Array(1024 * 2).join('-'); + var str = Array(1000).join('-'); res.send(str); }); @@ -503,7 +505,7 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"d-1486392595"', done) + .expect('etag', 'W/"d-58988d13"', done) }) }) diff --git a/test/utils.js b/test/utils.js index 89601a5e848..399b3f5bcdb 100644 --- a/test/utils.js +++ b/test/utils.js @@ -28,18 +28,18 @@ describe('utils.etag(body, encoding)', function(){ describe('utils.wetag(body, encoding)', function(){ it('should support strings', function(){ utils.wetag('express!') - .should.eql('W/"8-3098196679"') + .should.eql('W/"8-b8aabac7"') }) it('should support utf8 strings', function(){ utils.wetag('express❤', 'utf8') - .should.eql('W/"a-1751845617"') + .should.eql('W/"a-686b0af1"') }) it('should support buffer', function(){ var buf = new Buffer('express!') utils.wetag(buf) - .should.eql('W/"8-3098196679"'); + .should.eql('W/"8-b8aabac7"'); }) it('should support empty string', function(){ From 12f92a50dc59887c30f4c6f23fdfbfc616dcbef5 Mon Sep 17 00:00:00 2001 From: Seth Samuel Date: Wed, 13 Aug 2014 09:09:59 -0400 Subject: [PATCH 0556/1265] Add res.sendStatus closes #2269 closes #2297 closes #2340 --- History.md | 1 + lib/response.js | 24 ++++++++++++++++++++++++ test/res.sendStatus.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 test/res.sendStatus.js diff --git a/History.md b/History.md index 5efd387bd8c..2b64dd5f34d 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Add `res.sendStatus` * Invoke callback for sendfile when client aborts - Applies to `res.sendFile`, `res.sendfile`, and `res.download` - `err` will be populated with request aborted error diff --git a/lib/response.js b/lib/response.js index 49624eff8c7..879dd98a2b6 100644 --- a/lib/response.js +++ b/lib/response.js @@ -303,6 +303,30 @@ res.jsonp = function jsonp(obj) { return this.send(body); }; +/** + * Send given HTTP status code. + * + * Sets the response status to `statusCode` and the body of the + * response to the standard description from node's http.STATUS_CODES + * or the statusCode number if no description. + * + * Examples: + * + * res.sendStatus(200); + * + * @param {number} statusCode + * @api public + */ + +res.sendStatus = function sendStatus(statusCode) { + var body = http.STATUS_CODES[statusCode] || String(statusCode); + + this.statusCode = statusCode; + this.type('txt'); + + return this.send(body); +}; + /** * Transfer the file at the given `path`. * diff --git a/test/res.sendStatus.js b/test/res.sendStatus.js new file mode 100644 index 00000000000..a97e1bf8d81 --- /dev/null +++ b/test/res.sendStatus.js @@ -0,0 +1,32 @@ + +var assert = require('assert') +var express = require('..') +var request = require('supertest') + +describe('res', function () { + describe('.sendStatus(statusCode)', function () { + it('should send the status code and message as body', function (done) { + var app = express(); + + app.use(function(req, res){ + res.sendStatus(201); + }); + + request(app) + .get('/') + .expect(201, 'Created', done); + }) + + it('should work with unknown code', function (done) { + var app = express(); + + app.use(function(req, res){ + res.sendStatus(599); + }); + + request(app) + .get('/') + .expect(599, '599', done); + }) + }) +}) From 1716e3b067af5acaeeee4165a865e0b670300aee Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 9 Sep 2014 00:32:17 -0400 Subject: [PATCH 0557/1265] 4.9.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 2b64dd5f34d..480cc42347a 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.0 / 2014-09-08 +================== * Add `res.sendStatus` * Invoke callback for sendfile when client aborts diff --git a/package.json b/package.json index d8dfc886522..a4932e51b03 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.8.8", + "version": "4.9.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From cf41a8f25434bde16ee8606ce12bb699ef9de39e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 12 Sep 2014 17:46:49 -0400 Subject: [PATCH 0558/1265] Fix app.use to accept array of middleware without path fixes #2356 --- History.md | 5 ++ lib/application.js | 13 ++- test/app.use.js | 204 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 480cc42347a..32160b82a65 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix `app.use` to accept array of middleware without path + 4.9.0 / 2014-09-08 ================== diff --git a/lib/application.js b/lib/application.js index 2214bf6c1f3..b5cb883dc8e 100644 --- a/lib/application.js +++ b/lib/application.js @@ -157,9 +157,18 @@ app.use = function use(fn) { var self = this; // default path to '/' + // disambiguate app.use([fn]) if (typeof fn !== 'function') { - offset = 1; - path = fn; + var arg = fn; + + while (Array.isArray(arg) && arg.length !== 0) { + arg = arg[0]; + } + + if (typeof arg !== 'function' && (arg == null || arg.length !== 0)) { + offset = 1; + path = fn; + } } var fns = flatten(slice.call(arguments, offset)); diff --git a/test/app.use.js b/test/app.use.js index ee237c88507..8f5698a366d 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -171,6 +171,90 @@ describe('app', function(){ .post('/foo') .expect(200, 'saw POST /foo', cb); }) + + it('should accept array of middleware', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + function fn3(req, res, next) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + } + + app.use([fn1, fn2, fn3]); + + request(app) + .get('/') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) + + it('should accept multiple arrays of middleware', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + function fn3(req, res, next) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + } + + app.use([fn1, fn2], [fn3]); + + request(app) + .get('/') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) + + it('should accept nested arrays of middleware', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + function fn3(req, res, next) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + } + + app.use([[fn1], fn2], [fn3]); + + request(app) + .get('/') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) }) describe('.use(path, middleware)', function(){ @@ -254,6 +338,90 @@ describe('app', function(){ .expect(200, 'saw POST /bar', cb); }) + it('should accept array of middleware', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + function fn3(req, res, next) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + } + + app.use('/foo', [fn1, fn2, fn3]); + + request(app) + .get('/foo') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) + + it('should accept multiple arrays of middleware', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + function fn3(req, res, next) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + } + + app.use('/foo', [fn1, fn2], [fn3]); + + request(app) + .get('/foo') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) + + it('should accept nested arrays of middleware', function (done) { + var app = express(); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + function fn3(req, res, next) { + res.setHeader('x-fn-3', 'hit'); + res.end(); + } + + app.use('/foo', [fn1, [fn2]], [fn3]); + + request(app) + .get('/foo') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, done); + }) + it('should support array of paths', function (done) { var app = express(); var cb = after(3, done); @@ -275,6 +443,42 @@ describe('app', function(){ .expect(200, 'saw GET / through /bar', cb); }) + it('should support array of paths with middleware array', function (done) { + var app = express(); + var cb = after(2, done); + + function fn1(req, res, next) { + res.setHeader('x-fn-1', 'hit'); + next(); + } + + function fn2(req, res, next) { + res.setHeader('x-fn-2', 'hit'); + next(); + } + + function fn3(req, res, next) { + res.setHeader('x-fn-3', 'hit'); + res.send('saw ' + req.method + ' ' + req.url + ' through ' + req.originalUrl); + } + + app.use(['/foo/', '/bar'], [[fn1], fn2], [fn3]); + + request(app) + .get('/foo') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, 'saw GET / through /foo', cb); + + request(app) + .get('/bar') + .expect('x-fn-1', 'hit') + .expect('x-fn-2', 'hit') + .expect('x-fn-3', 'hit') + .expect(200, 'saw GET / through /bar', cb); + }) + it('should support regexp path', function (done) { var app = express(); var cb = after(4, done); From bb8abf1f9017aca26cded6c61043c37dee34a68a Mon Sep 17 00:00:00 2001 From: Fei Yao Date: Sun, 14 Sep 2014 16:20:31 +0800 Subject: [PATCH 0559/1265] Remove unused require in router match closes #2358 --- lib/router/match.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/router/match.js b/lib/router/match.js index ce308c41486..9afebfc8b34 100644 --- a/lib/router/match.js +++ b/lib/router/match.js @@ -1,8 +1,3 @@ -/** - * Module dependencies. - */ - -var pathRegexp = require('path-to-regexp'); /** * Expose `Layer`. From 80847d8c82513c092f168a9f8d877a7f16866df3 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Tue, 2 Sep 2014 17:53:56 -0700 Subject: [PATCH 0560/1265] tests: fix broken tests with node v0.12 branch Currently, test/req.ip.js assumes that the connection between the client and the server is an IPv4 connection. However, depending on the configuration of the host where this test runs, the connection can be an IPv4 one or an IPv6 one using an IPv4 mapped address. In the future, it could also be a "full" IPv6 connection. This change makes this test handle any type of address. fixes #2342 --- test/req.ip.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/req.ip.js b/test/req.ip.js index 8e5f9f5516c..19d0fee147e 100644 --- a/test/req.ip.js +++ b/test/req.ip.js @@ -45,10 +45,9 @@ describe('req', function(){ res.send(req.ip); }); - request(app) - .get('/') - .set('X-Forwarded-For', 'client, p1, p2') - .expect('127.0.0.1', done); + var test = request(app).get('/') + test.set('X-Forwarded-For', 'client, p1, p2') + test.expect(200, getExpectedClientAddress(test._server), done); }) }) }) @@ -63,10 +62,19 @@ describe('req', function(){ res.send(req.ip); }); - request(app) - .get('/') - .expect('127.0.0.1', done); + var test = request(app).get('/') + test.expect(200, getExpectedClientAddress(test._server), done); }) }) }) }) + +/** + * Get the local client address depending on AF_NET of server + */ + +function getExpectedClientAddress(server) { + return server.address().address === '::' + ? '::ffff:127.0.0.1' + : '127.0.0.1'; +} From 534fa181c6bfc695b5724d81ff32b8346986e8f0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 15 Sep 2014 18:56:09 -0700 Subject: [PATCH 0561/1265] Add test-tap npm script for TAP output closes #2359 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7806cb8ccf1..b4673599235 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "prepublish": "npm prune", "test": "mocha --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", + "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" } } From 381f278d0aa6d9ea1abe337686700e35b478f246 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 15 Sep 2014 23:56:36 -0700 Subject: [PATCH 0562/1265] deps: connect@2.26.1 --- History.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 416ab71b640..842cd6b1cea 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,14 @@ +3.x +=== + + * deps: connect@2.26.1 + - deps: body-parser@~1.8.2 + - deps: depd@0.4.5 + - deps: express-session@~1.8.2 + - deps: morgan@~1.3.1 + - deps: serve-favicon@~2.1.3 + - deps: serve-static@~1.6.2 + 3.17.1 / 2014-09-08 =================== diff --git a/package.json b/package.json index b4673599235..0e2d58e5492 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "basic-auth": "1.0.0", "buffer-crc32": "0.2.3", - "connect": "2.26.0", + "connect": "2.26.1", "commander": "1.3.2", "cookie-signature": "1.0.5", "debug": "~2.0.0", From 178fe15091f87c4147cff150d44ccba8b553318e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 15 Sep 2014 23:57:41 -0700 Subject: [PATCH 0563/1265] deps: depd@0.4.5 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 842cd6b1cea..1871b7eac1b 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,7 @@ - deps: morgan@~1.3.1 - deps: serve-favicon@~2.1.3 - deps: serve-static@~1.6.2 + * deps: depd@0.4.5 3.17.1 / 2014-09-08 =================== diff --git a/package.json b/package.json index 0e2d58e5492..42d025a8bc6 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "commander": "1.3.2", "cookie-signature": "1.0.5", "debug": "~2.0.0", - "depd": "0.4.4", + "depd": "0.4.5", "escape-html": "1.0.1", "fresh": "0.2.4", "media-typer": "0.3.0", From 7eb65eeca2a18e9d69a0c57d93e83c5568a78b4b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 15 Sep 2014 23:59:02 -0700 Subject: [PATCH 0564/1265] deps: send@0.9.2 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1871b7eac1b..ada4894b4c3 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,10 @@ - deps: serve-favicon@~2.1.3 - deps: serve-static@~1.6.2 * deps: depd@0.4.5 + * deps: send@0.9.2 + - deps: depd@0.4.5 + - deps: etag@~1.3.1 + - deps: range-parser@~1.0.2 3.17.1 / 2014-09-08 =================== diff --git a/package.json b/package.json index 42d025a8bc6..d8a1e4dabbf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "parseurl": "~1.3.0", "proxy-addr": "1.0.1", "range-parser": "~1.0.2", - "send": "0.9.1", + "send": "0.9.2", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2" From f6ac068ab040ae008074e2ecc9b935a55310f2f2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Sep 2014 00:11:08 -0700 Subject: [PATCH 0565/1265] Use crc instead of buffer-crc32 for speed --- History.md | 1 + lib/utils.js | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index ada4894b4c3..7fe76c91727 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Use `crc` instead of `buffer-crc32` for speed * deps: connect@2.26.1 - deps: body-parser@~1.8.2 - deps: depd@0.4.5 diff --git a/lib/utils.js b/lib/utils.js index 2d5bfbb33fa..7497fe8eb1b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,9 +3,9 @@ * Module dependencies. */ +var crc = require('crc').crc32; var mime = require('connect').mime , proxyaddr = require('proxy-addr') - , crc32 = require('buffer-crc32') , crypto = require('crypto'); var typer = require('media-typer'); @@ -56,7 +56,7 @@ exports.wetag = function wetag(body, encoding){ ? body : new Buffer(body, encoding) var len = buf.length - return 'W/"' + len.toString(16) + '-' + crc32.unsigned(buf) + '"' + return 'W/"' + len.toString(16) + '-' + crc(buf) + '"' }; /** diff --git a/package.json b/package.json index d8a1e4dabbf..5219657cc2d 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,10 @@ "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", - "buffer-crc32": "0.2.3", "connect": "2.26.1", "commander": "1.3.2", "cookie-signature": "1.0.5", + "crc": "3.0.0", "debug": "~2.0.0", "depd": "0.4.5", "escape-html": "1.0.1", From f29399c4e1f644a64e08a45251f113d361bdfbb3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Sep 2014 00:14:41 -0700 Subject: [PATCH 0566/1265] 3.17.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 7fe76c91727..07349797ee0 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.2 / 2014-09-15 +=================== * Use `crc` instead of `buffer-crc32` for speed * deps: connect@2.26.1 diff --git a/package.json b/package.json index 5219657cc2d..92eea497321 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.1", + "version": "3.17.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From daacb749c12edd70987bd11104f74d6409c40d68 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Sep 2014 23:03:04 -0700 Subject: [PATCH 0567/1265] deps: remove un-used buffer-crc32 dependency --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index a4932e51b03..33d9de46fd9 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "homepage": "http://expressjs.com/", "dependencies": { "accepts": "~1.1.0", - "buffer-crc32": "0.2.3", "cookie-signature": "1.0.5", "debug": "~2.0.0", "depd": "0.4.4", From 2470ae6c7270485717c0f2f9af490815929fd431 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Sep 2014 23:21:45 -0700 Subject: [PATCH 0568/1265] deps: etag@~1.3.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 551c6658d2a..4c2e3a3e907 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ unreleased * Fix `app.use` to accept array of middleware without path * deps: depd@0.4.5 + * deps: etag@~1.3.1 * deps: send@0.9.2 - deps: depd@0.4.5 - deps: etag@~1.3.1 diff --git a/package.json b/package.json index f6e662a599a..9ab16140945 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "debug": "~2.0.0", "depd": "0.4.5", "escape-html": "1.0.1", - "etag": "~1.3.0", + "etag": "~1.3.1", "finalhandler": "0.2.0", "fresh": "0.2.4", "media-typer": "0.3.0", From d08fd64190a5850576c54e3e13e535907c1523db Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Sep 2014 23:23:14 -0700 Subject: [PATCH 0569/1265] deps: serve-static@~1.6.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4c2e3a3e907..96dd8f9c69a 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ unreleased - deps: depd@0.4.5 - deps: etag@~1.3.1 - deps: range-parser@~1.0.2 + * deps: serve-static@~1.6.2 + - deps: send@0.9.2 4.9.0 / 2014-09-08 ================== diff --git a/package.json b/package.json index 9ab16140945..0c1a08046e0 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "qs": "2.2.3", "range-parser": "~1.0.2", "send": "0.9.2", - "serve-static": "~1.6.1", + "serve-static": "~1.6.2", "type-is": "~1.5.1", "vary": "~1.0.0", "cookie": "0.1.2", From c5193536e5c1082e0eea7517e4dc326d9a0767e5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Sep 2014 23:24:23 -0700 Subject: [PATCH 0570/1265] deps: update example dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0c1a08046e0..dd27e3fc2e4 100644 --- a/package.json +++ b/package.json @@ -60,13 +60,13 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.8.1", + "body-parser": "~1.8.2", "connect-redis": "~2.1.0", - "cookie-parser": "~1.3.2", - "express-session": "~1.8.1", + "cookie-parser": "~1.3.3", + "express-session": "~1.8.2", "jade": "~1.6.0", "method-override": "~2.2.0", - "morgan": "~1.3.0", + "morgan": "~1.3.1", "multiparty": "~3.3.2", "vhost": "~3.0.0" }, From 947fb8b27425851f3316ae9d39df5035085dde4a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Sep 2014 23:31:57 -0700 Subject: [PATCH 0571/1265] 4.9.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 96dd8f9c69a..1f0b8e751d6 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.1 / 2014-09-16 +================== * Fix `app.use` to accept array of middleware without path * deps: depd@0.4.5 diff --git a/package.json b/package.json index dd27e3fc2e4..2fb27ccda50 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.0", + "version": "4.9.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 3c1a96436237e4dc920786030b05b4903b9dcfff Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Sep 2014 12:17:03 -0700 Subject: [PATCH 0572/1265] Fix regression for empty string path in app.use fixes #2361 fixes #2362 --- History.md | 5 +++++ lib/application.js | 3 ++- test/app.use.js | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1f0b8e751d6..abd9623a548 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix regression for empty string `path` in `app.use` + 4.9.1 / 2014-09-16 ================== diff --git a/lib/application.js b/lib/application.js index b5cb883dc8e..2c7cc2de263 100644 --- a/lib/application.js +++ b/lib/application.js @@ -165,7 +165,8 @@ app.use = function use(fn) { arg = arg[0]; } - if (typeof arg !== 'function' && (arg == null || arg.length !== 0)) { + // first arg is the path + if (typeof arg !== 'function') { offset = 1; path = fn; } diff --git a/test/app.use.js b/test/app.use.js index 8f5698a366d..c1c511bad92 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -503,5 +503,17 @@ describe('app', function(){ .get('/get/zoo') .expect(404, cb); }) + + it('should support empty string path', function (done) { + var app = express(); + + app.use('', function (req, res) { + res.send('saw ' + req.method + ' ' + req.url + ' through ' + req.originalUrl); + }); + + request(app) + .get('/') + .expect(200, 'saw GET / through /', done); + }) }) }) From bf1980f1b4f863bf89db2d3066f79bd813bcfe05 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Sep 2014 12:28:48 -0700 Subject: [PATCH 0573/1265] Improve error message for bad app.use arguments --- History.md | 1 + lib/router/index.js | 28 +++++++++++++++++++++++----- test/Router.js | 7 +++++-- test/app.use.js | 18 +++++++++++++----- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/History.md b/History.md index abd9623a548..1e9e7d37966 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Fix regression for empty string `path` in `app.use` + * Improve error message for bad `app.use` arguments 4.9.1 / 2014-09-16 ================== diff --git a/lib/router/index.js b/lib/router/index.js index 4e63eb1060f..8bdce9197c5 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -1,3 +1,4 @@ + /** * Module dependencies. */ @@ -8,9 +9,15 @@ var methods = require('methods'); var mixin = require('utils-merge'); var debug = require('debug')('express:router'); var parseUrl = require('parseurl'); +var utils = require('../utils'); + +/** + * Module variables. + */ + +var objectRegExp = /^\[object (\S+)\]$/; var slice = Array.prototype.slice; var toString = Object.prototype.toString; -var utils = require('../utils'); /** * Initialize a new `Router` with the given `options`. @@ -413,14 +420,12 @@ proto.use = function use(fn) { var callbacks = utils.flatten(slice.call(arguments, offset)); if (callbacks.length === 0) { - throw new TypeError('Router.use() requires callback function'); + throw new TypeError('Router.use() requires middleware functions'); } callbacks.forEach(function (fn) { if (typeof fn !== 'function') { - var type = toString.call(fn); - var msg = 'Router.use() requires callback function but got a ' + type; - throw new TypeError(msg); + throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn)); } // add the middleware @@ -477,6 +482,19 @@ methods.concat('all').forEach(function(method){ }; }); +// get type for error message +function gettype(obj) { + var type = typeof obj; + + if (type !== 'object') { + return type; + } + + // inspect [[Class]] for objects + return toString.call(obj) + .replace(objectRegExp, '$1'); +} + // merge params with parent params function mergeParams(params, parent) { if (typeof parent !== 'object' || !parent) { diff --git a/test/Router.js b/test/Router.js index 142b9b33faa..9085acd7f0e 100644 --- a/test/Router.js +++ b/test/Router.js @@ -300,12 +300,15 @@ describe('Router', function(){ describe('.use', function() { it('should require arguments', function(){ var router = new Router(); - router.use.bind(router).should.throw(/requires callback function/) + router.use.bind(router).should.throw(/requires middleware function/) }) it('should not accept non-functions', function(){ var router = new Router(); - router.use.bind(router, '/', 'hello').should.throw(/requires callback function/) + router.use.bind(router, '/', 'hello').should.throw(/requires middleware function.*string/) + router.use.bind(router, '/', 5).should.throw(/requires middleware function.*number/) + router.use.bind(router, '/', null).should.throw(/requires middleware function.*Null/) + router.use.bind(router, '/', new Date()).should.throw(/requires middleware function.*Date/) }) }) diff --git a/test/app.use.js b/test/app.use.js index c1c511bad92..b2031e4c56c 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -16,11 +16,6 @@ describe('app', function(){ app.use(blog); }) - it('should reject missing functions', function(){ - var app = express(); - app.use.bind(app, 3).should.throw(/requires middleware function/); - }) - describe('.use(app)', function(){ it('should mount the app', function(done){ var blog = express() @@ -258,6 +253,19 @@ describe('app', function(){ }) describe('.use(path, middleware)', function(){ + it('should reject missing functions', function () { + var app = express(); + app.use.bind(app, '/').should.throw(/requires middleware function/); + }) + + it('should reject non-functions as middleware', function () { + var app = express(); + app.use.bind(app, '/', 'hi').should.throw(/requires middleware function.*string/); + app.use.bind(app, '/', 5).should.throw(/requires middleware function.*number/); + app.use.bind(app, '/', null).should.throw(/requires middleware function.*Null/); + app.use.bind(app, '/', new Date()).should.throw(/requires middleware function.*Date/); + }) + it('should strip path from req.url', function (done) { var app = express(); From 728917164cc00dd02382560f52c6f78936adb4c3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Sep 2014 12:37:56 -0700 Subject: [PATCH 0574/1265] Fix router.use to accept array of middleware without path --- History.md | 1 + lib/router/index.js | 14 ++++++++++++-- test/Router.js | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 1e9e7d37966..42b9166c5ea 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Fix regression for empty string `path` in `app.use` + * Fix `router.use` to accept array of middleware without path * Improve error message for bad `app.use` arguments 4.9.1 / 2014-09-16 diff --git a/lib/router/index.js b/lib/router/index.js index 8bdce9197c5..64fcd1e3ac0 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -412,9 +412,19 @@ proto.use = function use(fn) { var self = this; // default path to '/' + // disambiguate router.use([fn]) if (typeof fn !== 'function') { - offset = 1; - path = fn; + var arg = fn; + + while (Array.isArray(arg) && arg.length !== 0) { + arg = arg[0]; + } + + // first arg is the path + if (typeof arg !== 'function') { + offset = 1; + path = fn; + } } var callbacks = utils.flatten(slice.call(arguments, offset)); diff --git a/test/Router.js b/test/Router.js index 9085acd7f0e..85a53312073 100644 --- a/test/Router.js +++ b/test/Router.js @@ -310,6 +310,28 @@ describe('Router', function(){ router.use.bind(router, '/', null).should.throw(/requires middleware function.*Null/) router.use.bind(router, '/', new Date()).should.throw(/requires middleware function.*Date/) }) + + it('should accept array of middleware', function(done){ + var count = 0; + var router = new Router(); + + function fn1(req, res, next){ + assert.equal(++count, 1); + next(); + } + + function fn2(req, res, next){ + assert.equal(++count, 2); + next(); + } + + router.use([fn1, fn2], function(req, res){ + assert.equal(++count, 3); + done(); + }); + + router.handle({ url: '/foo', method: 'GET' }, {}, function(){}); + }) }) describe('.param', function() { From 91891e3aee6f2a0b1c4db1e0b499338d05bda91b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Sep 2014 20:49:01 -0700 Subject: [PATCH 0575/1265] 4.9.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 42b9166c5ea..fadebb9b564 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.2 / 2014-09-17 +================== * Fix regression for empty string `path` in `app.use` * Fix `router.use` to accept array of middleware without path diff --git a/package.json b/package.json index 2fb27ccda50..eea18553c60 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.1", + "version": "4.9.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From c00f2f859635471cedaef12ecc20bd251d815dc2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Sep 2014 10:36:21 -0700 Subject: [PATCH 0576/1265] deps: proxy-addr@~1.0.2 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 07349797ee0..6c9b8fe3763 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: proxy-addr@~1.0.2 + - Fix a global leak when multiple subnets are trusted + - deps: ipaddr.js@0.1.3 + 3.17.2 / 2014-09-15 =================== diff --git a/package.json b/package.json index 92eea497321..dfaa228aaee 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "methods": "1.1.0", "mkdirp": "0.5.0", "parseurl": "~1.3.0", - "proxy-addr": "1.0.1", + "proxy-addr": "~1.0.2", "range-parser": "~1.0.2", "send": "0.9.2", "vary": "~1.0.0", From 63286e1192c695630a9c221c93b98d3b982fc5c7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Sep 2014 10:38:31 -0700 Subject: [PATCH 0577/1265] 3.17.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 6c9b8fe3763..d34e517ea25 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.3 / 2014-09-18 +=================== * deps: proxy-addr@~1.0.2 - Fix a global leak when multiple subnets are trusted diff --git a/package.json b/package.json index dfaa228aaee..b761379d05c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.2", + "version": "3.17.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From bc38d896ea6bb8049e08467c0ff7fcf40956e744 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Sep 2014 10:45:35 -0700 Subject: [PATCH 0578/1265] 4.9.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index cd0990c8266..d67cb81691e 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.3 / 2014-09-18 +================== * deps: proxy-addr@~1.0.2 - Fix a global leak when multiple subnets are trusted diff --git a/package.json b/package.json index 95a64f48063..7673de50625 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.2", + "version": "4.9.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 0e0b259556789538b818a1a691502775e1758b75 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 19 Sep 2014 22:54:39 -0700 Subject: [PATCH 0579/1265] deps: connect@2.26.2 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d34e517ea25..b0601d4ef58 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.26.2 + - deps: body-parser@~1.8.3 + - deps: qs@2.2.4 + 3.17.3 / 2014-09-18 =================== diff --git a/package.json b/package.json index b761379d05c..0967c0078d9 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", - "connect": "2.26.1", + "connect": "2.26.2", "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", From b09afad7b19d87bbc5acae6220e79f4765fb69c3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 19 Sep 2014 22:57:07 -0700 Subject: [PATCH 0580/1265] 3.17.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b0601d4ef58..4e7dda5208b 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.4 / 2014-09-19 +=================== * deps: connect@2.26.2 - deps: body-parser@~1.8.3 diff --git a/package.json b/package.json index 0967c0078d9..63489f5dc1f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.3", + "version": "3.17.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From e4fc09423e467efab58caf073a22898d01571a2d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 19 Sep 2014 23:06:31 -0700 Subject: [PATCH 0581/1265] deps: qs@2.2.4 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4a091f8538a..a56b4452bf0 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: qs@2.2.4 + - Fix issue with object keys starting with numbers truncated + 4.9.3 / 2014-09-18 ================== diff --git a/package.json b/package.json index 7673de50625..3a810beed2a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.2", - "qs": "2.2.3", + "qs": "2.2.4", "range-parser": "~1.0.2", "send": "0.9.2", "serve-static": "~1.6.2", From 8e46af1b1dd543b9933b86613a16ddcb7dc286be Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 19 Sep 2014 23:07:58 -0700 Subject: [PATCH 0582/1265] 4.9.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index a56b4452bf0..ec5c90b7331 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.4 / 2014-09-19 +================== * deps: qs@2.2.4 - Fix issue with object keys starting with numbers truncated diff --git a/package.json b/package.json index 3a810beed2a..7423c4eddc0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.3", + "version": "4.9.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 341c1919d9c1280c7a9bbc610bef3ebf8e8d6ad2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 24 Sep 2014 19:12:43 -0400 Subject: [PATCH 0583/1265] deps: connect@2.26.3 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4e7dda5208b..5c38c2492b1 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +3.x +=== + + * deps: connect@2.26.3 + - deps: body-parser@~1.8.4 + - deps: serve-favicon@~2.1.5 + - deps: serve-static@~1.6.3 + 3.17.4 / 2014-09-19 =================== diff --git a/package.json b/package.json index 63489f5dc1f..ac147a40780 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", - "connect": "2.26.2", + "connect": "2.26.3", "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", From 734bdf5ca15f2b620015d197606df34e3900c7da Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 24 Sep 2014 19:14:33 -0400 Subject: [PATCH 0584/1265] deps: proxy-addr@~1.0.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5c38c2492b1..6740df6502c 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,8 @@ - deps: body-parser@~1.8.4 - deps: serve-favicon@~2.1.5 - deps: serve-static@~1.6.3 + * deps: proxy-addr@~1.0.3 + - Use `forwarded` npm module 3.17.4 / 2014-09-19 =================== diff --git a/package.json b/package.json index ac147a40780..f3fa8be1902 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "methods": "1.1.0", "mkdirp": "0.5.0", "parseurl": "~1.3.0", - "proxy-addr": "~1.0.2", + "proxy-addr": "~1.0.3", "range-parser": "~1.0.2", "send": "0.9.2", "vary": "~1.0.0", From 653270bb432ef20646a5cc480c62658e8a4b1c51 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 24 Sep 2014 19:15:46 -0400 Subject: [PATCH 0585/1265] deps: send@0.9.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6740df6502c..628be16bfc5 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ - deps: serve-static@~1.6.3 * deps: proxy-addr@~1.0.3 - Use `forwarded` npm module + * deps: send@0.9.3 + - deps: etag@~1.4.0 3.17.4 / 2014-09-19 =================== diff --git a/package.json b/package.json index f3fa8be1902..2383af2bbcc 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.3", "range-parser": "~1.0.2", - "send": "0.9.2", + "send": "0.9.3", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2" From 43e2cd79cba6acddb0d2c0de6dceb5874e21f5e5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 24 Sep 2014 19:38:35 -0400 Subject: [PATCH 0586/1265] 3.17.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 628be16bfc5..6bed7ce12d3 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.5 / 2014-09-24 +=================== * deps: connect@2.26.3 - deps: body-parser@~1.8.4 diff --git a/package.json b/package.json index 2383af2bbcc..54a05a263fc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.4", + "version": "3.17.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 3bcba79e2defda3a5a93c87a8f6d1ef08b3cfda2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 24 Sep 2014 20:14:39 -0400 Subject: [PATCH 0587/1265] deps: etag@~1.4.0 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index bc5225ee3a7..6445b2ee59d 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * deps: etag@~1.4.0 * deps: proxy-addr@~1.0.3 - Use `forwarded` npm module * deps: send@0.9.3 diff --git a/package.json b/package.json index 1ae9bc3ea5a..72c9ccc2151 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "debug": "~2.0.0", "depd": "0.4.5", "escape-html": "1.0.1", - "etag": "~1.3.1", + "etag": "~1.4.0", "finalhandler": "0.2.0", "fresh": "0.2.4", "media-typer": "0.3.0", From 590c9192042c5a615be6832634451e079133749b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 24 Sep 2014 20:16:00 -0400 Subject: [PATCH 0588/1265] deps: serve-static@~1.6.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6445b2ee59d..e2d46155948 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,8 @@ unreleased - Use `forwarded` npm module * deps: send@0.9.3 - deps: etag@~1.4.0 + * deps: serve-static@~1.6.3 + - deps: send@0.9.3 4.9.4 / 2014-09-19 ================== diff --git a/package.json b/package.json index 72c9ccc2151..c1a80aeb765 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "qs": "2.2.4", "range-parser": "~1.0.2", "send": "0.9.3", - "serve-static": "~1.6.2", + "serve-static": "~1.6.3", "type-is": "~1.5.1", "vary": "~1.0.0", "cookie": "0.1.2", From daadf6033b013319360850a6fc51911533a84512 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 24 Sep 2014 20:18:59 -0400 Subject: [PATCH 0589/1265] 4.9.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index e2d46155948..8ba25525b46 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.5 / 2014-09-24 +================== * deps: etag@~1.4.0 * deps: proxy-addr@~1.0.3 diff --git a/package.json b/package.json index c1a80aeb765..2a578d58067 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.4", + "version": "4.9.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 5603f86eddc5adac4ed868f9f3c593a494039831 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 2 Oct 2014 23:27:41 -0400 Subject: [PATCH 0590/1265] deps: connect@2.26.4 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6bed7ce12d3..3f6b247d329 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.26.4 + - deps: morgan@~1.3.2 + - deps: type-is@~1.5.2 + 3.17.5 / 2014-09-24 =================== diff --git a/package.json b/package.json index 54a05a263fc..5df85a1bae6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", - "connect": "2.26.3", + "connect": "2.26.4", "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", From cc18da5cdfd6edbe1878b80f1c37cf0d6b86bcb6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 2 Oct 2014 23:29:40 -0400 Subject: [PATCH 0591/1265] 3.17.6 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 3f6b247d329..ca45081ffc2 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.6 / 2014-10-02 +=================== * deps: connect@2.26.4 - deps: morgan@~1.3.2 diff --git a/package.json b/package.json index 5df85a1bae6..fef1b98bae6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.5", + "version": "3.17.6", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From f45bd632dfada823e4f18bc7f52659e1394f7961 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 8 Oct 2014 16:43:02 -0400 Subject: [PATCH 0592/1265] deps: connect@2.26.5 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ca45081ffc2..bb97145c4fb 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.26.5 + - Fix accepting non-object arguments to `logger` + - deps: serve-static@~1.6.4 + 3.17.6 / 2014-10-02 =================== diff --git a/package.json b/package.json index fef1b98bae6..46e6ae8cff6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", - "connect": "2.26.4", + "connect": "2.26.5", "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", From ef3e95ca739a5357f9a8fd9f8a61e1cc26265b28 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 8 Oct 2014 16:44:29 -0400 Subject: [PATCH 0593/1265] deps: supertest@~0.14.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 46e6ae8cff6..789bef7a567 100644 --- a/package.json +++ b/package.json @@ -51,11 +51,11 @@ "istanbul": "0.3.2", "mocha": "~1.21.4", "should": "~4.0.0", + "supertest": "~0.14.0", "ejs": "~1.0.0", "jade": "~1.6.0", "hjs": "~0.0.6", - "marked": "0.3.2", - "supertest": "~0.13.0" + "marked": "0.3.2" }, "engines": { "node": ">= 0.8.0" From 9f292d873ef3124ed1760ca3647780452b34daf0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 8 Oct 2014 17:00:45 -0400 Subject: [PATCH 0594/1265] 3.17.7 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index bb97145c4fb..8b402228551 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.7 / 2014-10-08 +=================== * deps: connect@2.26.5 - Fix accepting non-object arguments to `logger` diff --git a/package.json b/package.json index 789bef7a567..8f4f9fc819b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.6", + "version": "3.17.7", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 2c140961ab5dec6622a6dffbd325d8a31eeb0bb3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 8 Oct 2014 21:48:27 -0400 Subject: [PATCH 0595/1265] deps: accepts@~1.1.1 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e351b409b73..f98b9b4067b 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +unreleased +========== + + * deps: accepts@~1.1.1 + - deps: mime-types@~2.0.2 + - deps: negotiator@0.4.8 + 4.9.5 / 2014-09-24 ================== diff --git a/package.json b/package.json index deff42aeba6..d5c31120122 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "license": "MIT", "homepage": "http://expressjs.com/", "dependencies": { - "accepts": "~1.1.0", + "accepts": "~1.1.1", "cookie-signature": "1.0.5", "debug": "~2.0.0", "depd": "0.4.5", From 61da3c7d0ec6cdf46f6926d44b1e65dc61707591 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 8 Oct 2014 21:50:08 -0400 Subject: [PATCH 0596/1265] deps: serve-static@~1.6.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f98b9b4067b..f2e77ee7bb2 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * deps: accepts@~1.1.1 - deps: mime-types@~2.0.2 - deps: negotiator@0.4.8 + * deps: serve-static@~1.6.4 + - Fix redirect loop when index file serving disabled 4.9.5 / 2014-09-24 ================== diff --git a/package.json b/package.json index d5c31120122..298a72df82d 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "qs": "2.2.4", "range-parser": "~1.0.2", "send": "0.9.3", - "serve-static": "~1.6.3", + "serve-static": "~1.6.4", "type-is": "~1.5.1", "vary": "~1.0.0", "cookie": "0.1.2", From 3f2454e3dfec27df00212075ed760b922751d2b6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 8 Oct 2014 21:51:10 -0400 Subject: [PATCH 0597/1265] deps: type-is@~1.5.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f2e77ee7bb2..3e50db7d1bf 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,8 @@ unreleased - deps: negotiator@0.4.8 * deps: serve-static@~1.6.4 - Fix redirect loop when index file serving disabled + * deps: type-is@~1.5.2 + - deps: mime-types@~2.0.2 4.9.5 / 2014-09-24 ================== diff --git a/package.json b/package.json index 298a72df82d..e30b7e81393 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "range-parser": "~1.0.2", "send": "0.9.3", "serve-static": "~1.6.4", - "type-is": "~1.5.1", + "type-is": "~1.5.2", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2", From efd2dfb8c82e42b43f3d7f03181381d390d9174d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 8 Oct 2014 22:33:13 -0400 Subject: [PATCH 0598/1265] 4.9.6 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 3e50db7d1bf..bf123a51b7d 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.6 / 2014-10-08 +================== * deps: accepts@~1.1.1 - deps: mime-types@~2.0.2 diff --git a/package.json b/package.json index e30b7e81393..35e5b981442 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.5", + "version": "4.9.6", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 94f10c26cb6f84960bf2d61cecaf0d64fa5c03da Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 10 Oct 2014 16:31:09 -0400 Subject: [PATCH 0599/1265] Fix using same param name in array of paths fixes #2389 --- History.md | 5 +++++ lib/router/layer.js | 16 ++++++++++++---- test/app.router.js | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index bf123a51b7d..8c93cc8a15c 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix using same param name in array of paths + 4.9.6 / 2014-10-08 ================== diff --git a/lib/router/layer.js b/lib/router/layer.js index e292a13a895..3f15002383e 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -5,6 +5,12 @@ var pathRegexp = require('path-to-regexp'); var debug = require('debug')('express:router:layer'); +/** + * Module variables. + */ + +var hasOwnProperty = Object.prototype.hasOwnProperty; + /** * Expose `Layer`. */ @@ -110,18 +116,20 @@ Layer.prototype.match = function match(path) { var keys = this.keys; var params = this.params; + var prop; var n = 0; var key; var val; for (var i = 1, len = m.length; i < len; ++i) { key = keys[i - 1]; + prop = key + ? key.name + : n++; val = decode_param(m[i]); - if (key) { - params[key.name] = val; - } else { - params[n++] = val; + if (val !== undefined || !(hasOwnProperty.call(params, prop))) { + params[prop] = val; } } diff --git a/test/app.router.js b/test/app.router.js index ad05a79f517..4f170ec64ad 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -679,6 +679,23 @@ describe('app.router', function(){ .get('/user/tj/edit') .expect('editing tj', done); }) + + it('should work in array of paths', function(done){ + var app = express(); + var cb = after(2, done); + + app.get(['/user/:user/poke', '/user/:user/pokes'], function(req, res){ + res.end('poking ' + req.params.user); + }); + + request(app) + .get('/user/tj/poke') + .expect('poking tj', cb); + + request(app) + .get('/user/tj/pokes') + .expect('poking tj', cb); + }) }) describe(':name?', function(){ From b0e4e641f93e422e4704f79f2ba3d3dcd0c5d8e6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 10 Oct 2014 16:40:46 -0400 Subject: [PATCH 0600/1265] 4.9.7 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 8c93cc8a15c..ef605753d3e 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.7 / 2014-10-10 +================== * Fix using same param name in array of paths diff --git a/package.json b/package.json index 35e5b981442..3cd2773525a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.6", + "version": "4.9.7", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From be478d348c56e5961746dc95b4c0305eb1d6b5a9 Mon Sep 17 00:00:00 2001 From: Bessie Chan Date: Sat, 11 Oct 2014 13:04:59 -0700 Subject: [PATCH 0601/1265] Fix typo in res.redirect deprecation closes #2395 --- lib/response.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/response.js b/lib/response.js index 822b849187e..0950062e39b 100644 --- a/lib/response.js +++ b/lib/response.js @@ -738,7 +738,7 @@ res.redirect = function(url){ status = url; url = arguments[1]; } else { - deprecate('res.redirect(ur, status): Use res.redirect(status, url) instead'); + deprecate('res.redirect(url, status): Use res.redirect(status, url) instead'); status = arguments[1]; } } From 33959ed350bbf8d48ac311ec83a94fde693b0bda Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Oct 2014 00:19:47 -0400 Subject: [PATCH 0602/1265] deps: mocha@~1.21.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f4f9fc819b..2ca5c9d35c9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "devDependencies": { "connect-redis": "~1.5.0", "istanbul": "0.3.2", - "mocha": "~1.21.4", + "mocha": "~1.21.5", "should": "~4.0.0", "supertest": "~0.14.0", "ejs": "~1.0.0", From 159ea677135c5c0d8f5791bc5f9d3d62e29acc1f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Oct 2014 00:24:28 -0400 Subject: [PATCH 0603/1265] deps: connect@2.26.6 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 8b402228551..ad3885b0481 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +3.x +=== + + * deps: connect@2.26.6 + - deps: compression@~1.1.2 + - deps: csurf@~1.6.2 + - deps: errorhandler@~1.2.2 + 3.17.7 / 2014-10-08 =================== diff --git a/package.json b/package.json index 2ca5c9d35c9..f5a84f9333e 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", - "connect": "2.26.5", + "connect": "2.26.6", "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", From 6d39d0f8a809eed1b75e0d5bd4d2dad3d2190f25 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Oct 2014 00:29:56 -0400 Subject: [PATCH 0604/1265] 3.17.8 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index ad3885b0481..9ade9e0bddb 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.17.8 / 2014-10-15 +=================== * deps: connect@2.26.6 - deps: compression@~1.1.2 diff --git a/package.json b/package.json index f5a84f9333e..9550df474d0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.7", + "version": "3.17.8", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 6f914160209c16c640d36db8565a968c4e63d3dc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Oct 2014 01:29:00 -0400 Subject: [PATCH 0605/1265] deps: accepts@~1.1.2 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e49253ae190..1db825eb694 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +unreleased +========== + + * deps: accepts@~1.1.2 + - Fix error when media type has invalid parameter + - deps: negotiator@0.4.9 + 4.9.7 / 2014-10-10 ================== diff --git a/package.json b/package.json index 31669009aab..5371d3af9dd 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "license": "MIT", "homepage": "http://expressjs.com/", "dependencies": { - "accepts": "~1.1.1", + "accepts": "~1.1.2", "cookie-signature": "1.0.5", "debug": "~2.0.0", "depd": "0.4.5", From a7064082085e41db5ddbfa97a4021a722ecd3d8f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 20:42:12 -0400 Subject: [PATCH 0606/1265] deps: connect@2.27.0 --- History.md | 20 ++++++++++++++++++++ package.json | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9ade9e0bddb..b4c6f055a36 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,23 @@ +3.x +=== + + * deps: connect@2.27.0 + - Use `http-errors` module for creating errors + - Use `utils-merge` module for merging objects + - deps: body-parser@~1.9.0 + - deps: compression@~1.2.0 + - deps: connect-timeout@~1.4.0 + - deps: debug@~2.1.0 + - deps: depd@~1.0.0 + - deps: express-session@~1.9.0 + - deps: finalhandler@0.3.1 + - deps: method-override@~2.3.0 + - deps: morgan@~1.4.0 + - deps: response-time@~2.2.0 + - deps: serve-favicon@~2.1.6 + - deps: serve-index@~1.5.0 + - deps: serve-static@~1.7.0 + 3.17.8 / 2014-10-15 =================== diff --git a/package.json b/package.json index 9550df474d0..f627c3411da 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "homepage": "http://expressjs.com/", "dependencies": { "basic-auth": "1.0.0", - "connect": "2.26.6", + "connect": "2.27.0", "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", From 2e20a858100c0d3cbb611949eb25734709717fb9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 20:43:23 -0400 Subject: [PATCH 0607/1265] deps: debug@~2.1.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b4c6f055a36..eae9e92840d 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,8 @@ - deps: serve-favicon@~2.1.6 - deps: serve-index@~1.5.0 - deps: serve-static@~1.7.0 + * deps: debug@~2.1.0 + - Implement `DEBUG_FD` env variable support 3.17.8 / 2014-10-15 =================== diff --git a/package.json b/package.json index f627c3411da..0a665a89a98 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", - "debug": "~2.0.0", + "debug": "~2.1.0", "depd": "0.4.5", "escape-html": "1.0.1", "fresh": "0.2.4", From bc9d8547632189f6bca6fe020e1329d3881a69dd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 20:44:07 -0400 Subject: [PATCH 0608/1265] deps: depd@~1.0.0 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index eae9e92840d..7df29de829d 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,7 @@ - deps: serve-static@~1.7.0 * deps: debug@~2.1.0 - Implement `DEBUG_FD` env variable support + * deps: depd@~1.0.0 3.17.8 / 2014-10-15 =================== diff --git a/package.json b/package.json index 0a665a89a98..285a0791172 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "cookie-signature": "1.0.5", "crc": "3.0.0", "debug": "~2.1.0", - "depd": "0.4.5", + "depd": "~1.0.0", "escape-html": "1.0.1", "fresh": "0.2.4", "media-typer": "0.3.0", From 7488e2760913494de753b199df03ac2a1090f03f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 20:45:09 -0400 Subject: [PATCH 0609/1265] deps: send@0.10.0 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7df29de829d..d440da8b230 100644 --- a/History.md +++ b/History.md @@ -20,6 +20,10 @@ * deps: debug@~2.1.0 - Implement `DEBUG_FD` env variable support * deps: depd@~1.0.0 + * deps: send@0.10.0 + - deps: debug@~2.1.0 + - deps: depd@~1.0.0 + - deps: etag@~1.5.0 3.17.8 / 2014-10-15 =================== diff --git a/package.json b/package.json index 285a0791172..2848f6a064e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.3", "range-parser": "~1.0.2", - "send": "0.9.3", + "send": "0.10.0", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2" From b766aad1125edacf7ea765880e68c0ed248e4216 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 20:45:57 -0400 Subject: [PATCH 0610/1265] deps: jade@~1.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2848f6a064e..d3d48e4dbde 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "should": "~4.0.0", "supertest": "~0.14.0", "ejs": "~1.0.0", - "jade": "~1.6.0", + "jade": "~1.7.0", "hjs": "~0.0.6", "marked": "0.3.2" }, From 7a7f18c20bb5a0edd15092f743a269ce09e9422e Mon Sep 17 00:00:00 2001 From: Fishrock123 Date: Mon, 13 Oct 2014 13:41:45 -0400 Subject: [PATCH 0611/1265] build: misc. updates to packaging closes #2398 --- .gitignore | 38 ++++++++++++++++++++++++-------------- .npmignore | 10 ---------- package.json | 15 +++++++++++---- 3 files changed, 35 insertions(+), 28 deletions(-) delete mode 100644 .npmignore diff --git a/.gitignore b/.gitignore index e5deefa24ef..9723e60591d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,26 @@ -coverage/ -.DS_Store -*.seed +# OS X +.DS_Store* +Icon? +._* + +# Windows +Thumbs.db +ehthumbs.db +Desktop.ini + +# Linux +.directory +*~ + + +# npm +node_modules *.log -*.csv -*.dat -*.out -*.pid -*.swp -*.swo +*.gz + + +# Coveralls +coverage + +# Benchmarking benchmarks/graphs -testing -node_modules/ -testing -test.js -.idea diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 8c029e8c207..00000000000 --- a/.npmignore +++ /dev/null @@ -1,10 +0,0 @@ -.git* -benchmarks/ -coverage/ -docs/ -examples/ -support/ -test/ -testing.js -.DS_Store -.travis.yml diff --git a/package.json b/package.json index d3d48e4dbde..63df56002d5 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,9 @@ "Jonathan Ong ", "Roman Shtylman Date: Fri, 17 Oct 2014 21:08:05 -0400 Subject: [PATCH 0612/1265] Use content-disposition module --- History.md | 3 +++ lib/response.js | 21 +++++++++++++-------- package.json | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/History.md b/History.md index d440da8b230..a2bf229506c 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,9 @@ 3.x === + * Use `content-disposition` module for `res.attachment`/`res.download` + - Sends standards-compliant `Content-Disposition` header + - Full Unicode support * deps: connect@2.27.0 - Use `http-errors` module for creating errors - Use `utils-merge` module for merging objects diff --git a/lib/response.js b/lib/response.js index 0950062e39b..ba6e0e4ad3d 100644 --- a/lib/response.js +++ b/lib/response.js @@ -2,6 +2,7 @@ * Module dependencies. */ +var contentDisposition = require('content-disposition'); var deprecate = require('depd')('express'); var escapeHtml = require('escape-html'); var parseUrl = require('parseurl'); @@ -413,15 +414,17 @@ res.sendfile = function(path, options, fn){ * @api public */ -res.download = function(path, filename, fn){ +res.download = function download(path, filename, fn) { // support function as second arg - if ('function' == typeof filename) { + if (typeof filename === 'function') { fn = filename; filename = null; } filename = filename || path; - this.set('Content-Disposition', 'attachment; filename="' + basename(filename) + '"'); + + this.set('Content-Disposition', contentDisposition(filename)); + return this.sendfile(path, fn); }; @@ -544,11 +547,13 @@ res.format = function(obj){ * @api public */ -res.attachment = function(filename){ - if (filename) this.type(extname(filename)); - this.set('Content-Disposition', filename - ? 'attachment; filename="' + basename(filename) + '"' - : 'attachment'); +res.attachment = function attachment(filename) { + if (filename) { + this.type(extname(filename)); + } + + this.set('Content-Disposition', contentDisposition(filename)); + return this; }; diff --git a/package.json b/package.json index 63df56002d5..c2771189492 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "dependencies": { "basic-auth": "1.0.0", "connect": "2.27.0", + "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", "crc": "3.0.0", From 6f0302fb78f636da320d3ffd329c18fed36aeda9 Mon Sep 17 00:00:00 2001 From: Alex Upadhyay Date: Sat, 18 Oct 2014 01:12:47 +0000 Subject: [PATCH 0613/1265] Fix res.redirect body when redirect status specified fixes #2402 fixes #2404 --- History.md | 1 + lib/response.js | 4 ++-- test/res.redirect.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 1db825eb694..7e3f4528725 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix `res.redirect` body when redirect status specified * deps: accepts@~1.1.2 - Fix error when media type has invalid parameter - deps: negotiator@0.4.9 diff --git a/lib/response.js b/lib/response.js index 32c098af209..c26f68ac8ab 100644 --- a/lib/response.js +++ b/lib/response.js @@ -818,11 +818,11 @@ res.redirect = function redirect(url) { // Support text/{plain,html} by default this.format({ text: function(){ - body = statusCodes[status] + '. Redirecting to ' + encodeURI(url); + body = statusCodes[status] + '. Redirecting to ' + encodeURI(address); }, html: function(){ - var u = escapeHtml(url); + var u = escapeHtml(address); body = '

' + statusCodes[status] + '. Redirecting to ' + u + '

'; }, diff --git a/test/res.redirect.js b/test/res.redirect.js index 08ce6e60764..4044ad49ee5 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -106,6 +106,21 @@ describe('res', function(){ done(); }) }) + + it('should include the redirect type', function(done){ + var app = express(); + + app.use(function(req, res){ + res.redirect(301, 'http://google.com'); + }); + + request(app) + .get('/') + .set('Accept', 'text/html') + .expect('Content-Type', /html/) + .expect('Location', 'http://google.com') + .expect(301, '

Moved Permanently. Redirecting to http://google.com

', done); + }) }) describe('when accepting text', function(){ @@ -143,6 +158,21 @@ describe('res', function(){ done(); }) }) + + it('should include the redirect type', function(done){ + var app = express(); + + app.use(function(req, res){ + res.redirect(301, 'http://google.com'); + }); + + request(app) + .get('/') + .set('Accept', 'text/plain, */*') + .expect('Content-Type', /plain/) + .expect('Location', 'http://google.com') + .expect(301, 'Moved Permanently. Redirecting to http://google.com', done); + }) }) describe('when accepting neither text or html', function(){ From f15bba7309f2e0a17f7b7a5552b9618f074078c8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 22:01:51 -0400 Subject: [PATCH 0614/1265] 4.9.8 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 7e3f4528725..17ba278ac98 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.9.8 / 2014-10-17 +================== * Fix `res.redirect` body when redirect status specified * deps: accepts@~1.1.2 diff --git a/package.json b/package.json index 5371d3af9dd..a1f7132db83 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.7", + "version": "4.9.8", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 4f1cd4f73c2b7ee441d375b819acf6428242d557 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 21:13:06 -0400 Subject: [PATCH 0615/1265] deps: etag@~1.5.0 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 17ba278ac98..6cc2877fde0 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +unreleased +========== + + * deps: etag@~1.5.0 + - Improve string performance + - Slightly improve speed for weak ETags over 1KB + 4.9.8 / 2014-10-17 ================== diff --git a/package.json b/package.json index a1f7132db83..9f6f1205cc3 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "debug": "~2.0.0", "depd": "0.4.5", "escape-html": "1.0.1", - "etag": "~1.4.0", + "etag": "~1.5.0", "finalhandler": "0.2.0", "fresh": "0.2.4", "media-typer": "0.3.0", From 6cd48590356c85230ad9b85435b8ee39ce54897d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 21:26:47 -0400 Subject: [PATCH 0616/1265] deps: finalhandler@0.3.1 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6cc2877fde0..dcf9ca33ce7 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,10 @@ unreleased * deps: etag@~1.5.0 - Improve string performance - Slightly improve speed for weak ETags over 1KB + * deps: finalhandler@0.3.1 + - Terminate in progress response only on error + - Use `on-finished` to determine request status + - deps: debug@~2.1.0 4.9.8 / 2014-10-17 ================== diff --git a/package.json b/package.json index 9f6f1205cc3..e4a4bde01e3 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "depd": "0.4.5", "escape-html": "1.0.1", "etag": "~1.5.0", - "finalhandler": "0.2.0", + "finalhandler": "0.3.1", "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", From 6f31218ecc9170daf2f907a1f98d423ba73eb2d8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 17 Oct 2014 23:45:58 -0400 Subject: [PATCH 0617/1265] Use content-disposition module --- History.md | 3 +++ lib/response.js | 10 +++++++--- lib/utils.js | 16 ++++------------ package.json | 1 + test/res.attachment.js | 6 ++---- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/History.md b/History.md index dcf9ca33ce7..eed38323000 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,9 @@ unreleased ========== + * Use `content-disposition` module for `res.attachment`/`res.download` + - Sends standards-compliant `Content-Disposition` header + - Full Unicode support * deps: etag@~1.5.0 - Improve string performance - Slightly improve speed for weak ETags over 1KB diff --git a/lib/response.js b/lib/response.js index c26f68ac8ab..5ba7aaf9f60 100644 --- a/lib/response.js +++ b/lib/response.js @@ -2,6 +2,7 @@ * Module dependencies. */ +var contentDisposition = require('content-disposition'); var deprecate = require('depd')('express'); var escapeHtml = require('escape-html'); var http = require('http'); @@ -13,7 +14,6 @@ var sign = require('cookie-signature').sign; var normalizeType = require('./utils').normalizeType; var normalizeTypes = require('./utils').normalizeTypes; var setCharset = require('./utils').setCharset; -var contentDisposition = require('./utils').contentDisposition; var statusCodes = http.STATUS_CODES; var cookie = require('cookie'); var send = require('send'); @@ -626,9 +626,13 @@ res.format = function(obj){ * @api public */ -res.attachment = function(filename){ - if (filename) this.type(extname(filename)); +res.attachment = function attachment(filename) { + if (filename) { + this.type(extname(filename)); + } + this.set('Content-Disposition', contentDisposition(filename)); + return this; }; diff --git a/lib/utils.js b/lib/utils.js index 8dd29664cb2..4f7b365f4c5 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -2,6 +2,8 @@ * Module dependencies. */ +var contentDisposition = require('content-disposition'); +var deprecate = require('depd')('express'); var mime = require('send').mime; var basename = require('path').basename; var etag = require('etag'); @@ -120,18 +122,8 @@ exports.normalizeTypes = function(types){ * @api private */ -exports.contentDisposition = function(filename){ - var ret = 'attachment'; - if (filename) { - filename = basename(filename); - // if filename contains non-ascii characters, add a utf-8 version ala RFC 5987 - ret = /[^\040-\176]/.test(filename) - ? 'attachment; filename="' + encodeURI(filename) + '"; filename*=UTF-8\'\'' + encodeURI(filename) - : 'attachment; filename="' + filename + '"'; - } - - return ret; -}; +exports.contentDisposition = deprecate.function(contentDisposition, + 'utils.contentDisposition: use content-disposition npm module instead'); /** * Parse accept params `str` returning an diff --git a/package.json b/package.json index e4a4bde01e3..d78c88cec15 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "homepage": "http://expressjs.com/", "dependencies": { "accepts": "~1.1.2", + "content-disposition": "0.5.0", "cookie-signature": "1.0.5", "debug": "~2.0.0", "depd": "0.4.5", diff --git a/test/res.attachment.js b/test/res.attachment.js index be189344749..662b1dd4e01 100644 --- a/test/res.attachment.js +++ b/test/res.attachment.js @@ -56,10 +56,8 @@ describe('res', function(){ request(app) .get('/') - .expect('Content-Disposition', 'attachment;' + - ' filename="%E6%97%A5%E6%9C%AC%E8%AA%9E.txt";' + - ' filename*=UTF-8\'\'%E6%97%A5%E6%9C%AC%E8%AA%9E.txt', - done); + .expect('Content-Disposition', 'attachment; filename="???.txt"; filename*=UTF-8\'\'%E6%97%A5%E6%9C%AC%E8%AA%9E.txt') + .expect(200, done); }) it('should set the Content-Type', function(done){ From 4d1ee23f84de64a4f317384f61d1cd9925849107 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 18 Oct 2014 00:53:17 -0400 Subject: [PATCH 0618/1265] Use etag module to generate ETag headers --- History.md | 1 + lib/utils.js | 35 ++++++++++++----------------------- package.json | 2 +- test/res.send.js | 12 ++++++------ test/utils.js | 6 +++--- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/History.md b/History.md index a2bf229506c..29fa5a9af5c 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ * Use `content-disposition` module for `res.attachment`/`res.download` - Sends standards-compliant `Content-Disposition` header - Full Unicode support + * Use `etag` module to generate `ETag` headers * deps: connect@2.27.0 - Use `http-errors` module for creating errors - Use `utils-merge` module for merging objects diff --git a/lib/utils.js b/lib/utils.js index 7497fe8eb1b..b9ff7bbdf68 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,10 +3,9 @@ * Module dependencies. */ -var crc = require('crc').crc32; -var mime = require('connect').mime - , proxyaddr = require('proxy-addr') - , crypto = require('crypto'); +var etag = require('etag'); +var mime = require('connect').mime; +var proxyaddr = require('proxy-addr'); var typer = require('media-typer'); /** @@ -24,17 +23,12 @@ var toString = {}.toString; * @api private */ -exports.etag = function etag(body, encoding){ - if (body.length === 0) { - // fast-path empty body - return '"1B2M2Y8AsgTpgAmY7PhCfg=="' - } +exports.etag = function (body, encoding) { + var buf = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body; - var hash = crypto - .createHash('md5') - .update(body, encoding) - .digest('base64') - return '"' + hash + '"' + return etag(buf, {weak: false}); }; /** @@ -47,16 +41,11 @@ exports.etag = function etag(body, encoding){ */ exports.wetag = function wetag(body, encoding){ - if (body.length === 0) { - // fast-path empty body - return 'W/"0-0"' - } + var buf = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body; - var buf = Buffer.isBuffer(body) - ? body - : new Buffer(body, encoding) - var len = buf.length - return 'W/"' + len.toString(16) + '-' + crc(buf) + '"' + return etag(buf, {weak: true}); }; /** diff --git a/package.json b/package.json index c2771189492..a398c117d5f 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,10 @@ "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", - "crc": "3.0.0", "debug": "~2.1.0", "depd": "~1.0.0", "escape-html": "1.0.1", + "etag": "~1.5.0", "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", diff --git a/test/res.send.js b/test/res.send.js index a73353c84b2..ad1a703f32b 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -120,7 +120,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"7ff-2796319984"') + .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') .end(done); }) @@ -209,7 +209,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"7ff-2796319984"') + .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') .end(done); }) @@ -325,7 +325,7 @@ describe('res', function(){ request(app) .get('/') - .set('If-None-Match', 'W/"7ff-2796319984"') + .set('If-None-Match', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') .expect(304, done); }) @@ -371,7 +371,7 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"c-1525560792"', done) + .expect('etag', 'W/"c-5aee35d8"', done) }) it('should send ETag for empty string response', function(done){ @@ -400,7 +400,7 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"7ff-2796319984"', done) + .expect('etag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="', done) }); it('should not override ETag when manually set', function(done){ @@ -499,7 +499,7 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"d-1486392595"', done) + .expect('etag', 'W/"d-58988d13"', done) }) }) diff --git a/test/utils.js b/test/utils.js index 21594c409e8..b811762c591 100644 --- a/test/utils.js +++ b/test/utils.js @@ -28,18 +28,18 @@ describe('utils.etag(body, encoding)', function(){ describe('utils.wetag(body, encoding)', function(){ it('should support strings', function(){ utils.wetag('express!') - .should.eql('W/"8-3098196679"') + .should.eql('W/"8-b8aabac7"') }) it('should support utf8 strings', function(){ utils.wetag('express❤', 'utf8') - .should.eql('W/"a-1751845617"') + .should.eql('W/"a-686b0af1"') }) it('should support buffer', function(){ var buf = new Buffer('express!') utils.wetag(buf) - .should.eql('W/"8-3098196679"'); + .should.eql('W/"8-b8aabac7"'); }) it('should support empty string', function(){ From 366000184f6fa2ae39b96c4806c7ab625a01e71c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 18 Oct 2014 00:57:48 -0400 Subject: [PATCH 0619/1265] 3.18.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 29fa5a9af5c..b73e51abbd5 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.18.0 / 2014-10-17 +=================== * Use `content-disposition` module for `res.attachment`/`res.download` - Sends standards-compliant `Content-Disposition` header diff --git a/package.json b/package.json index a398c117d5f..ebc30581575 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.17.8", + "version": "3.18.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 9c2c21aaaf2c552ecd0319e322c3cf5397b29539 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Oct 2014 15:08:49 -0400 Subject: [PATCH 0620/1265] deps: mocha@~2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ebc30581575..42c9d881d6f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "devDependencies": { "connect-redis": "~1.5.0", "istanbul": "0.3.2", - "mocha": "~1.21.5", + "mocha": "~2.0.0", "should": "~4.0.0", "supertest": "~0.14.0", "ejs": "~1.0.0", From dd763ec5b8a93419d5524f42998db1774f5bfafa Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Oct 2014 15:10:22 -0400 Subject: [PATCH 0621/1265] deps: should@~4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 42c9d881d6f..fc93f98580a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "connect-redis": "~1.5.0", "istanbul": "0.3.2", "mocha": "~2.0.0", - "should": "~4.0.0", + "should": "~4.1.0", "supertest": "~0.14.0", "ejs": "~1.0.0", "jade": "~1.7.0", From af1043844f3e23ee21fc9584a5074fb3e73437fb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Oct 2014 15:18:10 -0400 Subject: [PATCH 0622/1265] Fix internal utils.merge deprecation warnings --- History.md | 5 +++++ lib/application.js | 10 ++++++---- lib/express.js | 10 +++++----- lib/response.js | 6 +++--- package.json | 1 + test/res.cookie.js | 4 ++-- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/History.md b/History.md index b73e51abbd5..d932d10b2b7 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.x +=== + + * Fix internal `utils.merge` deprecation warnings + 3.18.0 / 2014-10-17 =================== diff --git a/lib/application.js b/lib/application.js index 5be5ad45e98..1909fd95754 100644 --- a/lib/application.js +++ b/lib/application.js @@ -11,9 +11,9 @@ var connect = require('connect') , compileETag = require('./utils').compileETag , compileTrust = require('./utils').compileTrust , View = require('./view') - , utils = connect.utils , http = require('http'); var deprecate = require('depd')('express'); +var merge = require('utils-merge'); /** * Application prototype. @@ -484,13 +484,15 @@ app.render = function(name, options, fn){ } // merge app.locals - utils.merge(opts, this.locals); + merge(opts, this.locals); // merge options._locals - if (options._locals) utils.merge(opts, options._locals); + if (options._locals) { + merge(opts, options._locals); + } // merge options - utils.merge(opts, options); + merge(opts, options); // set .cache unless explicitly provided opts.cache = null == opts.cache diff --git a/lib/express.js b/lib/express.js index 8a976daa4b8..17b32c58e78 100644 --- a/lib/express.js +++ b/lib/express.js @@ -3,14 +3,14 @@ */ var deprecate = require('depd')('express'); -var merge = require('merge-descriptors'); +var mixin = require('merge-descriptors'); +var merge = require('utils-merge'); var connect = require('connect') , proto = require('./application') , Route = require('./router/route') , Router = require('./router') , req = require('./request') - , res = require('./response') - , utils = connect.utils; + , res = require('./response'); /** * Expose `createApplication()`. @@ -33,7 +33,7 @@ exports.mime = connect.mime; function createApplication() { var app = connect(); - utils.merge(app, proto); + merge(app, proto); app.request = { __proto__: req, app: app }; app.response = { __proto__: res, app: app }; app.init(); @@ -45,7 +45,7 @@ function createApplication() { * for example `express.logger` etc. */ -merge(exports, connect.middleware); +mixin(exports, connect.middleware); /** * Deprecated createServer(). diff --git a/lib/response.js b/lib/response.js index ba6e0e4ad3d..9404d34f606 100644 --- a/lib/response.js +++ b/lib/response.js @@ -5,12 +5,12 @@ var contentDisposition = require('content-disposition'); var deprecate = require('depd')('express'); var escapeHtml = require('escape-html'); +var merge = require('utils-merge'); var parseUrl = require('parseurl'); var vary = require('vary'); var http = require('http') , path = require('path') , connect = require('connect') - , utils = connect.utils , sign = require('cookie-signature').sign , normalizeType = require('./utils').normalizeType , normalizeTypes = require('./utils').normalizeTypes @@ -613,7 +613,7 @@ res.get = function(field){ res.clearCookie = function(name, options){ var opts = { expires: new Date(1), path: '/' }; return this.cookie(name, '', options - ? utils.merge(opts, options) + ? merge(opts, options) : opts); }; @@ -641,7 +641,7 @@ res.clearCookie = function(name, options){ */ res.cookie = function(name, val, options){ - options = utils.merge({}, options); + options = merge({}, options); var secret = this.req.secret; var signed = options.signed; if (signed && !secret) throw new Error('connect.cookieParser("secret") required for signed cookies'); diff --git a/package.json b/package.json index fc93f98580a..212b22990db 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "proxy-addr": "~1.0.3", "range-parser": "~1.0.2", "send": "0.10.0", + "utils-merge": "1.0.0", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2" diff --git a/test/res.cookie.js b/test/res.cookie.js index a00c8d14b40..094d28898a5 100644 --- a/test/res.cookie.js +++ b/test/res.cookie.js @@ -1,8 +1,8 @@ var express = require('../') , request = require('supertest') - , utils = require('connect').utils , cookie = require('cookie'); +var merge = require('utils-merge'); describe('res', function(){ describe('.cookie(name, object)', function(){ @@ -111,7 +111,7 @@ describe('res', function(){ var app = express(); var options = { maxAge: 1000 }; - var optionsCopy = utils.merge({}, options); + var optionsCopy = merge({}, options); app.use(function(req, res){ res.cookie('name', 'tobi', options) From c939a771c0696e6db26b8d16964931c0a738dc7e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:23:54 -0400 Subject: [PATCH 0623/1265] deps: connect@2.27.1 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d932d10b2b7..f4378c722d1 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,13 @@ === * Fix internal `utils.merge` deprecation warnings + * deps: connect@2.27.1 + - deps: body-parser@~1.9.1 + - deps: express-session@~1.9.1 + - deps: finalhandler@0.3.2 + - deps: morgan@~1.4.1 + - deps: qs@2.3.0 + - deps: serve-static@~1.7.1 3.18.0 / 2014-10-17 =================== diff --git a/package.json b/package.json index 212b22990db..a50f706d502 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.27.0", + "connect": "2.27.1", "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", From 5759b3e9f5bf399df8790a8300679fe8ab14d6ac Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:25:07 -0400 Subject: [PATCH 0624/1265] deps: send@0.10.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f4378c722d1..8f215fdd548 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,8 @@ - deps: morgan@~1.4.1 - deps: qs@2.3.0 - deps: serve-static@~1.7.1 + * deps: send@0.10.1 + - deps: on-finished@~2.1.1 3.18.0 / 2014-10-17 =================== diff --git a/package.json b/package.json index a50f706d502..498e272e5ea 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.3", "range-parser": "~1.0.2", - "send": "0.10.0", + "send": "0.10.1", "utils-merge": "1.0.0", "vary": "~1.0.0", "cookie": "0.1.2", From 88dfd36eaafa7a0349401a6142413dbb4030ab78 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:26:21 -0400 Subject: [PATCH 0625/1265] 3.18.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 8f215fdd548..ee2a1f75cfc 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.18.1 / 2014-10-22 +=================== * Fix internal `utils.merge` deprecation warnings * deps: connect@2.27.1 diff --git a/package.json b/package.json index 498e272e5ea..c4aede125c7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.18.0", + "version": "3.18.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 4dd970578a5ec4c8a26e85e7f93296ec2de1cfa5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:35:16 -0400 Subject: [PATCH 0626/1265] Fix res.send to mention res.sendStatus --- History.md | 1 + lib/response.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index eed38323000..b1c6a9012a0 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix `res.send(status)` to mention `res.sendStatus(status)` * Use `content-disposition` module for `res.attachment`/`res.download` - Sends standards-compliant `Content-Disposition` header - Full Unicode support diff --git a/lib/response.js b/lib/response.js index 5ba7aaf9f60..104c3d06fdb 100644 --- a/lib/response.js +++ b/lib/response.js @@ -109,7 +109,7 @@ res.send = function send(body) { this.type('txt'); } - deprecate('res.send(status): Use res.status(status).end() instead'); + deprecate('res.send(status): Use res.sendStatus(status) instead'); this.statusCode = chunk; chunk = http.STATUS_CODES[chunk]; } From 6c2f7fb48d5ed8f4190edf05e961c8304e45ec2a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:37:00 -0400 Subject: [PATCH 0627/1265] deps: finalhandler@0.3.2 --- History.md | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index b1c6a9012a0..f5a01bf9699 100644 --- a/History.md +++ b/History.md @@ -8,10 +8,11 @@ unreleased * deps: etag@~1.5.0 - Improve string performance - Slightly improve speed for weak ETags over 1KB - * deps: finalhandler@0.3.1 + * deps: finalhandler@0.3.2 - Terminate in progress response only on error - Use `on-finished` to determine request status - deps: debug@~2.1.0 + - deps: on-finished@~2.1.1 4.9.8 / 2014-10-17 ================== diff --git a/package.json b/package.json index d78c88cec15..e76e398d51d 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "depd": "0.4.5", "escape-html": "1.0.1", "etag": "~1.5.0", - "finalhandler": "0.3.1", + "finalhandler": "0.3.2", "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", From 6a5dd52deb8ba4f105f7d14d14a18b4a11d19254 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:38:48 -0400 Subject: [PATCH 0628/1265] deps: qs@2.3.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f5a01bf9699..75b4d9d0fe9 100644 --- a/History.md +++ b/History.md @@ -13,6 +13,8 @@ unreleased - Use `on-finished` to determine request status - deps: debug@~2.1.0 - deps: on-finished@~2.1.1 + * deps: qs@2.3.0 + - Fix parsing of mixed implicit and explicit arrays 4.9.8 / 2014-10-17 ================== diff --git a/package.json b/package.json index e76e398d51d..06f7a7c6420 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.3", - "qs": "2.2.4", + "qs": "2.3.0", "range-parser": "~1.0.2", "send": "0.9.3", "serve-static": "~1.6.4", From ce7bbae007e80a8dd80afff1b76758b589305149 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:43:19 -0400 Subject: [PATCH 0629/1265] deps: serve-static@~1.7.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 75b4d9d0fe9..9811a2c2851 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,8 @@ unreleased - deps: on-finished@~2.1.1 * deps: qs@2.3.0 - Fix parsing of mixed implicit and explicit arrays + * deps: serve-static@~1.7.1 + - deps: send@0.10.1 4.9.8 / 2014-10-17 ================== diff --git a/package.json b/package.json index 06f7a7c6420..e9c3ac21ede 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "qs": "2.3.0", "range-parser": "~1.0.2", "send": "0.9.3", - "serve-static": "~1.6.4", + "serve-static": "~1.7.1", "type-is": "~1.5.2", "vary": "~1.0.0", "cookie": "0.1.2", From cd9d2ec6a978fd56206375852de887a2d1126d0b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 01:45:58 -0400 Subject: [PATCH 0630/1265] deps: on-finished@~2.1.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9811a2c2851..15ac19cb938 100644 --- a/History.md +++ b/History.md @@ -13,6 +13,8 @@ unreleased - Use `on-finished` to determine request status - deps: debug@~2.1.0 - deps: on-finished@~2.1.1 + * deps: on-finished@~2.1.1 + - Fix handling of pipelined requests * deps: qs@2.3.0 - Fix parsing of mixed implicit and explicit arrays * deps: serve-static@~1.7.1 diff --git a/package.json b/package.json index e9c3ac21ede..c4884d4df99 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", - "on-finished": "~2.1.0", + "on-finished": "~2.1.1", "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.3", From ff3a368b2f9a7e640fb3fd18f116de5352e73d58 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 02:08:34 -0400 Subject: [PATCH 0631/1265] deps: update example dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f30a497eabd..348517e9f49 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,14 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.8.2", + "body-parser": "~1.9.1", "connect-redis": "~2.1.0", "cookie-parser": "~1.3.3", - "express-session": "~1.8.2", + "express-session": "~1.9.1", "jade": "~1.7.0", - "method-override": "~2.2.0", - "morgan": "~1.3.1", - "multiparty": "~3.3.2", + "method-override": "~2.3.0", + "morgan": "~1.4.1", + "multiparty": "~4.0.0", "vhost": "~3.0.0" }, "engines": { From 5f7a37ee517e172c0762fc3debaf94c066e531f9 Mon Sep 17 00:00:00 2001 From: Fishrock123 Date: Sat, 11 Oct 2014 14:12:03 -0400 Subject: [PATCH 0632/1265] docs: misc. tweaks closes #2394 --- Readme.md | 95 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/Readme.md b/Readme.md index 426bb723f24..8dacd469463 100644 --- a/Readme.md +++ b/Readme.md @@ -2,10 +2,10 @@ Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). - [![NPM Version](https://img.shields.io/npm/v/express.svg?style=flat)](https://www.npmjs.org/package/express) - [![Build Status](https://img.shields.io/travis/strongloop/express.svg?style=flat)](https://travis-ci.org/strongloop/express) - [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg?style=flat)](https://coveralls.io/r/strongloop/express) - [![Gittip](https://img.shields.io/gittip/dougwilson.svg?style=flat)](https://www.gittip.com/dougwilson/) + [![NPM Version][npm-image]][npm-url] + [![NPM Downloads][downloads-image]][downloads-url] + [![Build Status][travis-image]][travis-url] + [![Test Coverage][coveralls-image]][coveralls-url] ```js var express = require('express') @@ -18,14 +18,34 @@ app.get('/', function (req, res) { app.listen(3000) ``` - **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x). - ### Installation ```bash $ npm install express ``` +## Features + + * Robust routing + * Focus on high performance + * Super-high test coverage + * HTTP helpers (redirection, caching, etc) + * View system supporting 14+ template engines + * Content negotiation + * Executable for generating applications quickly + +## Docs & Community + + * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)] + * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC + * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules + * Visit the [Wiki](https://github.com/strongloop/express/wiki) + * [Google Group](https://groups.google.com/group/express-js) for discussion + * [Русскоязычная документация](http://jsman.ru/express/) + * [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)] + +**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x). + ## Quick Start The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below: @@ -54,16 +74,6 @@ $ npm install $ npm start ``` -## Features - - * Robust routing - * HTTP helpers (redirection, caching, etc) - * View system supporting 14+ template engines - * Content negotiation - * Focus on high performance - * Executable for generating applications quickly - * High test coverage - ## Philosophy The Express philosophy is to provide small, robust tooling for HTTP servers, making @@ -74,20 +84,9 @@ $ npm start 14 template engines via [Consolidate.js](https://github.com/visionmedia/consolidate.js), you can quickly craft your perfect framework. -## More Information +## Examples - * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)] - * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules - * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC - * Visit the [Wiki](https://github.com/strongloop/express/wiki) - * [Google Group](https://groups.google.com/group/express-js) for discussion - * [Русскоязычная документация](http://jsman.ru/express/) - * [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)] - * Run express examples [online](https://runnable.com/express) - -## Viewing Examples - - Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies: + To view the examples, clone the Express repo & install the dependancies: ```bash $ git clone git://github.com/strongloop/express.git --depth 1 @@ -97,32 +96,40 @@ $ npm install Then run whichever example you want: - $ node examples/content-negotiation - - You can also view live examples here: - - +```bash +$ node examples/content-negotiation +``` -## Running Tests +## Tests - To run the test suite, first invoke the following command within the repo, installing the development dependencies: + To run the test suite, first install the dependancies, then run `npm test`: ```bash $ npm install +$ npm test ``` - Then run the tests: +### People -```bash -$ npm test -``` +The original author of Express is [TJ Holowaychuk](https://github.com/visionmedia) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia] -### Contributors +The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson] - * Author: [TJ Holowaychuk](https://github.com/visionmedia) - * Lead Maintainer: [Douglas Christopher Wilson](https://github.com/dougwilson) - * [All Contributors](https://github.com/strongloop/express/graphs/contributors) +[List of all contributors](https://github.com/strongloop/express/graphs/contributors) ### License [MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/express.svg?style=flat +[npm-url]: https://npmjs.org/package/express +[downloads-image]: https://img.shields.io/npm/dm/express.svg?style=flat +[downloads-url]: https://npmjs.org/package/express +[travis-image]: https://img.shields.io/travis/strongloop/express.svg?style=flat +[travis-url]: https://travis-ci.org/strongloop/express +[coveralls-image]: https://img.shields.io/coveralls/strongloop/express.svg?style=flat +[coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master +[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg?style=flat +[gratipay-url-visionmedia]: https://gratipay/visionmedia/ +[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg?style=flat +[gratipay-url-dougwilson]: https://gratipay/dougwilson/ From e9539fc7803d287c07c2dd7109a6bed434c27800 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 02:20:51 -0400 Subject: [PATCH 0633/1265] docs: visionmedia is now tj on Github --- Readme.md | 4 ++-- examples/auth/pass.js | 2 +- lib/application.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 8dacd469463..9fe91d2fc6c 100644 --- a/Readme.md +++ b/Readme.md @@ -81,7 +81,7 @@ $ npm start HTTP APIs. Express does not force you to use any specific ORM or template engine. With support for over - 14 template engines via [Consolidate.js](https://github.com/visionmedia/consolidate.js), + 14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js), you can quickly craft your perfect framework. ## Examples @@ -111,7 +111,7 @@ $ npm test ### People -The original author of Express is [TJ Holowaychuk](https://github.com/visionmedia) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia] +The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia] The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson] diff --git a/examples/auth/pass.js b/examples/auth/pass.js index 0779c814bd6..fefb25b66a5 100644 --- a/examples/auth/pass.js +++ b/examples/auth/pass.js @@ -1,5 +1,5 @@ -// check out https://github.com/visionmedia/node-pwd +// check out https://github.com/tj/node-pwd /** * Module dependencies. diff --git a/lib/application.js b/lib/application.js index b9f4198ccb0..d3ba6378822 100644 --- a/lib/application.js +++ b/lib/application.js @@ -247,7 +247,7 @@ app.route = function(path){ * so if you're using ".ejs" extensions you dont need to do anything. * * Some template engines do not follow this convention, the - * [Consolidate.js](https://github.com/visionmedia/consolidate.js) + * [Consolidate.js](https://github.com/tj/consolidate.js) * library was created to map all of node's popular template * engines to follow this convention, thus allowing them to * work seamlessly within Express. From dfa7ee47322777b3f5f942c584239f1c64ba7766 Mon Sep 17 00:00:00 2001 From: lemmy Date: Sat, 6 Sep 2014 21:35:17 +0400 Subject: [PATCH 0634/1265] Pass context to .forEach instead of closure Has a slight performance improvement closes #2347 --- lib/application.js | 16 +++++++--------- lib/router/index.js | 7 +++---- lib/router/route.js | 20 +++++++++----------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/lib/application.js b/lib/application.js index d3ba6378822..15b1405bfa1 100644 --- a/lib/application.js +++ b/lib/application.js @@ -154,7 +154,6 @@ app.handle = function(req, res, done) { app.use = function use(fn) { var offset = 0; var path = '/'; - var self = this; // default path to '/' // disambiguate app.use([fn]) @@ -190,7 +189,7 @@ app.use = function use(fn) { debug('.use app under %s', path); fn.mountpath = path; - fn.parent = self; + fn.parent = this; // restore .app property on req and res router.use(path, function mounted_app(req, res, next) { @@ -203,8 +202,8 @@ app.use = function use(fn) { }); // mounted an app - fn.emit('mount', self); - }); + fn.emit('mount', this); + }, this); return this; }; @@ -278,17 +277,16 @@ app.engine = function(ext, fn){ */ app.param = function(name, fn){ - var self = this; - self.lazyrouter(); + this.lazyrouter(); if (Array.isArray(name)) { name.forEach(function(key) { - self.param(key, fn); - }); + this.param(key, fn); + }, this); return this; } - self._router.param(name, fn); + this._router.param(name, fn); return this; }; diff --git a/lib/router/index.js b/lib/router/index.js index 64fcd1e3ac0..0ca1b6fee5c 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -409,7 +409,6 @@ proto.process_params = function(layer, called, req, res, done) { proto.use = function use(fn) { var offset = 0; var path = '/'; - var self = this; // default path to '/' // disambiguate router.use([fn]) @@ -442,15 +441,15 @@ proto.use = function use(fn) { debug('use %s %s', path, fn.name || ''); var layer = new Layer(path, { - sensitive: self.caseSensitive, + sensitive: this.caseSensitive, strict: false, end: false }, fn); layer.route = undefined; - self.stack.push(layer); - }); + this.stack.push(layer); + }, this); return this; }; diff --git a/lib/router/route.js b/lib/router/route.js index 6b39211921a..903d1a5e218 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -131,7 +131,6 @@ Route.prototype.dispatch = function(req, res, done){ */ Route.prototype.all = function(){ - var self = this; var callbacks = utils.flatten([].slice.call(arguments)); callbacks.forEach(function(fn) { if (typeof fn !== 'function') { @@ -143,16 +142,15 @@ Route.prototype.all = function(){ var layer = Layer('/', {}, fn); layer.method = undefined; - self.methods._all = true; - self.stack.push(layer); - }); + this.methods._all = true; + this.stack.push(layer); + }, this); - return self; + return this; }; methods.forEach(function(method){ Route.prototype[method] = function(){ - var self = this; var callbacks = utils.flatten([].slice.call(arguments)); callbacks.forEach(function(fn) { @@ -162,14 +160,14 @@ methods.forEach(function(method){ throw new Error(msg); } - debug('%s %s', method, self.path); + debug('%s %s', method, this.path); var layer = Layer('/', {}, fn); layer.method = method; - self.methods[method] = true; - self.stack.push(layer); - }); - return self; + this.methods[method] = true; + this.stack.push(layer); + }, this); + return this; }; }); From b1d0c19ca16c8f302fb674bc51a19af484170b0c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 02:39:38 -0400 Subject: [PATCH 0635/1265] examples: make main app file names consistent fixes #2408 --- examples/auth/{app.js => index.js} | 0 examples/cookies/{app.js => index.js} | 0 examples/downloads/{app.js => index.js} | 0 examples/params/{app.js => index.js} | 0 examples/resource/{app.js => index.js} | 0 test/acceptance/auth.js | 2 +- test/acceptance/cookies.js | 2 +- test/acceptance/downloads.js | 2 +- test/acceptance/params.js | 2 +- test/acceptance/resource.js | 2 +- 10 files changed, 5 insertions(+), 5 deletions(-) rename examples/auth/{app.js => index.js} (100%) rename examples/cookies/{app.js => index.js} (100%) rename examples/downloads/{app.js => index.js} (100%) rename examples/params/{app.js => index.js} (100%) rename examples/resource/{app.js => index.js} (100%) diff --git a/examples/auth/app.js b/examples/auth/index.js similarity index 100% rename from examples/auth/app.js rename to examples/auth/index.js diff --git a/examples/cookies/app.js b/examples/cookies/index.js similarity index 100% rename from examples/cookies/app.js rename to examples/cookies/index.js diff --git a/examples/downloads/app.js b/examples/downloads/index.js similarity index 100% rename from examples/downloads/app.js rename to examples/downloads/index.js diff --git a/examples/params/app.js b/examples/params/index.js similarity index 100% rename from examples/params/app.js rename to examples/params/index.js diff --git a/examples/resource/app.js b/examples/resource/index.js similarity index 100% rename from examples/resource/app.js rename to examples/resource/index.js diff --git a/test/acceptance/auth.js b/test/acceptance/auth.js index 2645f7b68e4..9a36ea45feb 100644 --- a/test/acceptance/auth.js +++ b/test/acceptance/auth.js @@ -1,4 +1,4 @@ -var app = require('../../examples/auth/app') +var app = require('../../examples/auth') var request = require('supertest') function getCookie(res) { diff --git a/test/acceptance/cookies.js b/test/acceptance/cookies.js index f28daa8a64b..86add660c73 100644 --- a/test/acceptance/cookies.js +++ b/test/acceptance/cookies.js @@ -1,5 +1,5 @@ -var app = require('../../examples/cookies/app') +var app = require('../../examples/cookies') , request = require('supertest'); describe('cookies', function(){ diff --git a/test/acceptance/downloads.js b/test/acceptance/downloads.js index 674acb15262..ed9a02f9ced 100644 --- a/test/acceptance/downloads.js +++ b/test/acceptance/downloads.js @@ -1,5 +1,5 @@ -var app = require('../../examples/downloads/app') +var app = require('../../examples/downloads') , request = require('supertest'); describe('downloads', function(){ diff --git a/test/acceptance/params.js b/test/acceptance/params.js index cfa65896e63..5c7e109188a 100644 --- a/test/acceptance/params.js +++ b/test/acceptance/params.js @@ -1,4 +1,4 @@ -var app = require('../../examples/params/app') +var app = require('../../examples/params') var request = require('supertest') describe('params', function(){ diff --git a/test/acceptance/resource.js b/test/acceptance/resource.js index 585d09b43e2..a2db7bd3fd2 100644 --- a/test/acceptance/resource.js +++ b/test/acceptance/resource.js @@ -1,4 +1,4 @@ -var app = require('../../examples/resource/app') +var app = require('../../examples/resource') var request = require('supertest') describe('resource', function(){ From 0e5f2f84eacd085438fcdb83ad0a47d3a86a5dae Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 15:55:17 -0400 Subject: [PATCH 0636/1265] Use path.resolve in view lookup --- History.md | 1 + lib/view.js | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index fc25715224a..037db772646 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased * Use `content-disposition` module for `res.attachment`/`res.download` - Sends standards-compliant `Content-Disposition` header - Full Unicode support + * Use `path.resolve` in view lookup * deps: debug@~2.1.0 - Implement `DEBUG_FD` env variable support * deps: depd@~1.0.0 diff --git a/lib/view.js b/lib/view.js index 989e8bb251d..e51817583f7 100644 --- a/lib/view.js +++ b/lib/view.js @@ -2,14 +2,22 @@ * Module dependencies. */ +var debug = require('debug')('express:view'); var path = require('path'); var fs = require('fs'); var utils = require('./utils'); + +/** + * Module variables. + * @private + */ + var dirname = path.dirname; var basename = path.basename; var extname = path.extname; var exists = fs.existsSync || path.existsSync; var join = path.join; +var resolve = path.resolve; /** * Expose `View`. @@ -52,11 +60,16 @@ function View(name, options) { * @api private */ -View.prototype.lookup = function(path){ +View.prototype.lookup = function lookup(path) { var ext = this.ext; + var root = this.root; + + debug('lookup "%s"', path); + + // resolve the path + path = resolve(root, path); // . - if (!utils.isAbsolute(path)) path = join(this.root, path); if (exists(path)) return path; // /index. @@ -72,6 +85,7 @@ View.prototype.lookup = function(path){ * @api private */ -View.prototype.render = function(options, fn){ +View.prototype.render = function render(options, fn) { + debug('render "%s"', this.path); this.engine(this.path, options, fn); }; From 661435256384165bb656cb7b6046b4138ca24c9e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 17:18:26 -0400 Subject: [PATCH 0637/1265] Add support for app.set('views', array) closes #2320 --- History.md | 2 + lib/application.js | 5 +- lib/view.js | 79 +++++++++++++++++++++----- test/app.render.js | 58 +++++++++++++++++++ test/fixtures/default_layout/name.jade | 1 + test/fixtures/default_layout/user.jade | 1 + test/fixtures/local_layout/user.jade | 1 + test/res.render.js | 48 ++++++++++++++++ 8 files changed, 180 insertions(+), 15 deletions(-) create mode 100644 test/fixtures/default_layout/name.jade create mode 100644 test/fixtures/default_layout/user.jade create mode 100644 test/fixtures/local_layout/user.jade diff --git a/History.md b/History.md index 037db772646..c681d790ebd 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ unreleased ========== + * Add support for `app.set('views', array)` + - Views are looked up in sequence in array of directories * Fix `res.send(status)` to mention `res.sendStatus(status)` * Use `content-disposition` module for `res.attachment`/`res.download` - Sends standards-compliant `Content-Disposition` header diff --git a/lib/application.js b/lib/application.js index 15b1405bfa1..2fbb5503c7b 100644 --- a/lib/application.js +++ b/lib/application.js @@ -513,7 +513,10 @@ app.render = function(name, options, fn){ }); if (!view.path) { - var err = new Error('Failed to lookup view "' + name + '" in views directory "' + view.root + '"'); + var dirs = Array.isArray(view.root) && view.root.length > 1 + ? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"' + : 'directory "' + view.root + '"' + var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs); err.view = view; return fn(err); } diff --git a/lib/view.js b/lib/view.js index e51817583f7..e0989b4ddac 100644 --- a/lib/view.js +++ b/lib/view.js @@ -15,7 +15,6 @@ var utils = require('./utils'); var dirname = path.dirname; var basename = path.basename; var extname = path.extname; -var exists = fs.existsSync || path.existsSync; var join = path.join; var resolve = path.resolve; @@ -53,28 +52,32 @@ function View(name, options) { } /** - * Lookup view by the given `path` + * Lookup view by the given `name` * - * @param {String} path + * @param {String} name * @return {String} * @api private */ -View.prototype.lookup = function lookup(path) { - var ext = this.ext; - var root = this.root; +View.prototype.lookup = function lookup(name) { + var path; + var roots = [].concat(this.root); + + debug('lookup "%s"', name); - debug('lookup "%s"', path); + for (var i = 0; i < roots.length && !path; i++) { + var root = roots[i]; - // resolve the path - path = resolve(root, path); + // resolve the path + var loc = resolve(root, name); + var dir = dirname(loc); + var file = basename(loc); - // . - if (exists(path)) return path; + // resolve the file + path = this.resolve(dir, file); + } - // /index. - path = join(dirname(path), basename(path, ext), 'index' + ext); - if (exists(path)) return path; + return path; }; /** @@ -89,3 +92,51 @@ View.prototype.render = function render(options, fn) { debug('render "%s"', this.path); this.engine(this.path, options, fn); }; + +/** + * Resolve the file within the given directory. + * + * @param {string} dir + * @param {string} file + * @private + */ + +View.prototype.resolve = function resolve(dir, file) { + var ext = this.ext; + var path; + var stat; + + // . + path = join(dir, file); + stat = tryStat(path); + + if (stat && stat.isFile()) { + return path; + } + + // /index. + path = join(dir, basename(file, ext), 'index' + ext); + stat = tryStat(path); + + if (stat && stat.isFile()) { + return path; + } +}; + +/** + * Return a stat, maybe. + * + * @param {string} path + * @return {fs.Stats} + * @private + */ + +function tryStat(path) { + debug('stat "%s"', path); + + try { + return fs.statSync(path); + } catch (e) { + return undefined; + } +} diff --git a/test/app.render.js b/test/app.render.js index 4c4c6934a04..6cf5f616131 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -131,6 +131,64 @@ describe('app', function(){ }) }) + describe('when "views" is given', function(){ + it('should lookup the file in the path', function(done){ + var app = express(); + + app.set('views', __dirname + '/fixtures/default_layout'); + app.locals.user = { name: 'tobi' }; + + app.render('user.jade', function(err, str){ + if (err) return done(err); + str.should.equal('

tobi

'); + done(); + }) + }) + + describe('when array of paths', function(){ + it('should lookup the file in the path', function(done){ + var app = express(); + var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + + app.set('views', views); + app.locals.user = { name: 'tobi' }; + + app.render('user.jade', function(err, str){ + if (err) return done(err); + str.should.equal('tobi'); + done(); + }) + }) + + it('should lookup in later paths until found', function(done){ + var app = express(); + var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + + app.set('views', views); + app.locals.name = 'tobi'; + + app.render('name.jade', function(err, str){ + if (err) return done(err); + str.should.equal('

tobi

'); + done(); + }) + }) + + it('should error if file does not exist', function(done){ + var app = express(); + var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + + app.set('views', views); + app.locals.name = 'tobi'; + + app.render('pet.jade', function(err, str){ + err.message.should.equal('Failed to lookup view "pet.jade" in views directories "' + __dirname + '/fixtures/local_layout" or "' + __dirname + '/fixtures/default_layout"'); + done(); + }) + }) + }) + }) + describe('when a "view" constructor is given', function(){ it('should create an instance of it', function(done){ var app = express(); diff --git a/test/fixtures/default_layout/name.jade b/test/fixtures/default_layout/name.jade new file mode 100644 index 00000000000..ede3527a79e --- /dev/null +++ b/test/fixtures/default_layout/name.jade @@ -0,0 +1 @@ +p= name diff --git a/test/fixtures/default_layout/user.jade b/test/fixtures/default_layout/user.jade new file mode 100644 index 00000000000..623c6654a70 --- /dev/null +++ b/test/fixtures/default_layout/user.jade @@ -0,0 +1 @@ +p= user.name \ No newline at end of file diff --git a/test/fixtures/local_layout/user.jade b/test/fixtures/local_layout/user.jade new file mode 100644 index 00000000000..b58bd0d7404 --- /dev/null +++ b/test/fixtures/local_layout/user.jade @@ -0,0 +1 @@ +span= user.name \ No newline at end of file diff --git a/test/res.render.js b/test/res.render.js index 6d576dc23b7..ee96ad5e777 100644 --- a/test/res.render.js +++ b/test/res.render.js @@ -114,6 +114,54 @@ describe('res', function(){ .expect('

This is an email

', done); }) }) + + describe('when "views" is given', function(){ + it('should lookup the file in the path', function(done){ + var app = express(); + + app.set('views', __dirname + '/fixtures/default_layout'); + + app.use(function(req, res){ + res.render('user.jade', { user: { name: 'tobi' } }); + }); + + request(app) + .get('/') + .expect('

tobi

', done); + }) + + describe('when array of paths', function(){ + it('should lookup the file in the path', function(done){ + var app = express(); + var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + + app.set('views', views); + + app.use(function(req, res){ + res.render('user.jade', { user: { name: 'tobi' } }); + }); + + request(app) + .get('/') + .expect('tobi', done); + }) + + it('should lookup in later paths until found', function(done){ + var app = express(); + var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + + app.set('views', views); + + app.use(function(req, res){ + res.render('name.jade', { name: 'tobi' }); + }); + + request(app) + .get('/') + .expect('

tobi

', done); + }) + }) + }) }) describe('.render(name, option)', function(){ From 68290ee87af9d6366e9d153882463f23f4f6bdb5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 21:33:38 -0400 Subject: [PATCH 0638/1265] Fix handling of invalid empty URLs fixes #2399 --- History.md | 1 + lib/router/layer.js | 7 +++++++ test/Router.js | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/History.md b/History.md index c681d790ebd..b75665ee215 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * Add support for `app.set('views', array)` - Views are looked up in sequence in array of directories * Fix `res.send(status)` to mention `res.sendStatus(status)` + * Fix handling of invalid empty URLs * Use `content-disposition` module for `res.attachment`/`res.download` - Sends standards-compliant `Content-Disposition` header - Full Unicode support diff --git a/lib/router/layer.js b/lib/router/layer.js index 3f15002383e..88ebd3964c2 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -95,6 +95,13 @@ Layer.prototype.handle_request = function handle(req, res, next) { */ Layer.prototype.match = function match(path) { + if (path == null) { + // no path, nothing matches + this.params = undefined; + this.path = undefined; + return false; + } + if (this.regexp.fast_slash) { // fast path non-ending match for / (everything matches) this.params = {}; diff --git a/test/Router.js b/test/Router.js index 85a53312073..db2082a4000 100644 --- a/test/Router.js +++ b/test/Router.js @@ -43,6 +43,16 @@ describe('Router', function(){ router.handle({ url: '/test/route', method: 'GET' }, { end: done }); }); + it('should handle blank URL', function(done){ + var router = new Router(); + + router.use(function (req, res) { + false.should.be.true; + }); + + router.handle({ url: '', method: 'GET' }, {}, done); + }); + describe('.handle', function(){ it('should dispatch', function(done){ var router = new Router(); From d40dc651f3561a4978fdc9c40e7fc802261d99ce Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Oct 2014 22:27:45 -0400 Subject: [PATCH 0639/1265] 4.10.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b75665ee215..baf38d2fa83 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.0 / 2014-10-23 +=================== * Add support for `app.set('views', array)` - Views are looked up in sequence in array of directories diff --git a/package.json b/package.json index 348517e9f49..75d1e51f157 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.9.8", + "version": "4.10.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From eabd4564aaa8d209260497b5f3f2dda3591a9dea Mon Sep 17 00:00:00 2001 From: Aria Stewart Date: Tue, 28 Oct 2014 23:39:03 -0400 Subject: [PATCH 0640/1265] Fix handling of URLs containing :// in the path fixes #2421 --- History.md | 5 +++++ lib/router/index.js | 2 +- test/Router.js | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index baf38d2fa83..1a61ba1901a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix handling of URLs containing `://` in the path + 4.10.0 / 2014-10-23 =================== diff --git a/lib/router/index.js b/lib/router/index.js index 0ca1b6fee5c..c6e6ba21d4a 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -126,7 +126,7 @@ proto.handle = function(req, res, done) { var search = 1 + req.url.indexOf('?'); var pathlength = search ? search - 1 : req.url.length; - var fqdn = 1 + req.url.substr(0, pathlength).indexOf('://'); + var fqdn = req.url[0] !== '/' && 1 + req.url.substr(0, pathlength).indexOf('://'); var protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : ''; var idx = 0; var removed = ''; diff --git a/test/Router.js b/test/Router.js index db2082a4000..880d34b8d53 100644 --- a/test/Router.js +++ b/test/Router.js @@ -219,6 +219,23 @@ describe('Router', function(){ }); }); + it('should ignore FQDN in path', function (done) { + var request = { hit: 0, url: '/proxy/http://example.com/blog/post/1', method: 'GET' }; + var router = new Router(); + + router.use('/proxy', function (req, res, next) { + assert.equal(req.hit++, 0); + assert.equal(req.url, '/http://example.com/blog/post/1'); + next(); + }); + + router.handle(request, {}, function (err) { + if (err) return done(err); + assert.equal(request.hit, 1); + done(); + }); + }); + it('should adjust FQDN req.url', function (done) { var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' }; var router = new Router(); From d53a0cd91e2381607719b1b262668810e2795ce4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 29 Oct 2014 01:08:36 -0400 Subject: [PATCH 0641/1265] deps: connect@2.27.2 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ee2a1f75cfc..6cb07b4316e 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +3.x +=== + + * deps: connect@2.27.2 + - Fix handling of URLs containing `://` in the path + - deps: body-parser@~1.9.2 + - deps: qs@2.3.2 + 3.18.1 / 2014-10-22 =================== diff --git a/package.json b/package.json index c4aede125c7..1a0368c38b3 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.27.1", + "connect": "2.27.2", "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", From a12ae729bdb1e59f4f5962f0429fd116fd1fba24 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 29 Oct 2014 01:10:45 -0400 Subject: [PATCH 0642/1265] 3.18.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 6cb07b4316e..43aa519a375 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.18.2 / 2014-10-28 +=================== * deps: connect@2.27.2 - Fix handling of URLs containing `://` in the path diff --git a/package.json b/package.json index 1a0368c38b3..0740b1d9029 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.18.1", + "version": "3.18.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 6c0031bfd8ec03ba242fc53ed40237040347b960 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 29 Oct 2014 01:14:44 -0400 Subject: [PATCH 0643/1265] deps: qs@2.3.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ebbbdfa547b..b791235676a 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * Fix handling of URLs containing `://` in the path + * deps: qs@2.3.2 + - Fix parsing of mixed objects and values 4.10.0 / 2014-10-23 =================== diff --git a/package.json b/package.json index 75d1e51f157..15d29c6e1ab 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.3", - "qs": "2.3.0", + "qs": "2.3.2", "range-parser": "~1.0.2", "send": "0.10.1", "serve-static": "~1.7.1", From 8bb013ec9567ae95a649c7537e1689944749d493 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 29 Oct 2014 01:15:58 -0400 Subject: [PATCH 0644/1265] 4.10.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b791235676a..fc8330b0faf 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.1 / 2014-10-28 +=================== * Fix handling of URLs containing `://` in the path * deps: qs@2.3.2 diff --git a/package.json b/package.json index 15d29c6e1ab..e98cd90db3b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.0", + "version": "4.10.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 1c96e18d20eecc7dbefabe21f8818192f06eafc9 Mon Sep 17 00:00:00 2001 From: Jaime Agudo Date: Thu, 30 Oct 2014 18:22:46 +0000 Subject: [PATCH 0645/1265] docs: fix Gratipay links fixes #2424 --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 9fe91d2fc6c..24bc5822222 100644 --- a/Readme.md +++ b/Readme.md @@ -130,6 +130,6 @@ The current lead maintainer is [Douglas Christopher Wilson](https://github.com/d [coveralls-image]: https://img.shields.io/coveralls/strongloop/express.svg?style=flat [coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master [gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg?style=flat -[gratipay-url-visionmedia]: https://gratipay/visionmedia/ +[gratipay-url-visionmedia]: https://gratipay.com/visionmedia/ [gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg?style=flat -[gratipay-url-dougwilson]: https://gratipay/dougwilson/ +[gratipay-url-dougwilson]: https://gratipay.com/dougwilson/ From e4debea297397fb32d042fefcf30d174984b68d6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 1 Nov 2014 14:09:12 -0400 Subject: [PATCH 0646/1265] Remove unused source file --- lib/router/match.js | 56 --------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 lib/router/match.js diff --git a/lib/router/match.js b/lib/router/match.js deleted file mode 100644 index 9afebfc8b34..00000000000 --- a/lib/router/match.js +++ /dev/null @@ -1,56 +0,0 @@ - -/** - * Expose `Layer`. - */ - -module.exports = Match; - -function Match(layer, path, params) { - this.layer = layer; - this.params = {}; - this.path = path || ''; - - if (!params) { - return this; - } - - var keys = layer.keys; - var n = 0; - var prop; - var key; - var val; - - for (var i = 0; i < params.length; i++) { - key = keys[i]; - val = decode_param(params[i]); - prop = key - ? key.name - : n++; - - this.params[prop] = val; - } - - return this; -}; - -/** - * Decode param value. - * - * @param {string} val - * @return {string} - * @api private - */ - -function decode_param(val){ - if (typeof val !== 'string') { - return val; - } - - try { - return decodeURIComponent(val); - } catch (e) { - var err = new TypeError("Failed to decode param '" + val + "'"); - err.status = 400; - throw err; - } -} From b4eaf891867a4ef68b7ca9578c88fa6a6b71c13d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 6 Nov 2014 21:14:02 -0500 Subject: [PATCH 0647/1265] examples: remove invalid cors example Not only is the example not even standards-compliant, but it encourages bad security settings and practices. --- examples/cors/index.js | 48 --------------------------------- examples/cors/public/index.html | 12 --------- 2 files changed, 60 deletions(-) delete mode 100644 examples/cors/index.js delete mode 100644 examples/cors/public/index.html diff --git a/examples/cors/index.js b/examples/cors/index.js deleted file mode 100644 index ac30ac9444e..00000000000 --- a/examples/cors/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Module dependencies. - */ - -var express = require('../..'); -var logger = require('morgan'); -var app = express(); -var bodyParser = require('body-parser'); -var api = express(); - -// app middleware - -app.use(express.static(__dirname + '/public')); - -// api middleware - -api.use(logger('dev')); -api.use(bodyParser.json()); - -/** - * CORS support. - */ - -api.all('*', function(req, res, next){ - if (!req.get('Origin')) return next(); - // use "*" here to accept any origin - res.set('Access-Control-Allow-Origin', 'http://localhost:3000'); - res.set('Access-Control-Allow-Methods', 'PUT'); - res.set('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type'); - // res.set('Access-Control-Allow-Max-Age', 3600); - if ('OPTIONS' == req.method) return res.send(200); - next(); -}); - -/** - * PUT an existing user. - */ - -api.put('/user/:id', function(req, res){ - console.log(req.body); - res.send(204); -}); - -app.listen(3000); -api.listen(3001); - -console.log('app listening on 3000'); -console.log('api listening on 3001'); diff --git a/examples/cors/public/index.html b/examples/cors/public/index.html deleted file mode 100644 index d87edc2255c..00000000000 --- a/examples/cors/public/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - From 77c83d0c570a298d26a3f00ee91acf694599a51e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Nov 2014 18:32:43 -0500 Subject: [PATCH 0648/1265] deps: connect@2.27.3 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 43aa519a375..78273a83d77 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.27.3 + - Correctly invoke async callback asynchronously + - deps: csurf@~1.6.3 + 3.18.2 / 2014-10-28 =================== diff --git a/package.json b/package.json index 0740b1d9029..ebbf4e99230 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.27.2", + "connect": "2.27.3", "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", From 01e3530a31dab88be87365199f0fbf5f7cc7b270 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Nov 2014 18:33:17 -0500 Subject: [PATCH 0649/1265] deps: should@~4.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ebbf4e99230..037d20cf413 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "connect-redis": "~1.5.0", "istanbul": "0.3.2", "mocha": "~2.0.0", - "should": "~4.1.0", + "should": "~4.2.1", "supertest": "~0.14.0", "ejs": "~1.0.0", "jade": "~1.7.0", From 28c6952d1c40d2ed840967206c1a7fc8d21da71b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Nov 2014 18:35:34 -0500 Subject: [PATCH 0650/1265] 3.18.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 78273a83d77..c6a0371464e 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.18.3 / 2014-11-09 +=================== * deps: connect@2.27.3 - Correctly invoke async callback asynchronously diff --git a/package.json b/package.json index 037d20cf413..b112ca808c9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.18.2", + "version": "3.18.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 0e488c19dfe5a0c7d5600dc3d31e7917ee7ddcec Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Nov 2014 18:41:01 -0500 Subject: [PATCH 0651/1265] deps: accepts@~1.1.3 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d13437ad436..f0a61188685 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: accepts@~1.1.3 + - deps: mime-types@~2.0.3 + 4.10.1 / 2014-10-28 =================== diff --git a/package.json b/package.json index 38c59b9cb8d..1a854526aea 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.1.2", + "accepts": "~1.1.3", "content-disposition": "0.5.0", "cookie-signature": "1.0.5", "debug": "~2.1.0", From 881e1ba6600186984df6e2aacdb2a3f3b0b51ce6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Nov 2014 18:42:33 -0500 Subject: [PATCH 0652/1265] deps: type-is@~1.5.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f0a61188685..a27c2076d54 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,8 @@ unreleased * deps: accepts@~1.1.3 - deps: mime-types@~2.0.3 + * deps: type-is@~1.5.3 + - deps: mime-types@~2.0.3 4.10.1 / 2014-10-28 =================== diff --git a/package.json b/package.json index 1a854526aea..fec3d230f30 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "range-parser": "~1.0.2", "send": "0.10.1", "serve-static": "~1.7.1", - "type-is": "~1.5.2", + "type-is": "~1.5.3", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2", From 5fab60bc6cbba8f3964575dbcd03671d05662aa5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Nov 2014 18:50:00 -0500 Subject: [PATCH 0653/1265] Correctly invoke async router callback asynchronously --- History.md | 1 + lib/router/index.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a27c2076d54..531235f1631 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Correctly invoke async router callback asynchronously * deps: accepts@~1.1.3 - deps: mime-types@~2.0.3 * deps: type-is@~1.5.3 diff --git a/lib/router/index.js b/lib/router/index.js index c6e6ba21d4a..b3a42e290c9 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -183,7 +183,8 @@ proto.handle = function(req, res, done) { } if (!layer) { - return done(layerError); + setImmediate(done, layerError); + return; } self.match_layer(layer, req, res, function (err, path) { From 6dea32cd18580a1206f1075295679da00d028354 Mon Sep 17 00:00:00 2001 From: Josemar Magalhaes Date: Sun, 9 Nov 2014 19:46:12 -0200 Subject: [PATCH 0654/1265] examples: add multi router example closes #2434 --- examples/multi-router/controllers/api_v1.js | 13 ++++++ examples/multi-router/controllers/api_v2.js | 13 ++++++ examples/multi-router/index.js | 16 ++++++++ test/acceptance/multi-router.js | 44 +++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 examples/multi-router/controllers/api_v1.js create mode 100644 examples/multi-router/controllers/api_v2.js create mode 100644 examples/multi-router/index.js create mode 100644 test/acceptance/multi-router.js diff --git a/examples/multi-router/controllers/api_v1.js b/examples/multi-router/controllers/api_v1.js new file mode 100644 index 00000000000..08b7b5e6fdd --- /dev/null +++ b/examples/multi-router/controllers/api_v1.js @@ -0,0 +1,13 @@ +var express = require('../../..'); + +var apiv1 = express.Router(); + +apiv1.get('/', function(req, res) { + res.send('Hello from APIv1 root route.'); +}); + +apiv1.get('/users', function(req, res) { + res.send('List of APIv1 users.'); +}); + +module.exports = apiv1; diff --git a/examples/multi-router/controllers/api_v2.js b/examples/multi-router/controllers/api_v2.js new file mode 100644 index 00000000000..4dd708281c2 --- /dev/null +++ b/examples/multi-router/controllers/api_v2.js @@ -0,0 +1,13 @@ +var express = require('../../..'); + +var apiv2 = express.Router(); + +apiv2.get('/', function(req, res) { + res.send('Hello from APIv2 root route.'); +}); + +apiv2.get('/users', function(req, res) { + res.send('List of APIv2 users.'); +}); + +module.exports = apiv2; diff --git a/examples/multi-router/index.js b/examples/multi-router/index.js new file mode 100644 index 00000000000..ff31e514a56 --- /dev/null +++ b/examples/multi-router/index.js @@ -0,0 +1,16 @@ +var express = require('../..'); + +var app = module.exports = express(); + +app.use('/api/v1', require('./controllers/api_v1')); +app.use('/api/v2', require('./controllers/api_v2')); + +app.get('/', function(req, res) { + res.send('Hello form root route.'); +}); + +/* istanbul ignore next */ +if (!module.parent) { + app.listen(3000); + console.log('Express started on port 3000'); +} diff --git a/test/acceptance/multi-router.js b/test/acceptance/multi-router.js new file mode 100644 index 00000000000..9590ee94d41 --- /dev/null +++ b/test/acceptance/multi-router.js @@ -0,0 +1,44 @@ +var app = require('../../examples/multi-router') +var request = require('supertest') + +describe('multi-router', function(){ + describe('GET /',function(){ + it('should respond with root handler', function(done){ + request(app) + .get('/') + .expect(200, 'Hello form root route.', done) + }) + }) + + describe('GET /api/v1/',function(){ + it('should respond with APIv1 root handler', function(done){ + request(app) + .get('/api/v1/') + .expect(200, 'Hello from APIv1 root route.', done) + }) + }) + + describe('GET /api/v1/users',function(){ + it('should respond with users from APIv1', function(done){ + request(app) + .get('/api/v1/users') + .expect(200, 'List of APIv1 users.', done) + }) + }) + + describe('GET /api/v2/',function(){ + it('should respond with APIv2 root handler', function(done){ + request(app) + .get('/api/v2/') + .expect(200, 'Hello from APIv2 root route.', done) + }) + }) + + describe('GET /api/v2/users',function(){ + it('should respond with users from APIv2', function(done){ + request(app) + .get('/api/v2/users') + .expect(200, 'List of APIv2 users.', done) + }) + }) +}) From ac56cf46063e461fbaf53c2c869a1a657e8adbe1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Nov 2014 19:09:24 -0500 Subject: [PATCH 0655/1265] 4.10.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 531235f1631..6c23252951d 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.2 / 2014-11-09 +=================== * Correctly invoke async router callback asynchronously * deps: accepts@~1.1.3 diff --git a/package.json b/package.json index fec3d230f30..9dcf0e08c52 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.1", + "version": "4.10.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From eaba4eeb703ee32cdd3ae5e5ec8aa72dfda69d58 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 14:53:23 -0500 Subject: [PATCH 0656/1265] deps: connect@2.27.4 --- History.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c6a0371464e..6acbcbad6d0 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,16 @@ +3.x +=== + + * deps: connect@2.27.4 + - deps: body-parser@~1.9.3 + - deps: compression@~1.2.1 + - deps: errorhandler@~1.2.3 + - deps: express-session@~1.9.2 + - deps: qs@2.3.3 + - deps: serve-favicon@~2.1.7 + - deps: serve-static@~1.5.1 + - deps: type-is@~1.5.3 + 3.18.3 / 2014-11-09 =================== diff --git a/package.json b/package.json index b112ca808c9..34470268882 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.27.3", + "connect": "2.27.4", "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", From 13184c4379681a2e3e42e033d1b3b5c5e8366c82 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 14:58:22 -0500 Subject: [PATCH 0657/1265] deps: etag@~1.5.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6acbcbad6d0..0d69031d4c3 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,7 @@ - deps: serve-favicon@~2.1.7 - deps: serve-static@~1.5.1 - deps: type-is@~1.5.3 + * deps: etag@~1.5.1 3.18.3 / 2014-11-09 =================== diff --git a/package.json b/package.json index 34470268882..fbbede3e062 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "debug": "~2.1.0", "depd": "~1.0.0", "escape-html": "1.0.1", - "etag": "~1.5.0", + "etag": "~1.5.1", "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", From 8535d3a9900c5fa409f6d7a842ebcad600c11a49 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 14:58:56 -0500 Subject: [PATCH 0658/1265] deps: supertest@~0.15.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fbbede3e062..b94c1c0141b 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "istanbul": "0.3.2", "mocha": "~2.0.0", "should": "~4.2.1", - "supertest": "~0.14.0", + "supertest": "~0.15.0", "ejs": "~1.0.0", "jade": "~1.7.0", "hjs": "~0.0.6", From ebca5887ccd38d8a5de5269cbac3919e8d6c4d58 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 15:34:57 -0500 Subject: [PATCH 0659/1265] deps: proxy-addr@~1.0.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0d69031d4c3..7bc7fffaa3e 100644 --- a/History.md +++ b/History.md @@ -11,6 +11,8 @@ - deps: serve-static@~1.5.1 - deps: type-is@~1.5.3 * deps: etag@~1.5.1 + * deps: proxy-addr@~1.0.4 + - deps: ipaddr.js@0.1.5 3.18.3 / 2014-11-09 =================== diff --git a/package.json b/package.json index b94c1c0141b..a8b82f5a454 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "methods": "1.1.0", "mkdirp": "0.5.0", "parseurl": "~1.3.0", - "proxy-addr": "~1.0.3", + "proxy-addr": "~1.0.4", "range-parser": "~1.0.2", "send": "0.10.1", "utils-merge": "1.0.0", From 95e63ec287ce6c23571379c57a80c5734fc3ebda Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 15:36:59 -0500 Subject: [PATCH 0660/1265] deps: should@~4.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a8b82f5a454..89255de70c6 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "connect-redis": "~1.5.0", "istanbul": "0.3.2", "mocha": "~2.0.0", - "should": "~4.2.1", + "should": "~4.3.0", "supertest": "~0.15.0", "ejs": "~1.0.0", "jade": "~1.7.0", From 6c8bcd5c4e049b5c212036a2e6cfe9ac98d5b9f8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 15:42:03 -0500 Subject: [PATCH 0661/1265] 3.18.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 7bc7fffaa3e..9efc8261edf 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.18.4 / 2014-11-23 +=================== * deps: connect@2.27.4 - deps: body-parser@~1.9.3 diff --git a/package.json b/package.json index 89255de70c6..f7ade51bd8c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.18.3", + "version": "3.18.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 997fd74e8c2166af6f24c61a7e271bfe74da203f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 15:56:59 -0500 Subject: [PATCH 0662/1265] deps: qs@2.3.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c5dbc0b7507..825a28f8c3d 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * deps: etag@~1.5.1 * deps: proxy-addr@~1.0.4 - deps: ipaddr.js@0.1.5 + * deps: qs@2.3.3 + - Fix `arrayLimit` behavior 4.10.2 / 2014-11-09 =================== diff --git a/package.json b/package.json index 036546c09a8..571942b83a7 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.4", - "qs": "2.3.2", + "qs": "2.3.3", "range-parser": "~1.0.2", "send": "0.10.1", "serve-static": "~1.7.1", From 869ddd775c07045f0a6ad1278aaa3447e50667d6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 15:58:24 -0500 Subject: [PATCH 0663/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 571942b83a7..1d6161f18f9 100644 --- a/package.json +++ b/package.json @@ -61,13 +61,13 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.9.1", + "body-parser": "~1.9.3", "connect-redis": "~2.1.0", "cookie-parser": "~1.3.3", - "express-session": "~1.9.1", + "express-session": "~1.9.2", "jade": "~1.7.0", "method-override": "~2.3.0", - "morgan": "~1.4.1", + "morgan": "~1.5.0", "multiparty": "~4.0.0", "vhost": "~3.0.0" }, From b326ae89df48faac64f22be0eca0a86c87b203ee Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 16:53:11 -0500 Subject: [PATCH 0664/1265] Fix res.sendFile logging standard write errors fixes #2433 --- History.md | 1 + lib/response.js | 4 ++-- test/res.sendFile.js | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 825a28f8c3d..895ddb1a843 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix `res.sendFile` logging standard write errors * deps: etag@~1.5.1 * deps: proxy-addr@~1.0.4 - deps: ipaddr.js@0.1.5 diff --git a/lib/response.js b/lib/response.js index 34e46ad73a6..4dc08f77bf4 100644 --- a/lib/response.js +++ b/lib/response.js @@ -398,8 +398,8 @@ res.sendFile = function sendFile(path, options, fn) { if (fn) return fn(err); if (err && err.code === 'EISDIR') return next(); - // next() all but aborted errors - if (err && err.code !== 'ECONNABORT') { + // next() all but write errors + if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') { next(err); } }); diff --git a/test/res.sendFile.js b/test/res.sendFile.js index 779f6ca79f9..c7631bb522b 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -69,6 +69,27 @@ describe('res', function(){ .end(done); }) + it('should not error if the client aborts', function (done) { + var cb = after(1, done); + var app = express(); + + app.use(function (req, res) { + setImmediate(function () { + res.sendFile(path.resolve(fixtures, 'name.txt')); + cb(); + }); + test.abort(); + }); + + app.use(function (err, req, res, next) { + err.code.should.be.empty; + cb(); + }); + + var test = request(app).get('/'); + test.expect(200, cb); + }) + describe('with "dotfiles" option', function () { it('should not serve dotfiles by default', function (done) { var app = createApp(path.resolve(__dirname, 'fixtures/.name')); From 7fcc8b190d7a8a3f3743bc19b4ec0d349e50cc20 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 18:48:55 -0500 Subject: [PATCH 0665/1265] 4.10.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 895ddb1a843..33185678594 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.3 / 2014-11-23 +=================== * Fix `res.sendFile` logging standard write errors * deps: etag@~1.5.1 diff --git a/package.json b/package.json index 1d6161f18f9..46f042b7810 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.2", + "version": "4.10.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 4b26bbde2d34e3cc6f03300c36130618546263ad Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 24 Nov 2014 23:28:37 -0500 Subject: [PATCH 0666/1265] Fix res.sendFile logging standard write errors closes #2451 --- History.md | 5 +++++ lib/response.js | 4 ++-- test/res.sendFile.js | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 33185678594..c7dca6b0937 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix `res.sendfile` logging standard write errors + 4.10.3 / 2014-11-23 =================== diff --git a/lib/response.js b/lib/response.js index 4dc08f77bf4..d040da726bc 100644 --- a/lib/response.js +++ b/lib/response.js @@ -467,8 +467,8 @@ res.sendfile = function(path, options, fn){ if (fn) return fn(err); if (err && err.code === 'EISDIR') return next(); - // next() all but aborted errors - if (err && err.code !== 'ECONNABORT') { + // next() all but write errors + if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') { next(err); } }); diff --git a/test/res.sendFile.js b/test/res.sendFile.js index c7631bb522b..4dfb17528b9 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -476,6 +476,27 @@ describe('res', function(){ .expect(200, '20%', done); }); + it('should not error if the client aborts', function (done) { + var cb = after(1, done); + var app = express(); + + app.use(function (req, res) { + setImmediate(function () { + res.sendfile(path.resolve(fixtures, 'name.txt')); + cb(); + }); + test.abort(); + }); + + app.use(function (err, req, res, next) { + err.code.should.be.empty; + cb(); + }); + + var test = request(app).get('/'); + test.expect(200, cb); + }) + describe('with an absolute path', function(){ it('should transfer the file', function(done){ var app = express(); From 656e214937889536b0faa73097422061315496f2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 25 Nov 2014 00:17:24 -0500 Subject: [PATCH 0667/1265] 4.10.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index c7dca6b0937..f48fa494a4f 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.4 / 2014-11-24 +=================== * Fix `res.sendfile` logging standard write errors diff --git a/package.json b/package.json index 46f042b7810..363889e6219 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.3", + "version": "4.10.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 91824514ced78b4122f684e05c91e666cbf01276 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 28 Nov 2014 09:10:44 -0500 Subject: [PATCH 0668/1265] tests: run render tests with internal template engine --- test/app.render.js | 60 ++++++++++++++---------- test/fixtures/blog/post/index.jade | 1 - test/fixtures/blog/post/index.tmpl | 1 + test/fixtures/email.jade | 1 - test/fixtures/email.tmpl | 1 + test/fixtures/pet.jade | 1 - test/fixtures/user.jade | 1 - test/fixtures/user.tmpl | 1 + test/res.render.js | 73 +++++++++++++++++------------- test/support/tmpl.js | 35 ++++++++++++++ 10 files changed, 114 insertions(+), 61 deletions(-) delete mode 100644 test/fixtures/blog/post/index.jade create mode 100644 test/fixtures/blog/post/index.tmpl delete mode 100644 test/fixtures/email.jade create mode 100644 test/fixtures/email.tmpl delete mode 100644 test/fixtures/pet.jade delete mode 100644 test/fixtures/user.jade create mode 100644 test/fixtures/user.tmpl create mode 100644 test/support/tmpl.js diff --git a/test/app.render.js b/test/app.render.js index a2c1ce69bcf..38ef0cfb803 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -1,14 +1,15 @@ -var express = require('../'); +var express = require('..'); +var tmpl = require('./support/tmpl'); describe('app', function(){ describe('.render(name, fn)', function(){ it('should support absolute paths', function(done){ - var app = express(); + var app = createApp(); app.locals.user = { name: 'tobi' }; - app.render(__dirname + '/fixtures/user.jade', function(err, str){ + app.render(__dirname + '/fixtures/user.tmpl', function (err, str) { if (err) return done(err); str.should.equal('

tobi

'); done(); @@ -16,9 +17,9 @@ describe('app', function(){ }) it('should support absolute paths with "view engine"', function(done){ - var app = express(); + var app = createApp(); - app.set('view engine', 'jade'); + app.set('view engine', 'tmpl'); app.locals.user = { name: 'tobi' }; app.render(__dirname + '/fixtures/user', function(err, str){ @@ -29,12 +30,12 @@ describe('app', function(){ }) it('should expose app.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.locals.user = { name: 'tobi' }; - app.render('user.jade', function(err, str){ + app.render('user.tmpl', function (err, str) { if (err) return done(err); str.should.equal('

tobi

'); done(); @@ -42,12 +43,12 @@ describe('app', function(){ }) it('should support index.', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); - app.set('view engine', 'jade'); + app.set('view engine', 'tmpl'); - app.render('blog/post', function(err, str){ + app.render('blog/post', function (err, str) { if (err) return done(err); str.should.equal('

blog post

'); done(); @@ -77,10 +78,11 @@ describe('app', function(){ describe('when the file does not exist', function(){ it('should provide a helpful error', function(done){ - var app = express(); + var app = createApp(); + app.set('views', __dirname + '/fixtures'); - app.render('rawr.jade', function(err){ - err.message.should.equal('Failed to lookup view "rawr.jade" in views directory "' + __dirname + '/fixtures"'); + app.render('rawr.tmpl', function (err) { + err.message.should.equal('Failed to lookup view "rawr.tmpl" in views directory "' + __dirname + '/fixtures"'); done(); }); }) @@ -88,11 +90,11 @@ describe('app', function(){ describe('when an error occurs', function(){ it('should invoke the callback', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); - app.render('user.jade', function(err, str){ + app.render('user.tmpl', function (err, str) { // nextTick to prevent cyclic process.nextTick(function(){ err.message.should.match(/Cannot read property 'name' of undefined/); @@ -104,11 +106,11 @@ describe('app', function(){ describe('when an extension is given', function(){ it('should render the template', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); - app.render('email.jade', function(err, str){ + app.render('email.tmpl', function (err, str) { if (err) return done(err); str.should.equal('

This is an email

'); done(); @@ -118,9 +120,9 @@ describe('app', function(){ describe('when "view engine" is given', function(){ it('should render the template', function(done){ - var app = express(); + var app = createApp(); - app.set('view engine', 'jade'); + app.set('view engine', 'tmpl'); app.set('views', __dirname + '/fixtures'); app.render('email', function(err, str){ @@ -219,13 +221,13 @@ describe('app', function(){ describe('.render(name, options, fn)', function(){ it('should render the template', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); var user = { name: 'tobi' }; - app.render('user.jade', { user: user }, function(err, str){ + app.render('user.tmpl', { user: user }, function (err, str) { if (err) return done(err); str.should.equal('

tobi

'); done(); @@ -233,12 +235,12 @@ describe('app', function(){ }) it('should expose app.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.locals.user = { name: 'tobi' }; - app.render('user.jade', {}, function(err, str){ + app.render('user.tmpl', {}, function (err, str) { if (err) return done(err); str.should.equal('

tobi

'); done(); @@ -246,13 +248,13 @@ describe('app', function(){ }) it('should give precedence to app.render() locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.locals.user = { name: 'tobi' }; var jane = { name: 'jane' }; - app.render('user.jade', { user: jane }, function(err, str){ + app.render('user.tmpl', { user: jane }, function (err, str) { if (err) return done(err); str.should.equal('

jane

'); done(); @@ -292,3 +294,11 @@ describe('app', function(){ }) }) }) + +function createApp() { + var app = express(); + + app.engine('.tmpl', tmpl); + + return app; +} diff --git a/test/fixtures/blog/post/index.jade b/test/fixtures/blog/post/index.jade deleted file mode 100644 index 36c8d4d1c48..00000000000 --- a/test/fixtures/blog/post/index.jade +++ /dev/null @@ -1 +0,0 @@ -h1 blog post \ No newline at end of file diff --git a/test/fixtures/blog/post/index.tmpl b/test/fixtures/blog/post/index.tmpl new file mode 100644 index 00000000000..a9a2a3b3053 --- /dev/null +++ b/test/fixtures/blog/post/index.tmpl @@ -0,0 +1 @@ +

blog post

\ No newline at end of file diff --git a/test/fixtures/email.jade b/test/fixtures/email.jade deleted file mode 100644 index 4475d8d5164..00000000000 --- a/test/fixtures/email.jade +++ /dev/null @@ -1 +0,0 @@ -p This is an email \ No newline at end of file diff --git a/test/fixtures/email.tmpl b/test/fixtures/email.tmpl new file mode 100644 index 00000000000..8a2cb77aeb4 --- /dev/null +++ b/test/fixtures/email.tmpl @@ -0,0 +1 @@ +

This is an email

\ No newline at end of file diff --git a/test/fixtures/pet.jade b/test/fixtures/pet.jade deleted file mode 100644 index 8ee192eca90..00000000000 --- a/test/fixtures/pet.jade +++ /dev/null @@ -1 +0,0 @@ -p #{first} #{last} is a #{species} \ No newline at end of file diff --git a/test/fixtures/user.jade b/test/fixtures/user.jade deleted file mode 100644 index 623c6654a70..00000000000 --- a/test/fixtures/user.jade +++ /dev/null @@ -1 +0,0 @@ -p= user.name \ No newline at end of file diff --git a/test/fixtures/user.tmpl b/test/fixtures/user.tmpl new file mode 100644 index 00000000000..67ef510227b --- /dev/null +++ b/test/fixtures/user.tmpl @@ -0,0 +1 @@ +

$user.name

\ No newline at end of file diff --git a/test/res.render.js b/test/res.render.js index b55417ff0ca..5285ad95d28 100644 --- a/test/res.render.js +++ b/test/res.render.js @@ -1,16 +1,17 @@ -var express = require('../') - , request = require('supertest'); +var express = require('..'); +var request = require('supertest'); +var tmpl = require('./support/tmpl'); describe('res', function(){ describe('.render(name)', function(){ it('should support absolute paths', function(done){ - var app = express(); + var app = createApp(); app.locals.user = { name: 'tobi' }; app.use(function(req, res){ - res.render(__dirname + '/fixtures/user.jade'); + res.render(__dirname + '/fixtures/user.tmpl'); }); request(app) @@ -19,10 +20,10 @@ describe('res', function(){ }) it('should support absolute paths with "view engine"', function(done){ - var app = express(); + var app = createApp(); app.locals.user = { name: 'tobi' }; - app.set('view engine', 'jade'); + app.set('view engine', 'tmpl'); app.use(function(req, res){ res.render(__dirname + '/fixtures/user'); @@ -34,13 +35,13 @@ describe('res', function(){ }) it('should expose app.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.locals.user = { name: 'tobi' }; app.use(function(req, res){ - res.render('user.jade'); + res.render('user.tmpl'); }); request(app) @@ -49,10 +50,10 @@ describe('res', function(){ }) it('should support index.', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); - app.set('view engine', 'jade'); + app.set('view engine', 'tmpl'); app.use(function(req, res){ res.render('blog/post'); @@ -65,12 +66,12 @@ describe('res', function(){ describe('when an error occurs', function(){ it('should next(err)', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.use(function(req, res){ - res.render('user.jade'); + res.render('user.tmpl'); }); app.use(function(err, req, res, next){ @@ -85,9 +86,9 @@ describe('res', function(){ describe('when "view engine" is given', function(){ it('should render the template', function(done){ - var app = express(); + var app = createApp(); - app.set('view engine', 'jade'); + app.set('view engine', 'tmpl'); app.set('views', __dirname + '/fixtures'); app.use(function(req, res){ @@ -103,14 +104,14 @@ describe('res', function(){ describe('.render(name, option)', function(){ it('should render the template', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); var user = { name: 'tobi' }; app.use(function(req, res){ - res.render('user.jade', { user: user }); + res.render('user.tmpl', { user: user }); }); request(app) @@ -119,13 +120,13 @@ describe('res', function(){ }) it('should expose app.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.locals.user = { name: 'tobi' }; app.use(function(req, res){ - res.render('user.jade'); + res.render('user.tmpl'); }); request(app) @@ -134,13 +135,13 @@ describe('res', function(){ }) it('should expose res.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.use(function(req, res){ res.locals.user = { name: 'tobi' }; - res.render('user.jade'); + res.render('user.tmpl'); }); request(app) @@ -149,14 +150,14 @@ describe('res', function(){ }) it('should give precedence to res.locals over app.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.locals.user = { name: 'tobi' }; app.use(function(req, res){ res.locals.user = { name: 'jane' }; - res.render('user.jade', {}); + res.render('user.tmpl', {}); }); request(app) @@ -165,14 +166,14 @@ describe('res', function(){ }) it('should give precedence to res.render() locals over res.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); var jane = { name: 'jane' }; app.use(function(req, res){ res.locals.user = { name: 'tobi' }; - res.render('user.jade', { user: jane }); + res.render('user.tmpl', { user: jane }); }); request(app) @@ -181,14 +182,14 @@ describe('res', function(){ }) it('should give precedence to res.render() locals over app.locals', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.locals.user = { name: 'tobi' }; var jane = { name: 'jane' }; app.use(function(req, res){ - res.render('user.jade', { user: jane }); + res.render('user.tmpl', { user: jane }); }); request(app) @@ -199,13 +200,13 @@ describe('res', function(){ describe('.render(name, options, fn)', function(){ it('should pass the resulting string', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.use(function(req, res){ var tobi = { name: 'tobi' }; - res.render('user.jade', { user: tobi }, function(err, html){ + res.render('user.tmpl', { user: tobi }, function (err, html) { html = html.replace('tobi', 'loki'); res.end(html); }); @@ -219,13 +220,13 @@ describe('res', function(){ describe('.render(name, fn)', function(){ it('should pass the resulting string', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.use(function(req, res){ res.locals.user = { name: 'tobi' }; - res.render('user.jade', function(err, html){ + res.render('user.tmpl', function (err, html) { html = html.replace('tobi', 'loki'); res.end(html); }); @@ -238,12 +239,12 @@ describe('res', function(){ describe('when an error occurs', function(){ it('should pass it to the callback', function(done){ - var app = express(); + var app = createApp(); app.set('views', __dirname + '/fixtures'); app.use(function(req, res){ - res.render('user.jade', function(err){ + res.render('user.tmpl', function (err) { res.end(err.message); }); }); @@ -255,3 +256,11 @@ describe('res', function(){ }) }) }) + +function createApp() { + var app = express(); + + app.engine('.tmpl', tmpl); + + return app; +} diff --git a/test/support/tmpl.js b/test/support/tmpl.js new file mode 100644 index 00000000000..2e8bec86388 --- /dev/null +++ b/test/support/tmpl.js @@ -0,0 +1,35 @@ +var fs = require('fs'); + +var variableRegExp = /\$([0-9a-zA-Z\.]+)/g; + +module.exports = function renderFile(fileName, options, callback) { + function onReadFile(err, str) { + if (err) { + callback(err); + return; + } + + try { + str = str.replace(variableRegExp, generateVariableLookup(options)); + } catch (e) { + err = e; + } + + callback(err, str); + } + + fs.readFile(fileName, 'utf8', onReadFile); +}; + +function generateVariableLookup(data) { + return function variableLookup(str, path) { + var parts = path.split('.'); + var value = data; + + for (var i = 0; i < parts.length; i++) { + value = value[parts[i]]; + } + + return value; + }; +} From d23417e6e8b7cdbbfb7c48d5adaabf1612e0a421 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 29 Nov 2014 12:09:00 -0500 Subject: [PATCH 0669/1265] examples: switch examples used in tests to ejs engine --- examples/error-pages/index.js | 4 ++-- examples/error-pages/views/404.ejs | 3 +++ examples/error-pages/views/404.jade | 5 ----- examples/error-pages/views/500.ejs | 8 ++++++++ examples/error-pages/views/500.jade | 13 ------------- examples/error-pages/views/error.jade | 6 ------ examples/error-pages/views/error_header.ejs | 8 ++++++++ examples/error-pages/views/footer.ejs | 2 ++ examples/error-pages/views/index.ejs | 18 ++++++++++++++++++ examples/error-pages/views/index.jade | 15 --------------- examples/error-pages/views/layout.jade | 6 ------ examples/mvc/controllers/pet/index.js | 2 +- examples/mvc/controllers/pet/views/edit.ejs | 16 ++++++++++++++++ examples/mvc/controllers/pet/views/edit.jade | 7 ------- examples/mvc/controllers/pet/views/show.ejs | 13 +++++++++++++ examples/mvc/controllers/pet/views/show.jade | 6 ------ package.json | 1 - 17 files changed, 71 insertions(+), 62 deletions(-) create mode 100644 examples/error-pages/views/404.ejs delete mode 100644 examples/error-pages/views/404.jade create mode 100644 examples/error-pages/views/500.ejs delete mode 100644 examples/error-pages/views/500.jade delete mode 100644 examples/error-pages/views/error.jade create mode 100644 examples/error-pages/views/error_header.ejs create mode 100644 examples/error-pages/views/footer.ejs create mode 100644 examples/error-pages/views/index.ejs delete mode 100644 examples/error-pages/views/index.jade delete mode 100644 examples/error-pages/views/layout.jade create mode 100644 examples/mvc/controllers/pet/views/edit.ejs delete mode 100644 examples/mvc/controllers/pet/views/edit.jade create mode 100644 examples/mvc/controllers/pet/views/show.ejs delete mode 100644 examples/mvc/controllers/pet/views/show.jade diff --git a/examples/error-pages/index.js b/examples/error-pages/index.js index 2c17d7f0ee5..26835153742 100644 --- a/examples/error-pages/index.js +++ b/examples/error-pages/index.js @@ -8,7 +8,7 @@ var express = require('../../') // general config app.set('views', __dirname + '/views'); -app.set('view engine', 'jade'); +app.set('view engine', 'ejs'); // our custom "verbose errors" setting // which we can use in the templates @@ -82,7 +82,7 @@ app.use(function(err, req, res, next){ // Routes app.get('/', function(req, res){ - res.render('index.jade'); + res.render('index.ejs'); }); app.get('/404', function(req, res, next){ diff --git a/examples/error-pages/views/404.ejs b/examples/error-pages/views/404.ejs new file mode 100644 index 00000000000..a72369e2d2c --- /dev/null +++ b/examples/error-pages/views/404.ejs @@ -0,0 +1,3 @@ +<% include error_header %> +

Cannot find <%= url %>

+<% include footer %> diff --git a/examples/error-pages/views/404.jade b/examples/error-pages/views/404.jade deleted file mode 100644 index db7b05d9fcf..00000000000 --- a/examples/error-pages/views/404.jade +++ /dev/null @@ -1,5 +0,0 @@ - -extends error - -block content - h2 Cannot find #{url} \ No newline at end of file diff --git a/examples/error-pages/views/500.ejs b/examples/error-pages/views/500.ejs new file mode 100644 index 00000000000..8c1e0e80fb8 --- /dev/null +++ b/examples/error-pages/views/500.ejs @@ -0,0 +1,8 @@ +<% include error_header %> +

Error: <%= error.message %>

+<% if (settings['verbose errors']) { %> +
<%= error.stack %>
+<% } else { %> +

An error occurred!

+<% } %> +<% include footer %> diff --git a/examples/error-pages/views/500.jade b/examples/error-pages/views/500.jade deleted file mode 100644 index e44489de995..00000000000 --- a/examples/error-pages/views/500.jade +++ /dev/null @@ -1,13 +0,0 @@ - -// note that we extend a different -// layout with jade for 4xx & 5xx -// responses - -extends error - -block content - h1 Error: #{error.message} - if settings['verbose errors'] - pre= error.stack - else - p An error ocurred! \ No newline at end of file diff --git a/examples/error-pages/views/error.jade b/examples/error-pages/views/error.jade deleted file mode 100644 index bf750c00878..00000000000 --- a/examples/error-pages/views/error.jade +++ /dev/null @@ -1,6 +0,0 @@ -html - head - title Error - body - h1 An error occurred! - block content \ No newline at end of file diff --git a/examples/error-pages/views/error_header.ejs b/examples/error-pages/views/error_header.ejs new file mode 100644 index 00000000000..6d541dd9f5c --- /dev/null +++ b/examples/error-pages/views/error_header.ejs @@ -0,0 +1,8 @@ + + + +Error + + + +

An error occurred!

diff --git a/examples/error-pages/views/footer.ejs b/examples/error-pages/views/footer.ejs new file mode 100644 index 00000000000..308b1d01b6c --- /dev/null +++ b/examples/error-pages/views/footer.ejs @@ -0,0 +1,2 @@ + + diff --git a/examples/error-pages/views/index.ejs b/examples/error-pages/views/index.ejs new file mode 100644 index 00000000000..04a1a7847b9 --- /dev/null +++ b/examples/error-pages/views/index.ejs @@ -0,0 +1,18 @@ + + + +Custom Pages Example + + + +

My Site

+

Pages Example

+ + + + + diff --git a/examples/error-pages/views/index.jade b/examples/error-pages/views/index.jade deleted file mode 100644 index da8f0f1698f..00000000000 --- a/examples/error-pages/views/index.jade +++ /dev/null @@ -1,15 +0,0 @@ - -extends layout - -block content - h2 Pages Example - ul - li - | visit - a(href="/500") 500 - li - | visit - a(href="/404") 404 - li - | visit - a(href='/403') 403 \ No newline at end of file diff --git a/examples/error-pages/views/layout.jade b/examples/error-pages/views/layout.jade deleted file mode 100644 index 8a6f7b17470..00000000000 --- a/examples/error-pages/views/layout.jade +++ /dev/null @@ -1,6 +0,0 @@ -html - head - title Custom Pages Example - body - h1 My Site - block content \ No newline at end of file diff --git a/examples/mvc/controllers/pet/index.js b/examples/mvc/controllers/pet/index.js index 9f3c34525ef..a0cbaea59c0 100644 --- a/examples/mvc/controllers/pet/index.js +++ b/examples/mvc/controllers/pet/index.js @@ -1,7 +1,7 @@ var db = require('../../db'); -exports.engine = 'jade'; +exports.engine = 'ejs'; exports.before = function(req, res, next){ var pet = db.pets[req.params.pet_id]; diff --git a/examples/mvc/controllers/pet/views/edit.ejs b/examples/mvc/controllers/pet/views/edit.ejs new file mode 100644 index 00000000000..0158181ba58 --- /dev/null +++ b/examples/mvc/controllers/pet/views/edit.ejs @@ -0,0 +1,16 @@ + + + + +Edit <%= pet.name %> + + + +

<%= pet.name %>

+
+ + + +
+ + diff --git a/examples/mvc/controllers/pet/views/edit.jade b/examples/mvc/controllers/pet/views/edit.jade deleted file mode 100644 index 911a54a3088..00000000000 --- a/examples/mvc/controllers/pet/views/edit.jade +++ /dev/null @@ -1,7 +0,0 @@ -link(rel='stylesheet', href='/style.css') -h1= pet.name -form(action='/pet/#{pet.id}', method='post') - input(type='hidden', name='_method', value='put') - label Name: - input(type='text', name='user[name]', value=pet.name) - input(type='submit', value='Update') diff --git a/examples/mvc/controllers/pet/views/show.ejs b/examples/mvc/controllers/pet/views/show.ejs new file mode 100644 index 00000000000..2ec7b0bf063 --- /dev/null +++ b/examples/mvc/controllers/pet/views/show.ejs @@ -0,0 +1,13 @@ + + + + +<%= pet.name %> + + + +

<%= pet.name %> edit

+ +

You are viewing <%= pet.name %>

+ + diff --git a/examples/mvc/controllers/pet/views/show.jade b/examples/mvc/controllers/pet/views/show.jade deleted file mode 100644 index ad57ae73847..00000000000 --- a/examples/mvc/controllers/pet/views/show.jade +++ /dev/null @@ -1,6 +0,0 @@ -link(rel='stylesheet', href='/style.css') - -h1= pet.name - a(href='/pet/#{pet.id}/edit') edit - -p You are viewing #{pet.name} diff --git a/package.json b/package.json index f7ade51bd8c..2a465534251 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,6 @@ "should": "~4.3.0", "supertest": "~0.15.0", "ejs": "~1.0.0", - "jade": "~1.7.0", "hjs": "~0.0.6", "marked": "0.3.2" }, From ebfa00a9c04ba7d911cd5ad88c1e0567c935ae22 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 29 Nov 2014 12:10:30 -0500 Subject: [PATCH 0670/1265] build: remove support folder --- support/app.js | 66 ---------------------------------------- support/docs | 21 ------------- support/views/hello.jade | 1 - 3 files changed, 88 deletions(-) delete mode 100644 support/app.js delete mode 100755 support/docs delete mode 100644 support/views/hello.jade diff --git a/support/app.js b/support/app.js deleted file mode 100644 index 42198d92d99..00000000000 --- a/support/app.js +++ /dev/null @@ -1,66 +0,0 @@ - -/** - * Module dependencies. - */ - -var express = require('../'); - -var app = express() - , blog = express() - , admin = express(); - -// app.use(express.logger('dev')) -blog.use('/admin', admin); -app.use('/blog', blog); -app.set('views', __dirname + '/views'); -app.set('view engine', 'jade'); -app.locals.self = true; - -app.get('/render', function(req, res){ - res.render('hello'); -}); - -admin.get('/', function(req, res){ - res.send('Hello World\n'); -}); - -blog.get('/', function(req, res){ - res.send('Hello World\n'); -}); - -app.get('/', function(req, res){ - res.send('Hello World\n'); -}); - -app.get('/json', function(req, res){ - res.send({ name: 'Tobi', role: 'admin' }); -}); - -app.get('/json/:n', function(req, res){ - var n = ~~req.params.n; - var arr = []; - var obj = { name: 'Tobi', role: 'admin' }; - while (n--) arr.push(obj); - res.send(arr); -}); - -function foo(req, res, next) { - next(); -} - -app.get('/middleware', foo, foo, foo, foo, function(req, res){ - res.send('Hello World\n'); -}); - -var n = 100; -while (n--) { - app.get('/foo', foo, foo, function(req, res){ - - }); -} - -app.get('/match', function(req, res){ - res.send('Hello World\n'); -}); - -app.listen(8000); diff --git a/support/docs b/support/docs deleted file mode 100755 index f97588a35ce..00000000000 --- a/support/docs +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env node - -var buf = ''; -process.stdin.setEncoding('utf8'); -process.stdin.on('data', function(chunk){ - buf += chunk; -}).on('end', function(){ - var comments = JSON.parse(buf); - comments.forEach(function(comment){ - if (comment.ignore) return; - if (comment.isPrivate) return; - if (!comment.ctx) return; - if (!comment.description.full.indexOf('Module dep')) return; - var ctx = comment.ctx; - console.log(); - console.log('# %s', ctx.string); - console.log(); - console.log(comment.description.full.trim().replace(/^/gm, ' ')); - }); - console.log(); -}).resume(); \ No newline at end of file diff --git a/support/views/hello.jade b/support/views/hello.jade deleted file mode 100644 index 09a0111cce1..00000000000 --- a/support/views/hello.jade +++ /dev/null @@ -1 +0,0 @@ -p Hello \ No newline at end of file From c24463d8298d9dc2d924d346adc8d4db8f4e1928 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 10 Dec 2014 12:25:43 -0500 Subject: [PATCH 0671/1265] Fix res.send double-calling res.end for HEAD requests fixes #2467 --- History.md | 5 +++++ lib/response.js | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index f48fa494a4f..f86b76f9f12 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix `res.send` double-calling `res.end` for `HEAD` requests + 4.10.4 / 2014-11-24 =================== diff --git a/lib/response.js b/lib/response.js index d040da726bc..f21cbe27de7 100644 --- a/lib/response.js +++ b/lib/response.js @@ -182,14 +182,14 @@ res.send = function send(body) { chunk = ''; } - // skip body for HEAD if (isHead) { + // skip body for HEAD this.end(); + } else { + // respond + this.end(chunk, encoding); } - // respond - this.end(chunk, encoding); - return this; }; From d5ad34b0e9b57821f70f7659cccfc28b0f1c42e1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 10 Dec 2014 22:55:36 -0500 Subject: [PATCH 0672/1265] deps: connect@2.27.6 --- History.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9efc8261edf..4f5733b0735 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,13 @@ +3.x +=== + + * deps: connect@2.27.6 + - deps: compression@~1.2.2 + - deps: express-session@~1.9.3 + - deps: http-errors@~1.2.8 + - deps: serve-index@~1.5.3 + - deps: type-is@~1.5.4 + 3.18.4 / 2014-11-23 =================== diff --git a/package.json b/package.json index 2a465534251..ea54a9b77c7 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.27.4", + "connect": "2.27.6", "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", From f0b679d02da97d82705dfa3d23b7821895e65a44 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 10 Dec 2014 23:49:34 -0500 Subject: [PATCH 0673/1265] deps: accepts@~1.1.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f86b76f9f12..04a6d1d5201 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * Fix `res.send` double-calling `res.end` for `HEAD` requests + * deps: accepts@~1.1.4 + - deps: mime-types@~2.0.4 4.10.4 / 2014-11-24 =================== diff --git a/package.json b/package.json index 363889e6219..fd0f55e2f33 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.1.3", + "accepts": "~1.1.4", "content-disposition": "0.5.0", "cookie-signature": "1.0.5", "debug": "~2.1.0", From 4370908674c21ff88d46f3e99ce2978959168d65 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 10 Dec 2014 23:50:58 -0500 Subject: [PATCH 0674/1265] deps: type-is@~1.5.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 04a6d1d5201..fc0164c14c1 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * Fix `res.send` double-calling `res.end` for `HEAD` requests * deps: accepts@~1.1.4 - deps: mime-types@~2.0.4 + * deps: type-is@~1.5.4 + - deps: mime-types@~2.0.4 4.10.4 / 2014-11-24 =================== diff --git a/package.json b/package.json index fd0f55e2f33..4cb2415eb19 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "range-parser": "~1.0.2", "send": "0.10.1", "serve-static": "~1.7.1", - "type-is": "~1.5.3", + "type-is": "~1.5.4", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2", From 4d8093302f752725874d6b31b57720d4cab6d078 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 10 Dec 2014 23:53:31 -0500 Subject: [PATCH 0675/1265] 4.10.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index fc0164c14c1..c6201a11ddb 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.5 / 2014-12-10 +=================== * Fix `res.send` double-calling `res.end` for `HEAD` requests * deps: accepts@~1.1.4 diff --git a/package.json b/package.json index 4cb2415eb19..716a9f80bfb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.4", + "version": "4.10.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From ce89c00cd9848885fbc678fbec22b6b5662f7e70 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 11 Dec 2014 23:01:12 -0500 Subject: [PATCH 0676/1265] deps: istanbul@0.3.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea54a9b77c7..1a8d6e94e67 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "connect-redis": "~1.5.0", - "istanbul": "0.3.2", + "istanbul": "0.3.5", "mocha": "~2.0.0", "should": "~4.3.0", "supertest": "~0.15.0", From e77e644224cd071f5c3425b80505fbd4b7bc214f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 11 Dec 2014 23:03:01 -0500 Subject: [PATCH 0677/1265] deps: should@~4.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a8d6e94e67..4be646f8d1d 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "connect-redis": "~1.5.0", "istanbul": "0.3.5", "mocha": "~2.0.0", - "should": "~4.3.0", + "should": "~4.3.1", "supertest": "~0.15.0", "ejs": "~1.0.0", "hjs": "~0.0.6", From 262b60537fd39c76420246d38c813a1743bf223e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 11 Dec 2014 23:10:34 -0500 Subject: [PATCH 0678/1265] 3.18.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 4f5733b0735..74e60c40b0b 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.18.5 / 2014-12-11 +=================== * deps: connect@2.27.6 - deps: compression@~1.2.2 diff --git a/package.json b/package.json index 4be646f8d1d..257274382b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.18.4", + "version": "3.18.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 5d74a553d67d23b8fd0c236c162fd0b556b9bdfe Mon Sep 17 00:00:00 2001 From: Troy Goode Date: Thu, 11 Dec 2014 20:34:26 -0800 Subject: [PATCH 0679/1265] Fix exception in req.fresh/req.stale without response headers fixes #2468 --- History.md | 5 +++++ lib/request.js | 2 +- test/req.fresh.js | 13 +++++++++++++ test/req.stale.js | 13 +++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 74e60c40b0b..94748f1e15d 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.x +=== + + * Fix exception in `req.fresh`/`req.stale` without response headers + 3.18.5 / 2014-12-11 =================== diff --git a/lib/request.js b/lib/request.js index 683d54805c0..c1392396c19 100644 --- a/lib/request.js +++ b/lib/request.js @@ -526,7 +526,7 @@ req.__defineGetter__('fresh', function(){ // 2xx or 304 as per rfc2616 14.26 if ((s >= 200 && s < 300) || 304 == s) { - return fresh(this.headers, this.res._headers); + return fresh(this.headers, (this.res._headers || {})); } return false; diff --git a/test/req.fresh.js b/test/req.fresh.js index be23c43a6de..fdf4b07d591 100644 --- a/test/req.fresh.js +++ b/test/req.fresh.js @@ -32,5 +32,18 @@ describe('req', function(){ .set('If-None-Match', '"12345"') .expect(200, 'false', done); }) + + it('should return false without response headers', function(done){ + var app = express(); + + app.use(function(req, res){ + res._headers = undefined; + res.send(req.fresh); + }); + + request(app) + .get('/') + .expect(200, 'false', done); + }) }) }) diff --git a/test/req.stale.js b/test/req.stale.js index a52237f3c06..70fee02c992 100644 --- a/test/req.stale.js +++ b/test/req.stale.js @@ -32,5 +32,18 @@ describe('req', function(){ .set('If-None-Match', '"12345"') .expect(200, 'true', done); }) + + it('should return true without response headers', function(done){ + var app = express(); + + app.use(function(req, res){ + res._headers = undefined; + res.send(req.stale); + }); + + request(app) + .get('/') + .expect(200, 'true', done); + }) }) }) From 4405b849a9ea62dfa76f32031e187c844f8e217d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 12 Dec 2014 21:39:47 -0500 Subject: [PATCH 0680/1265] 3.18.6 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 94748f1e15d..706d453b85a 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.18.6 / 2014-12-12 +=================== * Fix exception in `req.fresh`/`req.stale` without response headers diff --git a/package.json b/package.json index 257274382b1..80f4cdfe01e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.18.5", + "version": "3.18.6", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From b78bd3d1fd6caf8228a1875078fecce936cb2e46 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 12 Dec 2014 23:13:34 -0500 Subject: [PATCH 0681/1265] 4.10.6 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index cc89dfa5929..667ee8ff827 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.6 / 2014-12-12 +=================== * Fix exception in `req.fresh`/`req.stale` without response headers diff --git a/package.json b/package.json index 3960bdd1ae5..10fefaeae5f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.5", + "version": "4.10.6", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 98585d1d0a789c64df3260a5518c4f7212d0ddf0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 17:40:22 -0500 Subject: [PATCH 0682/1265] deps: finalhandler@0.3.3 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 667ee8ff827..a45a9a113af 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +unreleased +========== + + * deps: finalhandler@0.3.3 + - deps: debug@~2.1.1 + - deps: on-finished@~2.2.0 + 4.10.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 10fefaeae5f..1ed97aaf91d 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "depd": "~1.0.0", "escape-html": "1.0.1", "etag": "~1.5.1", - "finalhandler": "0.3.2", + "finalhandler": "0.3.3", "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.0", From 571ce16405ae210d7c1725238f74018c070e40c0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 17:42:57 -0500 Subject: [PATCH 0683/1265] deps: methods@~1.1.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a45a9a113af..a5a188203db 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * deps: finalhandler@0.3.3 - deps: debug@~2.1.1 - deps: on-finished@~2.2.0 + * deps: methods@~1.1.1 4.10.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 1ed97aaf91d..9583e437152 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "finalhandler": "0.3.3", "fresh": "0.2.4", "media-typer": "0.3.0", - "methods": "1.1.0", + "methods": "1.1.1", "on-finished": "~2.1.1", "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", From 6e9cfa2aea35ba3add2e8ff4a4a544723f113cb3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 17:46:41 -0500 Subject: [PATCH 0684/1265] deps: on-finished@~2.2.0 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a5a188203db..1c32c16b916 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased - deps: debug@~2.1.1 - deps: on-finished@~2.2.0 * deps: methods@~1.1.1 + * deps: on-finished@~2.2.0 4.10.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 9583e437152..fad5ead2da8 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "fresh": "0.2.4", "media-typer": "0.3.0", "methods": "1.1.1", - "on-finished": "~2.1.1", + "on-finished": "~2.2.0", "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.4", From a7227a09649cfb6ebb03885b717ae18a56281085 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 17:47:25 -0500 Subject: [PATCH 0685/1265] deps: debug@~2.1.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1c32c16b916..17e9dd8a011 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * deps: debug@~2.1.1 * deps: finalhandler@0.3.3 - deps: debug@~2.1.1 - deps: on-finished@~2.2.0 diff --git a/package.json b/package.json index fad5ead2da8..920a45ecb32 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "accepts": "~1.1.4", "content-disposition": "0.5.0", "cookie-signature": "1.0.5", - "debug": "~2.1.0", + "debug": "~2.1.1", "depd": "~1.0.0", "escape-html": "1.0.1", "etag": "~1.5.1", From 2d6faf6da78e2af3ce5d76bc400a8dd70bf5760d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 17:49:39 -0500 Subject: [PATCH 0686/1265] deps: serve-static@~1.7.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 17e9dd8a011..ce4bc5dc669 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ unreleased - deps: on-finished@~2.2.0 * deps: methods@~1.1.1 * deps: on-finished@~2.2.0 + * deps: serve-static@~1.7.2 + - Fix potential open redirect when mounted at root 4.10.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 920a45ecb32..638c3d20ad3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "qs": "2.3.3", "range-parser": "~1.0.2", "send": "0.10.1", - "serve-static": "~1.7.1", + "serve-static": "~1.7.2", "type-is": "~1.5.4", "vary": "~1.0.0", "cookie": "0.1.2", From f76403b717dc59d0fea41e5da68bd50d95b42fdf Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 17:50:42 -0500 Subject: [PATCH 0687/1265] deps: type-is@~1.5.5 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ce4bc5dc669..52a05063734 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,8 @@ unreleased * deps: on-finished@~2.2.0 * deps: serve-static@~1.7.2 - Fix potential open redirect when mounted at root + * deps: type-is@~1.5.5 + - deps: mime-types@~2.0.7 4.10.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 638c3d20ad3..4a71c272bfc 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "range-parser": "~1.0.2", "send": "0.10.1", "serve-static": "~1.7.2", - "type-is": "~1.5.4", + "type-is": "~1.5.5", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2", From 3387916efcac19302188151a24927a0405a373e8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 18:26:15 -0500 Subject: [PATCH 0688/1265] Fix incorrect "Request aborted" for res.sendFile when HEAD or 304 fixes #2481 --- History.md | 1 + lib/response.js | 23 ++++++++++- test/res.sendFile.js | 93 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 52a05063734..3e859893177 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix incorrect "Request aborted" for `res.sendFile` when `HEAD` or 304 * deps: debug@~2.1.1 * deps: finalhandler@0.3.3 - deps: debug@~2.1.1 diff --git a/lib/response.js b/lib/response.js index f21cbe27de7..87d1dc5d0a1 100644 --- a/lib/response.js +++ b/lib/response.js @@ -907,6 +907,7 @@ res.render = function(view, options, fn){ // pipe the send file stream function sendfile(res, file, options, callback) { var done = false; + var streaming = false; // directory function ondirectory() { @@ -920,6 +921,7 @@ function sendfile(res, file, options, callback) { // errors function onerror(err) { + if (!err) return; if (done) return; done = true; callback(err); @@ -932,6 +934,11 @@ function sendfile(res, file, options, callback) { callback(); } + // file + function onfile() { + onFinished(res, onfinish); + } + // finished function onfinish(err) { if (err) return onerror(err); @@ -941,6 +948,11 @@ function sendfile(res, file, options, callback) { if (done) return; done = true; + if (!streaming) { + callback(); + return; + } + // response finished before end of file var err = new Error('Request aborted'); err.code = 'ECONNABORT'; @@ -948,10 +960,17 @@ function sendfile(res, file, options, callback) { }); } + // streaming + function onstream() { + streaming = true; + } + + file.on('directory', ondirectory); file.on('end', onend); file.on('error', onerror); - file.on('directory', ondirectory); - onFinished(res, onfinish); + file.on('file', onfile); + file.on('stream', onstream); + onFinished(res, onerror); if (options.headers) { // set headers on successful transfer diff --git a/test/res.sendFile.js b/test/res.sendFile.js index 4dfb17528b9..c53e10ae672 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -34,6 +34,31 @@ describe('res', function(){ .expect(200, '20%', done); }); + it('should include ETag', function (done) { + var app = createApp(path.resolve(fixtures, 'name.txt')); + + request(app) + .get('/') + .expect('ETag', /^(?:W\/)?"[^"]+"$/) + .expect(200, 'tobi', done); + }); + + it('should 304 when ETag matches', function (done) { + var app = createApp(path.resolve(fixtures, 'name.txt')); + + request(app) + .get('/') + .expect('ETag', /^(?:W\/)?"[^"]+"$/) + .expect(200, 'tobi', function (err, res) { + if (err) return done(err); + var etag = res.headers.etag; + request(app) + .get('/') + .set('If-None-Match', etag) + .expect(304, done); + }); + }); + it('should 404 for directory', function (done) { var app = createApp(path.resolve(fixtures, 'blog')); @@ -212,6 +237,40 @@ describe('res', function(){ test.expect(200, cb); }) + it('should invoke the callback without error when HEAD', function (done) { + var app = express(); + var cb = after(2, done); + + app.use(function (req, res) { + res.sendFile(path.resolve(fixtures, 'name.txt'), cb); + }); + + request(app) + .head('/') + .expect(200, cb); + }); + + it('should invoke the callback without error when 304', function (done) { + var app = express(); + var cb = after(3, done); + + app.use(function (req, res) { + res.sendFile(path.resolve(fixtures, 'name.txt'), cb); + }); + + request(app) + .get('/') + .expect('ETag', /^(?:W\/)?"[^"]+"$/) + .expect(200, 'tobi', function (err, res) { + if (err) return cb(err); + var etag = res.headers.etag; + request(app) + .get('/') + .set('If-None-Match', etag) + .expect(304, cb); + }); + }); + it('should invoke the callback on 404', function(done){ var app = express(); @@ -294,6 +353,40 @@ describe('res', function(){ test.expect(200, cb); }) + it('should invoke the callback without error when HEAD', function (done) { + var app = express(); + var cb = after(2, done); + + app.use(function (req, res) { + res.sendfile('test/fixtures/name.txt', cb); + }); + + request(app) + .head('/') + .expect(200, cb); + }); + + it('should invoke the callback without error when 304', function (done) { + var app = express(); + var cb = after(3, done); + + app.use(function (req, res) { + res.sendfile('test/fixtures/name.txt', cb); + }); + + request(app) + .get('/') + .expect('ETag', /^(?:W\/)?"[^"]+"$/) + .expect(200, 'tobi', function (err, res) { + if (err) return cb(err); + var etag = res.headers.etag; + request(app) + .get('/') + .set('If-None-Match', etag) + .expect(304, cb); + }); + }); + it('should invoke the callback on 404', function(done){ var app = express() , calls = 0; From 12626aed35a6d1ef4466fa0d67613a53db8b1149 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 19:07:21 -0500 Subject: [PATCH 0689/1265] Fix Allow header for OPTIONS to not contain duplicate methods fixes #2458 --- History.md | 1 + lib/router/index.js | 12 +++++++++++- test/app.options.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3e859893177..57cc574e785 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix `Allow` header for `OPTIONS` to not contain duplicate methods * Fix incorrect "Request aborted" for `res.sendFile` when `HEAD` or 304 * deps: debug@~2.1.1 * deps: finalhandler@0.3.3 diff --git a/lib/router/index.js b/lib/router/index.js index b3a42e290c9..488713915e9 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -207,7 +207,7 @@ proto.handle = function(req, res, done) { // build up automatic options response if (!has_method && method === 'OPTIONS') { - options.push.apply(options, route._options()); + appendMethods(options, route._options()); } // don't even bother @@ -492,6 +492,16 @@ methods.concat('all').forEach(function(method){ }; }); +// append methods to a list of methods +function appendMethods(list, addition) { + for (var i = 0; i < addition.length; i++) { + var method = addition[i]; + if (list.indexOf(method) === -1) { + list.push(method); + } + } +} + // get type for error message function gettype(obj) { var type = typeof obj; diff --git a/test/app.options.js b/test/app.options.js index 98fefe9a0bd..3d484ef17d0 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -16,6 +16,20 @@ describe('OPTIONS', function(){ .expect('Allow', 'GET,PUT', done); }) + it('should only include each method once', function(done){ + var app = express(); + + app.del('/', function(){}); + app.get('/users', function(req, res){}); + app.put('/users', function(req, res){}); + app.get('/users', function(req, res){}); + + request(app) + .options('/users') + .expect('GET,PUT') + .expect('Allow', 'GET,PUT', done); + }) + it('should not be affected by app.all', function(done){ var app = express(); From d842647217feeb3024e8056fabacc8bab1b382f0 Mon Sep 17 00:00:00 2001 From: Nick Mandel Date: Mon, 15 Dec 2014 20:41:05 -0800 Subject: [PATCH 0690/1265] docs: readme tweaks closes #2471 --- Readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 24bc5822222..748e1ee81f3 100644 --- a/Readme.md +++ b/Readme.md @@ -18,7 +18,7 @@ app.get('/', function (req, res) { app.listen(3000) ``` -### Installation +## Installation ```bash $ npm install express @@ -86,7 +86,7 @@ $ npm start ## Examples - To view the examples, clone the Express repo & install the dependancies: + To view the examples, clone the Express repo and install the dependancies: ```bash $ git clone git://github.com/strongloop/express.git --depth 1 @@ -109,7 +109,7 @@ $ npm install $ npm test ``` -### People +## People The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia] @@ -117,7 +117,7 @@ The current lead maintainer is [Douglas Christopher Wilson](https://github.com/d [List of all contributors](https://github.com/strongloop/express/graphs/contributors) -### License +## License [MIT](LICENSE) From ff5e96c88b23ebf0bb9bf99f9195b5b40215502f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jan 2015 19:33:31 -0500 Subject: [PATCH 0691/1265] 4.10.7 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 57cc574e785..20a7b43566f 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.7 / 2015-01-04 +=================== * Fix `Allow` header for `OPTIONS` to not contain duplicate methods * Fix incorrect "Request aborted" for `res.sendFile` when `HEAD` or 304 diff --git a/package.json b/package.json index 4a71c272bfc..5ea14e218f6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.6", + "version": "4.10.7", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From a715ba6be40247b360cfbf3ca96efa29be4282af Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 17:06:08 -0500 Subject: [PATCH 0692/1265] docs: Gittip is now Gratipay --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index e63a689a13d..4200fe730eb 100644 --- a/Readme.md +++ b/Readme.md @@ -5,7 +5,7 @@ [![NPM version](https://img.shields.io/npm/v/express.svg?style=flat)](https://www.npmjs.org/package/express) [![Build Status](https://img.shields.io/travis/strongloop/express.svg?style=flat)](https://travis-ci.org/strongloop/express) [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg?style=flat)](https://coveralls.io/r/strongloop/express) - [![Gittip](https://img.shields.io/gittip/dougwilson.svg?style=flat)](https://www.gittip.com/dougwilson/) + [![Gratipay](https://img.shields.io/gratipay/dougwilson.svg?style=flat)](https://gratipay.com/dougwilson/) ```js var express = require('express'); From c163d2f33d7aa45746d4cf399b2d5b4d99db21c5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 21:18:56 -0500 Subject: [PATCH 0693/1265] deps: connect@2.28.1 --- History.md | 19 +++++++++++++++++++ package.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 706d453b85a..ffb3c49297b 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,22 @@ +3.x +=== + + * deps: connect@2.28.1 + - deps: body-parser@~1.10.1 + - deps: compression@~1.3.0 + - deps: connect-timeout@~1.5.0 + - deps: csurf@~1.6.4 + - deps: debug@~2.1.1 + - deps: errorhandler@~1.3.2 + - deps: express-session@~1.10.1 + - deps: finalhandler@0.3.3 + - deps: method-override@~2.3.1 + - deps: morgan@~1.5.1 + - deps: serve-favicon@~2.2.0 + - deps: serve-index@~1.6.0 + - deps: serve-static@~1.8.0 + - deps: type-is@~1.5.5 + 3.18.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 80f4cdfe01e..e156e15706d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.27.6", + "connect": "2.28.1", "content-disposition": "0.5.0", "commander": "1.3.2", "cookie-signature": "1.0.5", From 33e4193f454ea8df41be0136f3900e29aded97b1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 21:24:28 -0500 Subject: [PATCH 0694/1265] deps: should@~4.4.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e156e15706d..4e045b3d0ea 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "connect-redis": "~1.5.0", "istanbul": "0.3.5", "mocha": "~2.0.0", - "should": "~4.3.1", + "should": "~4.4.4", "supertest": "~0.15.0", "ejs": "~1.0.0", "hjs": "~0.0.6", From 2dd332b4912d19d77f4d6672507636fb388b3f50 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 21:25:17 -0500 Subject: [PATCH 0695/1265] deps: mocha@~2.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e045b3d0ea..01ecc93e9f4 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "devDependencies": { "connect-redis": "~1.5.0", "istanbul": "0.3.5", - "mocha": "~2.0.0", + "mocha": "~2.1.0", "should": "~4.4.4", "supertest": "~0.15.0", "ejs": "~1.0.0", From 224fe056973abf69fef2f17d2881f9014c5b817a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 21:31:32 -0500 Subject: [PATCH 0696/1265] deps: methods@~1.1.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ffb3c49297b..784f165a290 100644 --- a/History.md +++ b/History.md @@ -16,6 +16,7 @@ - deps: serve-index@~1.6.0 - deps: serve-static@~1.8.0 - deps: type-is@~1.5.5 + * deps: methods@~1.1.1 3.18.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 01ecc93e9f4..e1394cee430 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "etag": "~1.5.1", "fresh": "0.2.4", "media-typer": "0.3.0", - "methods": "1.1.0", + "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0", "proxy-addr": "~1.0.4", From 1afcff955b6b3606c08bbee85b5616953da4d0d6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 22:14:46 -0500 Subject: [PATCH 0697/1265] deps: proxy-addr@~1.0.5 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 784f165a290..82354be189f 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,8 @@ - deps: serve-static@~1.8.0 - deps: type-is@~1.5.5 * deps: methods@~1.1.1 + * deps: proxy-addr@~1.0.5 + - deps: ipaddr.js@0.1.6 3.18.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index e1394cee430..27782ce4fb4 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0", - "proxy-addr": "~1.0.4", + "proxy-addr": "~1.0.5", "range-parser": "~1.0.2", "send": "0.10.1", "utils-merge": "1.0.0", From 192be8fea33489de9982e21e79f9077ab8b3a3a0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 22:15:53 -0500 Subject: [PATCH 0698/1265] deps: send@0.11.0 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 82354be189f..5d681e2a952 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,11 @@ * deps: methods@~1.1.1 * deps: proxy-addr@~1.0.5 - deps: ipaddr.js@0.1.6 + * deps: send@0.11.0 + - deps: debug@~2.1.1 + - deps: etag@~1.5.1 + - deps: ms@0.7.0 + - deps: on-finished@~2.2.0 3.18.6 / 2014-12-12 =================== diff --git a/package.json b/package.json index 27782ce4fb4..351b56c03fc 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.5", "range-parser": "~1.0.2", - "send": "0.10.1", + "send": "0.11.0", "utils-merge": "1.0.0", "vary": "~1.0.0", "cookie": "0.1.2", From 3a1d9b8289884c7d4cb4de8ef9b7dc9a64fa2308 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 22:17:19 -0500 Subject: [PATCH 0699/1265] deps: ejs@2.0.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 351b56c03fc..f6c98079ab1 100644 --- a/package.json +++ b/package.json @@ -50,11 +50,11 @@ }, "devDependencies": { "connect-redis": "~1.5.0", + "ejs": "2.0.8", "istanbul": "0.3.5", "mocha": "~2.1.0", "should": "~4.4.4", "supertest": "~0.15.0", - "ejs": "~1.0.0", "hjs": "~0.0.6", "marked": "0.3.2" }, From ec1175daa3700e236814d3f67fc0c851fe71e9dc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 22:21:50 -0500 Subject: [PATCH 0700/1265] Use readline for prompt in express(1) --- History.md | 1 + bin/express | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5d681e2a952..a9c0a3c8d3e 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Use `readline` for prompt in `express(1)` * deps: connect@2.28.1 - deps: body-parser@~1.10.1 - deps: compression@~1.3.0 diff --git a/bin/express b/bin/express index a95df72841b..b060062e93d 100755 --- a/bin/express +++ b/bin/express @@ -7,6 +7,7 @@ var program = require('commander') , mkdirp = require('mkdirp') , pkg = require('../package.json') + , readline = require('readline') , version = pkg.version , os = require('os') , fs = require('fs'); @@ -249,7 +250,7 @@ var app = [ if (empty || program.force) { createApplicationAt(path); } else { - program.confirm('destination is not empty, continue? ', function(ok){ + confirm('destination is not empty, continue? [y/N] ', function (ok) { if (ok) { process.stdin.destroy(); createApplicationAt(path); @@ -261,6 +262,22 @@ var app = [ }); })(path); +/** + * Prompt for confirmation on STDOUT/STDIN + */ + +function confirm(msg, callback) { + var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + + rl.question(msg, function (input) { + rl.close(); + callback(/^y|yes|ok|true$/i.test(input)); + }); +} + /** * Create application at the given directory `path`. * From b0f8809e3d7940cdf2b1a728c5e1d70b786588bc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 22:23:04 -0500 Subject: [PATCH 0701/1265] deps: commander@2.6.0 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a9c0a3c8d3e..db029f144c1 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ === * Use `readline` for prompt in `express(1)` + * deps: commander@2.6.0 * deps: connect@2.28.1 - deps: body-parser@~1.10.1 - deps: compression@~1.3.0 diff --git a/package.json b/package.json index f6c98079ab1..b7260d56c72 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "basic-auth": "1.0.0", "connect": "2.28.1", "content-disposition": "0.5.0", - "commander": "1.3.2", + "commander": "2.6.0", "cookie-signature": "1.0.5", "debug": "~2.1.0", "depd": "~1.0.0", From 11529a2ea0294e548abae5201eae9ce5bdbb930e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Jan 2015 23:30:42 -0500 Subject: [PATCH 0702/1265] Fix OPTIONS responses to include the HEAD method property fixes #2459 --- History.md | 1 + lib/router/index.js | 35 +++++++++++++++++++++++++---------- test/app.options.js | 8 ++++---- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/History.md b/History.md index db029f144c1..91ea64bc0ea 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Fix `OPTIONS` responses to include the `HEAD` method property * Use `readline` for prompt in `express(1)` * deps: commander@2.6.0 * deps: connect@2.28.1 diff --git a/lib/router/index.js b/lib/router/index.js index 79997c6f701..a6bf8a82141 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -196,17 +196,32 @@ Router.prototype._options = function(req, res, next){ * @api private */ -Router.prototype._optionsFor = function(path){ - var self = this; - return methods.filter(function(method){ - var routes = self.map[method]; - if (!routes || 'options' == method) return; - for (var i = 0, len = routes.length; i < len; ++i) { - if (routes[i].match(path)) return true; +Router.prototype._optionsFor = function _optionsFor(path) { + var options = []; + + for (var i = 0; i < methods.length; i++) { + var method = methods[i]; + + if (method === 'options') continue; + + var routes = this.map[method]; + + // HEAD methods include GET routes + if (!routes && method === 'head') { + routes = this.map.get; } - }).map(function(method){ - return method.toUpperCase(); - }); + + if (!routes) continue; + + for (var j = 0; j < routes.length; j++) { + if (routes[j].match(path)) { + options.push(method.toUpperCase()); + break; + } + } + } + + return options.sort(); }; /** diff --git a/test/app.options.js b/test/app.options.js index 9a9852a7445..790a8925773 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -12,8 +12,8 @@ describe('OPTIONS', function(){ request(app) .options('/users') - .expect('GET,PUT') - .expect('Allow', 'GET,PUT', done); + .expect('GET,HEAD,PUT') + .expect('Allow', 'GET,HEAD,PUT', done); }) it('should not respond if the path is not defined', function(done){ @@ -36,8 +36,8 @@ describe('OPTIONS', function(){ request(app) .options('/other') - .expect('GET') - .expect('Allow', 'GET', done); + .expect('GET,HEAD') + .expect('Allow', 'GET,HEAD', done); }) }) From 34b6385dc3d3a745732b87bfba4c730c6e397bc2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 9 Jan 2015 01:05:41 -0500 Subject: [PATCH 0703/1265] deps: debug@~2.1.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 91ea64bc0ea..d1075f0ebbf 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,7 @@ - deps: serve-index@~1.6.0 - deps: serve-static@~1.8.0 - deps: type-is@~1.5.5 + * deps: debug@~2.1.1 * deps: methods@~1.1.1 * deps: proxy-addr@~1.0.5 - deps: ipaddr.js@0.1.6 diff --git a/package.json b/package.json index b7260d56c72..10d5350d1f7 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "content-disposition": "0.5.0", "commander": "2.6.0", "cookie-signature": "1.0.5", - "debug": "~2.1.0", + "debug": "~2.1.1", "depd": "~1.0.0", "escape-html": "1.0.1", "etag": "~1.5.1", From ee3f2b073cbd947a5108b0ed68faf8172a4af2ca Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 9 Jan 2015 01:07:12 -0500 Subject: [PATCH 0704/1265] 3.19.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index d1075f0ebbf..5a7edc26496 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.19.0 / 2015-01-09 +=================== * Fix `OPTIONS` responses to include the `HEAD` method property * Use `readline` for prompt in `express(1)` diff --git a/package.json b/package.json index 10d5350d1f7..6e97a65db3f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.18.6", + "version": "3.19.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From a3658642291b48dc948809a01e795c3455636caf Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 11 Jan 2015 12:09:34 -0500 Subject: [PATCH 0705/1265] deps: proxy-addr@~1.0.5 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 20a7b43566f..3e913c99385 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: proxy-addr@~1.0.5 + - deps: ipaddr.js@0.1.6 + 4.10.7 / 2015-01-04 =================== diff --git a/package.json b/package.json index 5ea14e218f6..bcb1e2f8c0c 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "on-finished": "~2.2.0", "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", - "proxy-addr": "~1.0.4", + "proxy-addr": "~1.0.5", "qs": "2.3.3", "range-parser": "~1.0.2", "send": "0.10.1", From 4070dabe532ecb799445920cf9756eb6625a0254 Mon Sep 17 00:00:00 2001 From: Sung Kim Date: Sat, 10 Jan 2015 07:32:40 -0500 Subject: [PATCH 0706/1265] Fix typo in comment closes #2493 --- lib/middleware/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/middleware/init.js b/lib/middleware/init.js index c09cf0c69c4..1e3e903f04f 100644 --- a/lib/middleware/init.js +++ b/lib/middleware/init.js @@ -1,6 +1,6 @@ /** * Initialization middleware, exposing the - * request and response to eachother, as well + * request and response to each other, as well * as defaulting the X-Powered-By header field. * * @param {Function} app From dab9222942cb9f7c3ff17abad4e0f6137c9e2cfc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 12 Jan 2015 18:00:49 -0500 Subject: [PATCH 0707/1265] Fix crash from error within OPTIONS response handler fixes #2494 --- History.md | 1 + lib/router/index.js | 15 ++++++++++++--- test/app.options.js | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 3e913c99385..8e7daf21854 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix crash from error within `OPTIONS` response handler * deps: proxy-addr@~1.0.5 - deps: ipaddr.js@0.1.6 diff --git a/lib/router/index.js b/lib/router/index.js index 488713915e9..37e3083fb76 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -152,9 +152,7 @@ proto.handle = function(req, res, done) { if (req.method === 'OPTIONS') { done = wrap(done, function(old, err) { if (err || options.length === 0) return old(err); - - var body = options.join(','); - return res.set('Allow', body).send(body); + sendOptionsResponse(res, options, old); }); } @@ -571,6 +569,17 @@ function restore(fn, obj) { }; } +// send an OPTIONS response +function sendOptionsResponse(res, options, next) { + try { + var body = options.join(','); + res.set('Allow', body); + res.send(body); + } catch (err) { + next(err); + } +} + // wrap a function function wrap(old, fn) { return function proxy() { diff --git a/test/app.options.js b/test/app.options.js index 3d484ef17d0..30890c05519 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -71,6 +71,28 @@ describe('OPTIONS', function(){ .expect('GET') .expect('Allow', 'GET', done); }) + + describe('when error occurs in respone handler', function () { + it('should pass error to callback', function (done) { + var app = express(); + var router = express.Router(); + + router.get('/users', function(req, res){}); + + app.use(function (req, res, next) { + res.writeHead(200); + next(); + }); + app.use(router); + app.use(function (err, req, res, next) { + res.end('true'); + }); + + request(app) + .options('/users') + .expect(200, 'true', done) + }) + }) }) describe('app.options()', function(){ From 55699bee8f69c9f711a340e6a9d335a7a7bc90d7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 12 Jan 2015 18:57:16 -0500 Subject: [PATCH 0708/1265] deps: update example dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bcb1e2f8c0c..b9d1555191a 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,14 @@ "ejs": "~1.0.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.9.3", + "body-parser": "~1.10.1", "connect-redis": "~2.1.0", "cookie-parser": "~1.3.3", "express-session": "~1.9.2", - "jade": "~1.7.0", - "method-override": "~2.3.0", - "morgan": "~1.5.0", - "multiparty": "~4.0.0", + "jade": "~1.8.2", + "method-override": "~2.3.1", + "morgan": "~1.5.1", + "multiparty": "~4.1.0", "vhost": "~3.0.0" }, "engines": { From 08939683c7a2e5d7dc928d310ebab65878bffff3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 12:38:09 -0500 Subject: [PATCH 0709/1265] 4.10.8 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 8e7daf21854..7834fffc0de 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.10.8 / 2015-01-13 +=================== * Fix crash from error within `OPTIONS` response handler * deps: proxy-addr@~1.0.5 diff --git a/package.json b/package.json index b9d1555191a..7eba07aec60 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.7", + "version": "4.10.8", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From fc4eb6dae01c32fba0af8b67663511583cb3ba5a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Nov 2014 22:30:58 -0500 Subject: [PATCH 0710/1265] Deprecate leading colon in name for app.param closes #2430 --- History.md | 5 +++++ lib/router/index.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/History.md b/History.md index 7834fffc0de..46f935c5fd7 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Deprecate leading `:` in `name` for `app.param(name, fn)` + 4.10.8 / 2015-01-13 =================== diff --git a/lib/router/index.js b/lib/router/index.js index 37e3083fb76..4a0a14700d7 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -8,6 +8,7 @@ var Layer = require('./layer'); var methods = require('methods'); var mixin = require('utils-merge'); var debug = require('debug')('express:router'); +var deprecate = require('depd')('express'); var parseUrl = require('parseurl'); var utils = require('../utils'); @@ -94,6 +95,7 @@ proto.param = function(name, fn){ var ret; if (name[0] === ':') { + deprecate('name with leading colon: remove leading colon from ' + JSON.stringify(name)); name = name.substr(1); } From 935f05bc8431a0700f737c679aa97d270794c7a5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 13:26:19 -0500 Subject: [PATCH 0711/1265] Fix OPTIONS responses to include the HEAD method properly fixes #2459 --- History.md | 1 + lib/router/route.js | 18 ++++++++++++++---- test/app.options.js | 16 ++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/History.md b/History.md index 46f935c5fd7..5fddc5792a8 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Deprecate leading `:` in `name` for `app.param(name, fn)` + * Fix `OPTIONS` responses to include the `HEAD` method properly 4.10.8 / 2015-01-13 =================== diff --git a/lib/router/route.js b/lib/router/route.js index 903d1a5e218..6213b821704 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -52,10 +52,20 @@ Route.prototype._handles_method = function _handles_method(method) { * @api private */ -Route.prototype._options = function(){ - return Object.keys(this.methods).map(function(method) { - return method.toUpperCase(); - }); +Route.prototype._options = function _options() { + var methods = Object.keys(this.methods); + + // append automatic head + if (this.methods.get && !this.methods.head) { + methods.push('head'); + } + + for (var i = 0; i < methods.length; i++) { + // make upper case + methods[i] = methods[i].toUpperCase(); + } + + return methods; }; /** diff --git a/test/app.options.js b/test/app.options.js index 30890c05519..20234723a57 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -12,8 +12,8 @@ describe('OPTIONS', function(){ request(app) .options('/users') - .expect('GET,PUT') - .expect('Allow', 'GET,PUT', done); + .expect('Allow', 'GET,HEAD,PUT') + .expect(200, 'GET,HEAD,PUT', done); }) it('should only include each method once', function(done){ @@ -26,8 +26,8 @@ describe('OPTIONS', function(){ request(app) .options('/users') - .expect('GET,PUT') - .expect('Allow', 'GET,PUT', done); + .expect('Allow', 'GET,HEAD,PUT') + .expect(200, 'GET,HEAD,PUT', done); }) it('should not be affected by app.all', function(done){ @@ -44,8 +44,8 @@ describe('OPTIONS', function(){ request(app) .options('/users') .expect('x-hit', '1') - .expect('allow', 'GET,PUT') - .expect(200, 'GET,PUT', done); + .expect('Allow', 'GET,HEAD,PUT') + .expect(200, 'GET,HEAD,PUT', done); }) it('should not respond if the path is not defined', function(done){ @@ -68,8 +68,8 @@ describe('OPTIONS', function(){ request(app) .options('/other') - .expect('GET') - .expect('Allow', 'GET', done); + .expect('Allow', 'GET,HEAD') + .expect(200, 'GET,HEAD', done); }) describe('when error occurs in respone handler', function () { From 5312a990b920d5ce1313fafaebcac2d440146c16 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 15:01:32 -0500 Subject: [PATCH 0712/1265] Fix res.sendFile not always detecting aborted connection fixes #2489 --- History.md | 1 + lib/response.js | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/History.md b/History.md index 5fddc5792a8..9128b16609a 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ unreleased * Deprecate leading `:` in `name` for `app.param(name, fn)` * Fix `OPTIONS` responses to include the `HEAD` method properly + * Fix `res.sendFile` not always detecting aborted connection 4.10.8 / 2015-01-13 =================== diff --git a/lib/response.js b/lib/response.js index 87d1dc5d0a1..7d6575c192d 100644 --- a/lib/response.js +++ b/lib/response.js @@ -907,7 +907,17 @@ res.render = function(view, options, fn){ // pipe the send file stream function sendfile(res, file, options, callback) { var done = false; - var streaming = false; + var streaming; + + // request aborted + function onaborted() { + if (done) return; + done = true; + + var err = new Error('Request aborted'); + err.code = 'ECONNABORT'; + callback(err); + } // directory function ondirectory() { @@ -921,7 +931,6 @@ function sendfile(res, file, options, callback) { // errors function onerror(err) { - if (!err) return; if (done) return; done = true; callback(err); @@ -936,7 +945,7 @@ function sendfile(res, file, options, callback) { // file function onfile() { - onFinished(res, onfinish); + streaming = false; } // finished @@ -945,18 +954,14 @@ function sendfile(res, file, options, callback) { if (done) return; setImmediate(function () { - if (done) return; - done = true; - - if (!streaming) { - callback(); + if (streaming !== false && !done) { + onaborted(); return; } - // response finished before end of file - var err = new Error('Request aborted'); - err.code = 'ECONNABORT'; - callback(err); + if (done) return; + done = true; + callback(); }); } @@ -970,7 +975,7 @@ function sendfile(res, file, options, callback) { file.on('error', onerror); file.on('file', onfile); file.on('stream', onstream); - onFinished(res, onerror); + onFinished(res, onfinish); if (options.headers) { // set headers on successful transfer From ec8daf0e7b020e5e597e7d7f85c88179a29a09cb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 24 Oct 2014 01:04:41 -0400 Subject: [PATCH 0713/1265] Match routes iteratively to prevent stack overflows fixes #2412 --- History.md | 1 + lib/router/index.js | 168 ++++++++++++++++++++++++++------------------ test/Router.js | 15 ++++ 3 files changed, 116 insertions(+), 68 deletions(-) diff --git a/History.md b/History.md index 9128b16609a..2e5245c8e36 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * Deprecate leading `:` in `name` for `app.param(name, fn)` * Fix `OPTIONS` responses to include the `HEAD` method properly * Fix `res.sendFile` not always detecting aborted connection + * Match routes iteratively to prevent stack overflows 4.10.8 / 2015-01-13 =================== diff --git a/lib/router/index.js b/lib/router/index.js index 4a0a14700d7..7f66579ab03 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -169,74 +169,104 @@ proto.handle = function(req, res, done) { ? null : err; - var layer = stack[idx++]; - + // remove added slash if (slashAdded) { req.url = req.url.substr(1); slashAdded = false; } + // restore altered req.url if (removed.length !== 0) { req.baseUrl = parentUrl; req.url = protohost + removed + req.url.substr(protohost.length); removed = ''; } - if (!layer) { + // no more matching layers + if (idx >= stack.length) { setImmediate(done, layerError); return; } - self.match_layer(layer, req, res, function (err, path) { - if (err || path === undefined) { - return next(layerError || err); + // get pathname of request + var path = getPathname(req); + + if (path == null) { + return done(layerError); + } + + // find next matching layer + var layer; + var match; + var route; + + while (match !== true && idx < stack.length) { + layer = stack[idx++]; + match = matchLayer(layer, path); + route = layer.route; + + if (typeof match !== 'boolean') { + // hold on to layerError + layerError = layerError || match; } - // route object and not middleware - var route = layer.route; + if (match !== true) { + continue; + } - // if final route, then we support options - if (route) { - // we don't run any routes with error first - if (layerError) { - return next(layerError); - } - - var method = req.method; - var has_method = route._handles_method(method); - - // build up automatic options response - if (!has_method && method === 'OPTIONS') { - appendMethods(options, route._options()); - } - - // don't even bother - if (!has_method && method !== 'HEAD') { - return next(); - } - - // we can now dispatch to the route - req.route = route; + if (!route) { + // process non-route handlers normally + continue; } - // Capture one-time layer values - req.params = self.mergeParams - ? mergeParams(layer.params, parentParams) - : layer.params; - var layerPath = layer.path; + if (layerError) { + // routes do not match with a pending error + match = false; + continue; + } - // this should be done for the layer - self.process_params(layer, paramcalled, req, res, function (err) { - if (err) { - return next(layerError || err); - } + var method = req.method; + var has_method = route._handles_method(method); - if (route) { - return layer.handle_request(req, res, next); - } + // build up automatic options response + if (!has_method && method === 'OPTIONS') { + appendMethods(options, route._options()); + } + + // don't even bother matching route + if (!has_method && method !== 'HEAD') { + match = false; + continue; + } + } - trim_prefix(layer, layerError, layerPath, path); - }); + // no match + if (match !== true) { + return done(layerError); + } + + // store route for dispatch on change + if (route) { + req.route = route; + } + + // Capture one-time layer values + req.params = self.mergeParams + ? mergeParams(layer.params, parentParams) + : layer.params; + var layerPath = layer.path; + + // this should be done for the layer + self.process_params(layer, paramcalled, req, res, function (err) { + if (err) { + return next(layerError || err); + } + + if (route) { + return layer.handle_request(req, res, next); + } + + trim_prefix(layer, layerError, layerPath, path); }); } @@ -273,29 +303,6 @@ proto.handle = function(req, res, done) { } }; -/** - * Match request to a layer. - * - * @api private - */ - -proto.match_layer = function match_layer(layer, req, res, done) { - var error = null; - var path; - - try { - path = parseUrl(req).pathname; - - if (!layer.match(path)) { - path = undefined; - } - } catch (err) { - error = err; - } - - done(error, path); -}; - /** * Process any parameters for the layer. * @@ -502,6 +509,15 @@ function appendMethods(list, addition) { } } +// get pathname of request +function getPathname(req) { + try { + return parseUrl(req).pathname; + } catch (err) { + return undefined; + } +} + // get type for error message function gettype(obj) { var type = typeof obj; @@ -515,6 +531,22 @@ function gettype(obj) { .replace(objectRegExp, '$1'); } +/** + * Match path to a layer. + * + * @param {Layer} layer + * @param {string} path + * @private + */ + +function matchLayer(layer, path) { + try { + return layer.match(path); + } catch (err) { + return err; + } +} + // merge params with parent params function mergeParams(params, parent) { if (typeof parent !== 'object' || !parent) { diff --git a/test/Router.js b/test/Router.js index 880d34b8d53..21cdff2c6c0 100644 --- a/test/Router.js +++ b/test/Router.js @@ -53,6 +53,21 @@ describe('Router', function(){ router.handle({ url: '', method: 'GET' }, {}, done); }); + it('should not stack overflow with many registered routes', function(done){ + var handler = function(req, res){ res.end(new Error('wrong handler')) }; + var router = new Router(); + + for (var i = 0; i < 6000; i++) { + router.get('/thing' + i, handler) + } + + router.get('/', function (req, res) { + res.end(); + }); + + router.handle({ url: '/', method: 'GET' }, { end: done }); + }); + describe('.handle', function(){ it('should dispatch', function(done){ var router = new Router(); From 4db51fbeba0cd543949e243672c0e6c3c3c70639 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 19:17:33 -0500 Subject: [PATCH 0714/1265] Deprecate req.param() closes #2440 --- History.md | 1 + lib/request.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2e5245c8e36..7136573f60b 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Deprecate leading `:` in `name` for `app.param(name, fn)` + * Deprecate `req.param()` -- use `req.params`, `req.body`, or `req.query` instead * Fix `OPTIONS` responses to include the `HEAD` method properly * Fix `res.sendFile` not always detecting aborted connection * Match routes iteratively to prevent stack overflows diff --git a/lib/request.js b/lib/request.js index 36ce1938683..5cd3900ee04 100644 --- a/lib/request.js +++ b/lib/request.js @@ -200,13 +200,20 @@ req.range = function(size){ * @api public */ -req.param = function(name, defaultValue){ +req.param = function param(name, defaultValue) { var params = this.params || {}; var body = this.body || {}; var query = this.query || {}; + + var args = arguments.length === 1 + ? 'name' + : 'name, default'; + deprecate('req.param(' + args + '): Use req.params, req.body, or req.query instead'); + if (null != params[name] && params.hasOwnProperty(name)) return params[name]; if (null != body[name]) return body[name]; if (null != query[name]) return query[name]; + return defaultValue; }; From 1616079a2d8fbfbcd29b1b4ac1208df7621432d7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 19:27:17 -0500 Subject: [PATCH 0715/1265] Improve deprecation message for router.param() --- lib/router/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/router/index.js b/lib/router/index.js index 7f66579ab03..51f2ad31056 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -95,7 +95,7 @@ proto.param = function(name, fn){ var ret; if (name[0] === ':') { - deprecate('name with leading colon: remove leading colon from ' + JSON.stringify(name)); + deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.substr(1)) + ', fn) instead'); name = name.substr(1); } From 591e89ed1890c3f519c9a732e164e64e758f6dbb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 19:28:06 -0500 Subject: [PATCH 0716/1265] Deprecate app.param(fn) closes #2429 --- History.md | 1 + lib/router/index.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 7136573f60b..5aa328a8199 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ unreleased * Deprecate leading `:` in `name` for `app.param(name, fn)` * Deprecate `req.param()` -- use `req.params`, `req.body`, or `req.query` instead + * Deprecate `app.param(fn)` * Fix `OPTIONS` responses to include the `HEAD` method properly * Fix `res.sendFile` not always detecting aborted connection * Match routes iteratively to prevent stack overflows diff --git a/lib/router/index.js b/lib/router/index.js index 51f2ad31056..209f881b1eb 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -82,9 +82,10 @@ var proto = module.exports = function(options) { * @api public */ -proto.param = function(name, fn){ +proto.param = function param(name, fn) { // param logic - if ('function' == typeof name) { + if (typeof name === 'function') { + deprecate('router.param(fn): Refactor to use path params'); this._params.push(name); return; } From f6f78e5f02afb874e916af27e30f56e82e23878c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 21:05:43 -0500 Subject: [PATCH 0717/1265] Add res.append(field, val) to append headers closes #2455 --- History.md | 1 + lib/response.js | 29 +++++++++++++ test/res.append.js | 104 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 test/res.append.js diff --git a/History.md b/History.md index 5aa328a8199..38d5f50b1a5 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Add `res.append(field, val)` to append headers * Deprecate leading `:` in `name` for `app.param(name, fn)` * Deprecate `req.param()` -- use `req.params`, `req.body`, or `req.query` instead * Deprecate `app.param(fn)` diff --git a/lib/response.js b/lib/response.js index 7d6575c192d..50c313eb461 100644 --- a/lib/response.js +++ b/lib/response.js @@ -636,6 +636,35 @@ res.attachment = function attachment(filename) { return this; }; +/** + * Append additional header `field` with value `val`. + * + * Example: + * + * res.append('Link', ['', '']); + * res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly'); + * res.append('Warning', '199 Miscellaneous warning'); + * + * @param {String} field + * @param {String|Array} val + * @return {ServerResponse} for chaining + * @api public + */ + +res.append = function append(field, val) { + var prev = this.get(field); + var value = val; + + if (prev) { + // concat the new and prev vals + value = Array.isArray(prev) ? prev.concat(val) + : Array.isArray(val) ? [prev].concat(val) + : [prev, val]; + } + + return this.set(field, value); +}; + /** * Set header `field` to `val`, or pass * an object of header fields. diff --git a/test/res.append.js b/test/res.append.js new file mode 100644 index 00000000000..f7f1d55b3cb --- /dev/null +++ b/test/res.append.js @@ -0,0 +1,104 @@ + +var express = require('..') +var request = require('supertest') +var should = require('should') + +describe('res', function () { + // note about these tests: "Link" and "X-*" are chosen because + // the common node.js versions white list which _incoming_ + // headers can appear multiple times; there is no such white list + // for outgoing, though + describe('.append(field, val)', function () { + it('should append multiple headers', function (done) { + var app = express() + + app.use(function (req, res, next) { + res.append('Link', '') + next() + }) + + app.use(function (req, res) { + res.append('Link', '') + res.end() + }) + + request(app) + .get('/') + .expect('Link', ', ', done) + }) + + it('should accept array of values', function (done) { + var app = express() + + app.use(function (req, res, next) { + res.append('Set-Cookie', ['foo=bar', 'fizz=buzz']) + res.end() + }) + + request(app) + .get('/') + .expect(function (res) { + should(res.headers['set-cookie']).eql(['foo=bar', 'fizz=buzz']) + }) + .expect(200, done) + }) + + it('should get reset by res.set(field, val)', function (done) { + var app = express() + + app.use(function (req, res, next) { + res.append('Link', '') + res.append('Link', '') + next() + }) + + app.use(function (req, res) { + res.set('Link', '') + res.end() + }); + + request(app) + .get('/') + .expect('Link', '', done) + }) + + it('should work with res.set(field, val) first', function (done) { + var app = express() + + app.use(function (req, res, next) { + res.set('Link', '') + next() + }) + + app.use(function(req, res){ + res.append('Link', '') + res.end() + }) + + request(app) + .get('/') + .expect('Link', ', ', done) + }) + + it('should work with cookies', function (done) { + var app = express() + + app.use(function (req, res, next) { + res.cookie('foo', 'bar') + next() + }) + + app.use(function (req, res) { + res.append('Set-Cookie', 'bar=baz') + res.end() + }) + + request(app) + .get('/') + .expect(function (res) { + should(res.headers['set-cookie']).eql(['foo=bar; Path=/', 'bar=baz']) + }) + .expect(200, done) + }) + }) +}) From 0b1cacff03d92189f897c6d41732d569d583fd56 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 22:16:00 -0500 Subject: [PATCH 0718/1265] deps: accepts@~1.2.2 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c16b4d60a75..62b89233b9e 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,9 @@ unreleased * Fix `OPTIONS` responses to include the `HEAD` method properly * Fix `res.sendFile` not always detecting aborted connection * Match routes iteratively to prevent stack overflows + * deps: accepts@~1.2.2 + - deps: mime-types@~2.0.7 + - deps: negotiator@0.5.0 * deps: send@0.11.0 - deps: debug@~2.1.1 - deps: etag@~1.5.1 diff --git a/package.json b/package.json index fb22dd7d927..c1edf63aaae 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.1.4", + "accepts": "~1.2.2", "content-disposition": "0.5.0", "cookie-signature": "1.0.5", "debug": "~2.1.1", From 7d983c94c76c7b07d83d9a1a7c60ac9f5a868cef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 22:18:02 -0500 Subject: [PATCH 0719/1265] deps: serve-static@~1.8.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 62b89233b9e..7963f07a811 100644 --- a/History.md +++ b/History.md @@ -16,6 +16,8 @@ unreleased - deps: etag@~1.5.1 - deps: ms@0.7.0 - deps: on-finished@~2.2.0 + * deps: serve-static@~1.8.0 + - deps: send@0.11.0 4.10.8 / 2015-01-13 =================== diff --git a/package.json b/package.json index c1edf63aaae..f305d31b495 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "qs": "2.3.3", "range-parser": "~1.0.2", "send": "0.11.0", - "serve-static": "~1.7.2", + "serve-static": "~1.8.0", "type-is": "~1.5.5", "vary": "~1.0.0", "cookie": "0.1.2", From 9434ad39e114ea810859cd9c6fef624d4acfbe18 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 22:19:33 -0500 Subject: [PATCH 0720/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f305d31b495..c8ae6f04aef 100644 --- a/package.json +++ b/package.json @@ -64,8 +64,8 @@ "body-parser": "~1.10.1", "connect-redis": "~2.1.0", "cookie-parser": "~1.3.3", - "express-session": "~1.9.2", - "jade": "~1.8.2", + "express-session": "~1.10.1", + "jade": "~1.9.0", "method-override": "~2.3.1", "morgan": "~1.5.1", "multiparty": "~4.1.0", From 40f7a8eaa297c26f74c1a5dbc13ab705b6f97b45 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 13 Jan 2015 22:51:55 -0500 Subject: [PATCH 0721/1265] 4.11.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 7963f07a811..b70d9b72425 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.11.0 / 2015-01-13 +=================== * Add `res.append(field, val)` to append headers * Deprecate leading `:` in `name` for `app.param(name, fn)` diff --git a/package.json b/package.json index c8ae6f04aef..2a26f21f1e1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.10.8", + "version": "4.11.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 548f2865e20efd4affa8138fb7aa55c32a85e210 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 02:03:28 -0500 Subject: [PATCH 0722/1265] deps: connect@2.28.2 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5a7edc26496..9d52592e337 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +3.x +=== + + * deps: connect@2.28.2 + - deps: body-parser@~1.10.2 + - deps: serve-static@~1.8.1 + 3.19.0 / 2015-01-09 =================== diff --git a/package.json b/package.json index 6e97a65db3f..d30906f327b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.28.1", + "connect": "2.28.2", "content-disposition": "0.5.0", "commander": "2.6.0", "cookie-signature": "1.0.5", From 0b25547ca071768160e7a81f3c2c9b8602a51201 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 02:05:03 -0500 Subject: [PATCH 0723/1265] deps: send@0.11.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9d52592e337..b1997021154 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ * deps: connect@2.28.2 - deps: body-parser@~1.10.2 - deps: serve-static@~1.8.1 + * deps: send@0.11.1 + - Fix root path disclosure 3.19.0 / 2015-01-09 =================== diff --git a/package.json b/package.json index d30906f327b..4d951f80f9d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.5", "range-parser": "~1.0.2", - "send": "0.11.0", + "send": "0.11.1", "utils-merge": "1.0.0", "vary": "~1.0.0", "cookie": "0.1.2", From ae92db98f3a8d4475d2ac5fb59d8b302da8cf087 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 02:13:17 -0500 Subject: [PATCH 0724/1265] deps: ejs@2.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d951f80f9d..b01a2106422 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "connect-redis": "~1.5.0", - "ejs": "2.0.8", + "ejs": "2.1.4", "istanbul": "0.3.5", "mocha": "~2.1.0", "should": "~4.4.4", From b95f2ee82067bdab2fa282556707fee4888b0620 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 02:14:27 -0500 Subject: [PATCH 0725/1265] deps: should@~4.6.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b01a2106422..bbbadf87440 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "ejs": "2.1.4", "istanbul": "0.3.5", "mocha": "~2.1.0", - "should": "~4.4.4", + "should": "~4.6.1", "supertest": "~0.15.0", "hjs": "~0.0.6", "marked": "0.3.2" From 855176b633a60a4032d5b35f69183b098ccf5609 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 03:17:30 -0500 Subject: [PATCH 0726/1265] tests: remove more mocking uses --- test/req.fresh.js | 2 +- test/req.stale.js | 2 +- test/res.format.js | 2 +- test/res.get.js | 20 ++++++--- test/res.links.js | 59 +++++++++++++------------ test/res.set.js | 54 ++++++++++++++++------- test/res.vary.js | 105 +++++++++++++++++++++++++++++++-------------- 7 files changed, 159 insertions(+), 85 deletions(-) diff --git a/test/req.fresh.js b/test/req.fresh.js index fdf4b07d591..0f1aa982ad2 100644 --- a/test/req.fresh.js +++ b/test/req.fresh.js @@ -37,7 +37,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - res._headers = undefined; + res._headers = null; res.send(req.fresh); }); diff --git a/test/req.stale.js b/test/req.stale.js index 70fee02c992..c92c5a9fb8d 100644 --- a/test/req.stale.js +++ b/test/req.stale.js @@ -37,7 +37,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - res._headers = undefined; + res._headers = null; res.send(req.stale); }); diff --git a/test/res.format.js b/test/res.format.js index 105c2b05aaa..b7b60afe741 100644 --- a/test/res.format.js +++ b/test/res.format.js @@ -81,7 +81,7 @@ describe('res', function(){ it('should be invoked instead of auto-responding', function(done){ request(app3) .get('/') - .set('Accept: text/html') + .set('Accept', 'text/html') .expect('default', done); }) }) diff --git a/test/res.get.js b/test/res.get.js index f6da5b50039..a53bdc33805 100644 --- a/test/res.get.js +++ b/test/res.get.js @@ -1,14 +1,20 @@ -var express = require('../') - , res = express.response; +var express = require('..'); +var request = require('supertest'); describe('res', function(){ describe('.get(field)', function(){ - it('should get the response header field', function(){ - res.setHeader('Content-Type', 'text/x-foo'); - res.get('Content-Type').should.equal('text/x-foo'); - res.get('Content-type').should.equal('text/x-foo'); - res.get('content-type').should.equal('text/x-foo'); + it('should get the response header field', function (done) { + var app = express(); + + app.use(function (req, res) { + res.setHeader('Content-Type', 'text/x-foo'); + res.send(res.get('Content-Type')); + }); + + request(app) + .get('/') + .expect(200, 'text/x-foo', done); }) }) }) diff --git a/test/res.links.js b/test/res.links.js index 34f3827e818..36630c9ccc5 100644 --- a/test/res.links.js +++ b/test/res.links.js @@ -1,41 +1,46 @@ -var express = require('../') - , res = express.response; +var express = require('..'); +var request = require('supertest'); describe('res', function(){ - - beforeEach(function() { - res.removeHeader('link'); - }); - describe('.links(obj)', function(){ - it('should set Link header field', function(){ - res.links({ - next: 'http://api.example.com/users?page=2', - last: 'http://api.example.com/users?page=5' + it('should set Link header field', function (done) { + var app = express(); + + app.use(function (req, res) { + res.links({ + next: 'http://api.example.com/users?page=2', + last: 'http://api.example.com/users?page=5' + }); + res.end(); }); - res.get('link') - .should.equal( - '; rel="next", ' - + '; rel="last"'); + request(app) + .get('/') + .expect('Link', '; rel="next", ; rel="last"') + .expect(200, done); }) - it('should set Link header field for multiple calls', function() { - res.links({ - next: 'http://api.example.com/users?page=2', - last: 'http://api.example.com/users?page=5' - }); + it('should set Link header field for multiple calls', function (done) { + var app = express(); + + app.use(function (req, res) { + res.links({ + next: 'http://api.example.com/users?page=2', + last: 'http://api.example.com/users?page=5' + }); + + res.links({ + prev: 'http://api.example.com/users?page=1' + }); - res.links({ - prev: 'http://api.example.com/users?page=1', + res.end(); }); - res.get('link') - .should.equal( - '; rel="next", ' - + '; rel="last", ' - + '; rel="prev"'); + request(app) + .get('/') + .expect('Link', '; rel="next", ; rel="last", ; rel="prev"') + .expect(200, done); }) }) }) diff --git a/test/res.set.js b/test/res.set.js index 1017e3aeaa1..a93ebbe20fc 100644 --- a/test/res.set.js +++ b/test/res.set.js @@ -1,7 +1,6 @@ -var express = require('../') - , request = require('supertest') - , res = express.response; +var express = require('..'); +var request = require('supertest'); describe('res', function(){ describe('.set(field, value)', function(){ @@ -18,10 +17,18 @@ describe('res', function(){ .end(done); }) - it('should coerce to a string', function(){ - res.headers = {}; - res.set('X-Number', 123); - res.get('X-Number').should.equal('123'); + it('should coerce to a string', function (done) { + var app = express(); + + app.use(function (req, res) { + res.set('X-Number', 123); + res.end(typeof res.get('X-Number')); + }); + + request(app) + .get('/') + .expect('X-Number', '123') + .expect(200, 'string', done); }) }) @@ -39,11 +46,18 @@ describe('res', function(){ .expect('["type=ninja","language=javascript"]', done); }) - it('should coerce to an array of strings', function(){ - res.headers = {}; - res.set('X-Numbers', [123, 456]); - JSON.stringify(res.get('X-Numbers')) - .should.equal('["123","456"]'); + it('should coerce to an array of strings', function (done) { + var app = express(); + + app.use(function (req, res) { + res.set('X-Numbers', [123, 456]); + res.end(JSON.stringify(res.get('X-Numbers'))); + }); + + request(app) + .get('/') + .expect('X-Numbers', '123, 456') + .expect(200, '["123","456"]', done); }) }) @@ -65,10 +79,18 @@ describe('res', function(){ .end(done); }) - it('should coerce to a string', function(){ - res.headers = {}; - res.set({ 'X-Number': 123 }); - res.get('X-Number').should.equal('123'); + it('should coerce to a string', function (done) { + var app = express(); + + app.use(function (req, res) { + res.set({ 'X-Number': 123 }); + res.end(typeof res.get('X-Number')); + }); + + request(app) + .get('/') + .expect('X-Number', '123') + .expect(200, 'string', done); }) }) }) diff --git a/test/res.vary.js b/test/res.vary.js index 4839c21dfdc..13c3af2bb70 100644 --- a/test/res.vary.js +++ b/test/res.vary.js @@ -1,55 +1,96 @@ -var express = require('../') - , should = require('should'); - -function response() { - var res = Object.create(express.response); - res._headers = {}; - return res; -} +var assert = require('assert'); +var express = require('..'); +var request = require('supertest'); describe('res.vary()', function(){ describe('with no arguments', function(){ - it('should not set Vary', function(){ - var res = response(); - res.vary(); - should.not.exist(res.get('Vary')); + it('should not set Vary', function (done) { + var app = express(); + + app.use(function (req, res) { + res.vary(); + res.end(); + }); + + request(app) + .get('/') + .expect(shouldNotHaveHeader('Vary')) + .expect(200, done); }) }) describe('with an empty array', function(){ - it('should not set Vary', function(){ - var res = response(); - res.vary([]); - should.not.exist(res.get('Vary')); + it('should not set Vary', function (done) { + var app = express(); + + app.use(function (req, res) { + res.vary([]); + res.end(); + }); + + request(app) + .get('/') + .expect(shouldNotHaveHeader('Vary')) + .expect(200, done); }) }) describe('with an array', function(){ - it('should set the values', function(){ - var res = response(); - res.vary(['Accept', 'Accept-Language', 'Accept-Encoding']); - res.get('Vary').should.equal('Accept, Accept-Language, Accept-Encoding'); + it('should set the values', function (done) { + var app = express(); + + app.use(function (req, res) { + res.vary(['Accept', 'Accept-Language', 'Accept-Encoding']); + res.end(); + }); + + request(app) + .get('/') + .expect('Vary', 'Accept, Accept-Language, Accept-Encoding') + .expect(200, done); }) }) describe('with a string', function(){ - it('should set the value', function(){ - var res = response(); - res.vary('Accept'); - res.get('Vary').should.equal('Accept'); + it('should set the value', function (done) { + var app = express(); + + app.use(function (req, res) { + res.vary('Accept'); + res.end(); + }); + + request(app) + .get('/') + .expect('Vary', 'Accept') + .expect(200, done); }) }) describe('when the value is present', function(){ - it('should not add it again', function(){ - var res = response(); - res.vary('Accept'); - res.vary('Accept-Encoding'); - res.vary('Accept-Encoding'); - res.vary('Accept-Encoding'); - res.vary('Accept'); - res.get('Vary').should.equal('Accept, Accept-Encoding'); + it('should not add it again', function (done) { + var app = express(); + + app.use(function (req, res) { + res.vary('Accept'); + res.vary('Accept-Encoding'); + res.vary('Accept-Encoding'); + res.vary('Accept-Encoding'); + res.vary('Accept'); + res.end(); + }); + + request(app) + .get('/') + .expect('Vary', 'Accept, Accept-Encoding') + .expect(200, done); }) }) }) + +function shouldNotHaveHeader(header) { + return function (res) { + assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header); + }; +} From 0c567b3282821c98a84640956e7fb4bf236be30e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 03:18:16 -0500 Subject: [PATCH 0727/1265] 3.19.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b1997021154..76c64f604b8 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.19.1 / 2015-01-20 +=================== * deps: connect@2.28.2 - deps: body-parser@~1.10.2 diff --git a/package.json b/package.json index bbbadf87440..55af8f0b10a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.19.0", + "version": "3.19.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From b275613d3ad2c1587db93b7d5def32e7222de7b4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 03:25:25 -0500 Subject: [PATCH 0728/1265] deps: serve-static@~1.8.1 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3c39c2f1f67..07ba59c0fc7 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,10 @@ unreleased * deps: send@0.11.1 - Fix root path disclosure + * deps: serve-static@~1.8.1 + - Fix redirect loop in Node.js 0.11.14 + - Fix root path disclosure + - deps: send@0.11.1 4.11.0 / 2015-01-13 =================== diff --git a/package.json b/package.json index 985993f5e9d..c7af68702b4 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "qs": "2.3.3", "range-parser": "~1.0.2", "send": "0.11.1", - "serve-static": "~1.8.0", + "serve-static": "~1.8.1", "type-is": "~1.5.5", "vary": "~1.0.0", "cookie": "0.1.2", From 41f8435d32237d672cc0f5040c21eeaa5d8ef56a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 03:28:57 -0500 Subject: [PATCH 0729/1265] tests: fix failing test on Node.js 0.11.15 --- test/app.router.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/app.router.js b/test/app.router.js index 4f170ec64ad..def50da34fb 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -11,7 +11,7 @@ describe('app.router', function(){ var router = new express.Router(); function handler1(req, res, next){ - res.setHeader('x-user-id', req.params.id); + res.setHeader('x-user-id', String(req.params.id)); next() } @@ -20,7 +20,7 @@ describe('app.router', function(){ } router.use(function(req, res, next){ - res.setHeader('x-router', req.params.id); + res.setHeader('x-router', String(req.params.id)); next(); }); From 96f47432a5383644328f27394fec1cdf57d864d1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 03:30:16 -0500 Subject: [PATCH 0730/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c7af68702b4..1ab7176269a 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,14 @@ "supertest": "~0.15.0", "marked": "0.3.2", "hjs": "~0.0.6", - "body-parser": "~1.10.1", + "body-parser": "~1.10.2", "connect-redis": "~2.1.0", "cookie-parser": "~1.3.3", "express-session": "~1.10.1", - "jade": "~1.9.0", + "jade": "~1.9.1", "method-override": "~2.3.1", "morgan": "~1.5.1", - "multiparty": "~4.1.0", + "multiparty": "~4.1.1", "vhost": "~3.0.0" }, "engines": { From 45ebb6cdf45710f4fba93ae41c9dbd16afae83fe Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 21 Jan 2015 03:31:11 -0500 Subject: [PATCH 0731/1265] 4.11.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 07ba59c0fc7..aca4495690c 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.11.1 / 2015-01-20 +=================== * deps: send@0.11.1 - Fix root path disclosure diff --git a/package.json b/package.json index 1ab7176269a..ad62cc56a7f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.11.0", + "version": "4.11.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 0b62f74a7f10df869b3ce8441534f2b7fd2126f4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 31 Jan 2015 17:26:35 -0500 Subject: [PATCH 0732/1265] deps: type-is@~1.5.6 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index aca4495690c..473dd8b83fd 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: type-is@~1.5.6 + - deps: mime-types@~2.0.8 + 4.11.1 / 2015-01-20 =================== diff --git a/package.json b/package.json index ad62cc56a7f..f0f7e2dd8d6 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "range-parser": "~1.0.2", "send": "0.11.1", "serve-static": "~1.8.1", - "type-is": "~1.5.5", + "type-is": "~1.5.6", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2", From 2ccb6cf3507cac74716f87c6ee056e79f6afdc52 Mon Sep 17 00:00:00 2001 From: Kevin Shay Date: Sat, 31 Jan 2015 16:23:18 -0500 Subject: [PATCH 0733/1265] Fix res.redirect double-calling res.end for HEAD requests fixes #2521 --- History.md | 1 + lib/response.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 473dd8b83fd..4ed719f2479 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix `res.redirect` double-calling `res.end` for `HEAD` requests * deps: type-is@~1.5.6 - deps: mime-types@~2.0.8 diff --git a/lib/response.js b/lib/response.js index 50c313eb461..14aa9cab221 100644 --- a/lib/response.js +++ b/lib/response.js @@ -870,9 +870,9 @@ res.redirect = function redirect(url) { if (this.req.method === 'HEAD') { this.end(); + } else { + this.end(body); } - - this.end(body); }; /** From fea768dbccc036d883b03e38daebc38e5206031c Mon Sep 17 00:00:00 2001 From: Ivan Fraixedes Date: Sun, 1 Feb 2015 00:53:53 +0000 Subject: [PATCH 0734/1265] Fix an incorrect @api jsdoc closes #2522 --- lib/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index 2fbb5503c7b..dc18fe37e38 100644 --- a/lib/application.js +++ b/lib/application.js @@ -563,7 +563,7 @@ app.listen = function(){ * Log error using console.error. * * @param {Error} err -* @api public +* @api private */ function logerror(err){ From fe435e497e9a0a40b4679c0896dd8a5e2ccbbf58 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 14:54:46 -0500 Subject: [PATCH 0735/1265] deps: connect@2.28.3 --- History.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 76c64f604b8..25e83a26dd2 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,14 @@ +3.x +=== + + * deps: connect@2.28.3 + - deps: compression@~1.3.1 + - deps: csurf@~1.6.6 + - deps: errorhandler@~1.3.3 + - deps: express-session@~1.10.2 + - deps: serve-index@~1.6.1 + - deps: type-is@~1.5.6 + 3.19.1 / 2015-01-20 =================== diff --git a/package.json b/package.json index 55af8f0b10a..dce62b226b6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.28.2", + "connect": "2.28.3", "content-disposition": "0.5.0", "commander": "2.6.0", "cookie-signature": "1.0.5", From 55f5a2dc8d6b7084805bbb9e8a666938df747fab Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 14:55:42 -0500 Subject: [PATCH 0736/1265] deps: proxy-addr@~1.0.6 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 25e83a26dd2..ffec3334def 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ - deps: express-session@~1.10.2 - deps: serve-index@~1.6.1 - deps: type-is@~1.5.6 + * deps: proxy-addr@~1.0.6 + - deps: ipaddr.js@0.1.8 3.19.1 / 2015-01-20 =================== diff --git a/package.json b/package.json index dce62b226b6..4862c2c87d2 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0", - "proxy-addr": "~1.0.5", + "proxy-addr": "~1.0.6", "range-parser": "~1.0.2", "send": "0.11.1", "utils-merge": "1.0.0", From 926a71f5acf55f1be879e2f0fd6fd6636f4d5482 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 14:56:18 -0500 Subject: [PATCH 0737/1265] deps: should@~4.6.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4862c2c87d2..e8c90795caa 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "ejs": "2.1.4", "istanbul": "0.3.5", "mocha": "~2.1.0", - "should": "~4.6.1", + "should": "~4.6.2", "supertest": "~0.15.0", "hjs": "~0.0.6", "marked": "0.3.2" From e497d068a1521e515eb1aa051d354a9ace7724ef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 14:58:19 -0500 Subject: [PATCH 0738/1265] deps: marked@0.3.3 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e8c90795caa..5821ae96997 100644 --- a/package.json +++ b/package.json @@ -52,11 +52,11 @@ "connect-redis": "~1.5.0", "ejs": "2.1.4", "istanbul": "0.3.5", + "marked": "0.3.3", "mocha": "~2.1.0", "should": "~4.6.2", "supertest": "~0.15.0", - "hjs": "~0.0.6", - "marked": "0.3.2" + "hjs": "~0.0.6" }, "engines": { "node": ">= 0.8.0" From 86328767fe6b253bdbf99343049cc57f1c3a1fbb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 15:15:53 -0500 Subject: [PATCH 0739/1265] 3.19.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index ffec3334def..d701954c50c 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.19.2 / 2015-02-01 +=================== * deps: connect@2.28.3 - deps: compression@~1.3.1 diff --git a/package.json b/package.json index 5821ae96997..e038310fc87 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.19.1", + "version": "3.19.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 72d35b6b4a06ed52d44a3058fe1d338f8917afc1 Mon Sep 17 00:00:00 2001 From: Vladimir Grinenko Date: Mon, 26 Jan 2015 03:55:23 +0300 Subject: [PATCH 0740/1265] Fix typo in jsdoc description closes #2514 --- lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 9814527c0fc..9c004cc764c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -272,7 +272,7 @@ exports.setCharset = function(type, charset){ }; /** - * Return new empty objet. + * Return new empty object. * * @return {Object} * @api private From f5d485235e9054dd4ada01ae129c3a1881344941 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 15:26:04 -0500 Subject: [PATCH 0741/1265] deps: accepts@~1.2.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2f1cbba4ca0..f3f232ce0c4 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * Fix `res.redirect` double-calling `res.end` for `HEAD` requests + * deps: accepts@~1.2.3 + - deps: mime-types@~2.0.8 * deps: proxy-addr@~1.0.6 - deps: ipaddr.js@0.1.8 * deps: type-is@~1.5.6 diff --git a/package.json b/package.json index 42675442ee4..b610b1d6574 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.2", + "accepts": "~1.2.3", "content-disposition": "0.5.0", "cookie-signature": "1.0.5", "debug": "~2.1.1", From 13c07237fe79bd3138b6324b16a6c1ec843e7082 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 15:27:48 -0500 Subject: [PATCH 0742/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b610b1d6574..1d5b640b8ae 100644 --- a/package.json +++ b/package.json @@ -61,10 +61,10 @@ "should": "~4.6.2", "supertest": "~0.15.0", "hjs": "~0.0.6", - "body-parser": "~1.10.2", - "connect-redis": "~2.1.0", + "body-parser": "~1.11.0", + "connect-redis": "~2.2.0", "cookie-parser": "~1.3.3", - "express-session": "~1.10.1", + "express-session": "~1.10.2", "jade": "~1.9.1", "method-override": "~2.3.1", "morgan": "~1.5.1", From 63ab25579bda70b4927a179b580a9c580b6c7ada Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Feb 2015 15:39:08 -0500 Subject: [PATCH 0743/1265] 4.11.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index f3f232ce0c4..6184768c9ae 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.11.2 / 2015-02-01 +=================== * Fix `res.redirect` double-calling `res.end` for `HEAD` requests * deps: accepts@~1.2.3 diff --git a/package.json b/package.json index 1d5b640b8ae..7179ee7b084 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.11.1", + "version": "4.11.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From ca480d7043827884a5fd49d6780c5ccd02aee64f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 4 Feb 2015 00:03:02 -0500 Subject: [PATCH 0744/1265] tests: improve res.download tests --- test/res.download.js | 54 +++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/test/res.download.js b/test/res.download.js index 0b9b0ba4edd..0671d8318c4 100644 --- a/test/res.download.js +++ b/test/res.download.js @@ -1,7 +1,8 @@ -var express = require('../') - , request = require('supertest') - , assert = require('assert'); +var after = require('after'); +var assert = require('assert'); +var express = require('..'); +var request = require('supertest'); describe('res', function(){ describe('.download(path)', function(){ @@ -38,27 +39,25 @@ describe('res', function(){ describe('.download(path, fn)', function(){ it('should invoke the callback', function(done){ - var app = express() - , calls = 0; + var app = express(); + var cb = after(2, done); app.use(function(req, res){ - res.download('test/fixtures/user.html', done); + res.download('test/fixtures/user.html', cb); }); request(app) .get('/') .expect('Content-Type', 'text/html; charset=UTF-8') .expect('Content-Disposition', 'attachment; filename="user.html"') - .expect(200, function(err){ - assert.ifError(err) - }) + .expect(200, cb); }) }) describe('.download(path, filename, fn)', function(){ it('should invoke the callback', function(done){ - var app = express() - , calls = 0; + var app = express(); + var cb = after(2, done); app.use(function(req, res){ res.download('test/fixtures/user.html', 'document', done); @@ -68,48 +67,47 @@ describe('res', function(){ .get('/') .expect('Content-Type', 'text/html; charset=UTF-8') .expect('Content-Disposition', 'attachment; filename="document"') - .expect(200, function(err){ - assert.ifError(err) - }) + .expect(200, cb); }) }) describe('on failure', function(){ it('should invoke the callback', function(done){ - var app = express() - , calls = 0; + var app = express(); - app.use(function(req, res){ + app.use(function (req, res, next) { res.download('test/fixtures/foobar.html', function(err){ - assert(404 == err.status); - assert('ENOENT' == err.code); - done(); + if (!err) return next(new Error('expected error')); + res.send('got ' + err.status + ' ' + err.code); }); }); request(app) .get('/') - .end(function(){}); + .expect(200, 'got 404 ENOENT', done); }) it('should remove Content-Disposition', function(done){ var app = express() , calls = 0; - app.use(function(req, res){ + app.use(function (req, res, next) { res.download('test/fixtures/foobar.html', function(err){ + if (!err) return next(new Error('expected error')); res.end('failed'); }); }); request(app) .get('/') - .expect('failed') - .end(function(err, res){ - if (err) return done(err); - res.header.should.not.have.property('content-disposition'); - done(); - }); + .expect(shouldNotHaveHeader('Content-Disposition')) + .expect(200, 'failed', done); }) }) }) + +function shouldNotHaveHeader(header) { + return function (res) { + assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header); + }; +} From 3610fdce3612eb27c8c8b8c4f683070d9d32d65d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:32:18 -0500 Subject: [PATCH 0745/1265] deps: connect@2.29.0 --- History.md | 19 +++++++++++++++++++ package.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d701954c50c..fb89295bc2f 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,22 @@ +3.x +=== + + * deps: connect@2.29.0 + - Use `content-type` to parse `Content-Type` headers + - deps: body-parser@~1.12.0 + - deps: compression@~1.4.1 + - deps: connect-timeout@~1.6.0 + - deps: cookie-parser@~1.3.4 + - deps: cookie-signature@1.0.6 + - deps: csurf@~1.7.0 + - deps: errorhandler@~1.3.4 + - deps: express-session@~1.10.3 + - deps: http-errors@~1.3.1 + - deps: response-time@~2.3.0 + - deps: serve-index@~1.6.2 + - deps: serve-static@~1.9.1 + - deps: type-is@~1.6.0 + 3.19.2 / 2015-02-01 =================== diff --git a/package.json b/package.json index e038310fc87..592d14f92bc 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.28.3", + "connect": "2.29.0", "content-disposition": "0.5.0", "commander": "2.6.0", "cookie-signature": "1.0.5", From 829fa34581be0f071433f84518df9d1ee33da82e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:37:28 -0500 Subject: [PATCH 0746/1265] build: use Travis CI container infrastructure --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1ff243c5e64..852ac641db4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,6 @@ matrix: allow_failures: - node_js: "0.11" fast_finish: true +sudo: false script: "npm run-script test-travis" after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls" From 2ce05047f83697a05043c7b73826cad2f48880cb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:40:51 -0500 Subject: [PATCH 0747/1265] deps: cookie-signature@1.0.6 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index fb89295bc2f..3bb53584236 100644 --- a/History.md +++ b/History.md @@ -16,6 +16,7 @@ - deps: serve-index@~1.6.2 - deps: serve-static@~1.9.1 - deps: type-is@~1.6.0 + * deps: cookie-signature@1.0.6 3.19.2 / 2015-02-01 =================== diff --git a/package.json b/package.json index 592d14f92bc..80f38245a18 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "connect": "2.29.0", "content-disposition": "0.5.0", "commander": "2.6.0", - "cookie-signature": "1.0.5", + "cookie-signature": "1.0.6", "debug": "~2.1.1", "depd": "~1.0.0", "escape-html": "1.0.1", From c2a6c8d3382e9b9ce771b467f0f21910fdd57fe1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:42:02 -0500 Subject: [PATCH 0748/1265] deps: send@0.12.1 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3bb53584236..349b925f4b4 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,10 @@ - deps: serve-static@~1.9.1 - deps: type-is@~1.6.0 * deps: cookie-signature@1.0.6 + * deps: send@0.12.1 + - Always read the stat size from the file + - Fix mutating passed-in `options` + - deps: mime@1.3.4 3.19.2 / 2015-02-01 =================== diff --git a/package.json b/package.json index 80f38245a18..22de15b397b 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.6", "range-parser": "~1.0.2", - "send": "0.11.1", + "send": "0.12.1", "utils-merge": "1.0.0", "vary": "~1.0.0", "cookie": "0.1.2", From 69a4869db03c1924cfaeff13147272543e9b2c5f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:43:38 -0500 Subject: [PATCH 0749/1265] deps: should@~5.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 22de15b397b..1e2a7ca5804 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "istanbul": "0.3.5", "marked": "0.3.3", "mocha": "~2.1.0", - "should": "~4.6.2", + "should": "~5.0.0", "supertest": "~0.15.0", "hjs": "~0.0.6" }, From f22937f3d158e5fcb194ec201b1a72ff2d84776d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:49:24 -0500 Subject: [PATCH 0750/1265] Use content-type to parse Content-Type headers --- History.md | 1 + lib/utils.js | 19 ++++++++++++++----- package.json | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index 349b925f4b4..83b8a5561c9 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Use `content-type` to parse `Content-Type` headers * deps: connect@2.29.0 - Use `content-type` to parse `Content-Type` headers - deps: body-parser@~1.12.0 diff --git a/lib/utils.js b/lib/utils.js index b9ff7bbdf68..889b62d5310 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,12 +1,19 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ /** * Module dependencies. + * @api private */ +var contentType = require('content-type'); var etag = require('etag'); var mime = require('connect').mime; var proxyaddr = require('proxy-addr'); -var typer = require('media-typer'); /** * toString ref. @@ -393,15 +400,17 @@ exports.compileTrust = function(val) { * @api private */ -exports.setCharset = function(type, charset){ - if (!type || !charset) return type; +exports.setCharset = function setCharset(type, charset) { + if (!type || !charset) { + return type; + } // parse type - var parsed = typer.parse(type); + var parsed = contentType.parse(type); // set charset parsed.parameters.charset = charset; // format type - return typer.format(parsed); + return contentType.format(parsed); }; diff --git a/package.json b/package.json index 1e2a7ca5804..e2dca4d9945 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "basic-auth": "1.0.0", "connect": "2.29.0", "content-disposition": "0.5.0", + "content-type": "~1.0.1", "commander": "2.6.0", "cookie-signature": "1.0.6", "debug": "~2.1.1", @@ -36,7 +37,6 @@ "escape-html": "1.0.1", "etag": "~1.5.1", "fresh": "0.2.4", - "media-typer": "0.3.0", "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0", From e1057bd7fd485f3ae7f6529ded0353ec78d3bd7d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:52:23 -0500 Subject: [PATCH 0751/1265] build: support Node.js 0.12 closes #2538 --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 852ac641db4..4af6d31b546 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,7 @@ language: node_js node_js: - "0.8" - "0.10" - - "0.11" -matrix: - allow_failures: - - node_js: "0.11" - fast_finish: true + - "0.12" sudo: false script: "npm run-script test-travis" after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls" From eaf3318dd39a83ecfa014cbb073883c63f4ef608 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 00:12:28 -0500 Subject: [PATCH 0752/1265] Generate ETags for all request responses closes #2546 --- History.md | 2 + LICENSE | 2 + lib/response.js | 30 +++++--- test/res.send.js | 191 +++++++++++++++++++++++++---------------------- 4 files changed, 125 insertions(+), 100 deletions(-) diff --git a/History.md b/History.md index 83b8a5561c9..00210c617e4 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ 3.x === + * Generate `ETag`s for all request responses + - No longer restricted to only responses for `GET` and `HEAD` requests * Use `content-type` to parse `Content-Type` headers * deps: connect@2.29.0 - Use `content-type` to parse `Content-Type` headers diff --git a/LICENSE b/LICENSE index d23e93ce9a5..bf9058b447a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,8 @@ (The MIT License) Copyright (c) 2009-2013 TJ Holowaychuk +Copyright (c) 2013 Roman Shtylman +Copyright (c) 2014-2015 Douglas Christopher Wilson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/lib/response.js b/lib/response.js index 9404d34f606..08c68f79e2e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -1,5 +1,13 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. + * @api private */ var contentDisposition = require('content-disposition'); @@ -86,7 +94,6 @@ res.links = function(links){ res.send = function(body){ var req = this.req; - var head = 'HEAD' == req.method; var type; var encoding; var len; @@ -153,12 +160,12 @@ res.send = function(body){ this.set('Content-Length', len); } - // ETag support - var etag = len !== undefined && app.get('etag fn'); - if (etag && ('GET' === req.method || 'HEAD' === req.method)) { - if (!this.get('ETag')) { - etag = etag(body, encoding); - etag && this.set('ETag', etag); + // populate ETag + var etag; + var generateETag = len !== undefined && app.get('etag fn'); + if (typeof generateETag === 'function' && !this.get('ETag')) { + if ((etag = generateETag(body, encoding))) { + this.set('ETag', etag); } } @@ -173,8 +180,13 @@ res.send = function(body){ body = ''; } - // respond - this.end((head ? null : body), encoding); + if (req.method === 'HEAD') { + // skip body for HEAD + this.end(); + } else { + // respond + this.end(body, encoding); + } return this; }; diff --git a/test/res.send.js b/test/res.send.js index ad1a703f32b..9ad8fd88fee 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -1,7 +1,8 @@ -var express = require('../') - , request = require('supertest') - , assert = require('assert'); +var assert = require('assert'); +var express = require('..'); +var methods = require('methods'); +var request = require('supertest'); describe('res', function(){ describe('.send(null)', function(){ @@ -110,10 +111,10 @@ describe('res', function(){ }) }) - it('should set ETag', function(done){ + it('should set ETag', function (done) { var app = express(); - app.use(function(req, res){ + app.use(function (req, res) { var str = Array(1024 * 2).join('-'); res.send(str); }); @@ -121,24 +122,7 @@ describe('res', function(){ request(app) .get('/') .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') - .end(done); - }) - - it('should not set ETag for non-GET/HEAD', function(done){ - var app = express(); - - app.use(function(req, res){ - var str = Array(1024 * 2).join('-'); - res.send(str); - }); - - request(app) - .post('/') - .end(function(err, res){ - if (err) return done(err); - assert(!res.header.etag, 'has an ETag'); - done(); - }); + .expect(200, done); }) it('should not override Content-Type', function(done){ @@ -199,10 +183,10 @@ describe('res', function(){ }) }) - it('should set ETag', function(done){ + it('should set ETag', function (done) { var app = express(); - app.use(function(req, res){ + app.use(function (req, res) { var str = Array(1024 * 2).join('-'); res.send(new Buffer(str)); }); @@ -210,7 +194,7 @@ describe('res', function(){ request(app) .get('/') .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') - .end(done); + .expect(200, done); }) it('should not override Content-Type', function(done){ @@ -358,12 +342,12 @@ describe('res', function(){ .expect('{"foo":"bar"}', done); }) - describe('"etag" setting', function(){ - describe('when enabled', function(){ - it('should send ETag', function(done){ + describe('"etag" setting', function () { + describe('when enabled', function () { + it('should send ETag', function (done) { var app = express(); - app.use(function(req, res){ + app.use(function (req, res) { res.send('kajdslfkasdf'); }); @@ -371,27 +355,46 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"c-5aee35d8"', done) - }) + .expect('ETag', 'W/"c-5aee35d8"') + .expect(200, done); + }); + + methods.forEach(function (method) { + if (method === 'connect') return; - it('should send ETag for empty string response', function(done){ - var app = express() + it('should send ETag in response to ' + method.toUpperCase() + ' request', function (done) { + var app = express(); - app.use(function(req, res){ - res.send('') + app[method]('/', function (req, res) { + res.send('kajdslfkasdf'); + }); + + request(app) + [method]('/') + .expect('ETag', 'W/"c-5aee35d8"') + .expect(200, done); + }) + }); + + it('should send ETag for empty string response', function (done) { + var app = express(); + + app.use(function (req, res) { + res.send(''); }); - app.enable('etag') + app.enable('etag'); request(app) .get('/') - .expect('etag', 'W/"0-0"', done) + .expect('ETag', 'W/"0-0"') + .expect(200, done); }) - it('should send ETag for long response', function(done){ + it('should send ETag for long response', function (done) { var app = express(); - app.use(function(req, res){ + app.use(function (req, res) { var str = Array(1024 * 2).join('-'); res.send(str); }); @@ -400,13 +403,14 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="', done) + .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') + .expect(200, done); }); - it('should not override ETag when manually set', function(done){ + it('should not override ETag when manually set', function (done) { var app = express(); - app.use(function(req, res){ + app.use(function (req, res) { res.set('etag', '"asdf"'); res.send(200); }); @@ -415,32 +419,31 @@ describe('res', function(){ request(app) .get('/') - .expect('etag', '"asdf"', done) + .expect('ETag', '"asdf"') + .expect(200, done); }); - it('should not send ETag for res.send()', function(done){ - var app = express() + it('should not send ETag for res.send()', function (done) { + var app = express(); - app.use(function(req, res){ - res.send() + app.use(function (req, res) { + res.send(); }); - app.enable('etag') + app.enable('etag'); request(app) .get('/') - .end(function(err, res){ - res.headers.should.not.have.property('etag'); - done(); - }) + .expect(shouldNotHaveHeader('ETag')) + .expect(200, done); }) }); - describe('when disabled', function(){ - it('should send no ETag', function(done){ + describe('when disabled', function () { + it('should send no ETag', function (done) { var app = express(); - app.use(function(req, res){ + app.use(function (req, res) { var str = Array(1024 * 2).join('-'); res.send(str); }); @@ -449,97 +452,103 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.not.have.property('etag'); - done(); - }); + .expect(shouldNotHaveHeader('ETag')) + .expect(200, done); }); - it('should send ETag when manually set', function(done){ + it('should send ETag when manually set', function (done) { var app = express(); app.disable('etag'); - app.use(function(req, res){ + app.use(function (req, res) { res.set('etag', '"asdf"'); res.send(200); }); request(app) .get('/') - .expect('etag', '"asdf"', done) + .expect('ETag', '"asdf"') + .expect(200, done); }); }); - describe('when "strong"', function(){ - it('should send strong ETag', function(done){ - var app = express() + describe('when "strong"', function () { + it('should send strong ETag', function (done) { + var app = express(); app.set('etag', 'strong'); - app.use(function(req, res){ + app.use(function (req, res) { res.send('hello, world!'); }); request(app) .get('/') - .expect('etag', '"Otu60XkfuuPskIiUxJY4cA=="', done) + .expect('ETag', '"Otu60XkfuuPskIiUxJY4cA=="') + .expect(200, done); }) }) - describe('when "weak"', function(){ - it('should send weak ETag', function(done){ - var app = express() + describe('when "weak"', function () { + it('should send weak ETag', function (done) { + var app = express(); app.set('etag', 'weak'); - app.use(function(req, res){ + app.use(function (req, res) { res.send('hello, world!'); }); request(app) .get('/') - .expect('etag', 'W/"d-58988d13"', done) + .expect('ETag', 'W/"d-58988d13"') + .expect(200, done) }) }) - describe('when a function', function(){ - it('should send custom ETag', function(done){ - var app = express() + describe('when a function', function () { + it('should send custom ETag', function (done) { + var app = express(); - app.set('etag', function(body, encoding){ - body.should.equal('hello, world!') - encoding.should.equal('utf8') - return '"custom"' + app.set('etag', function (body, encoding) { + body.should.equal('hello, world!'); + encoding.should.equal('utf8'); + return '"custom"'; }); - app.use(function(req, res){ + app.use(function (req, res) { res.send('hello, world!'); }); request(app) .get('/') - .expect('etag', '"custom"', done) + .expect('ETag', '"custom"') + .expect(200, done); }) - it('should not send falsy ETag', function(done){ - var app = express() + it('should not send falsy ETag', function (done) { + var app = express(); - app.set('etag', function(body, encoding){ - return undefined + app.set('etag', function (body, encoding) { + return undefined; }); - app.use(function(req, res){ + app.use(function (req, res) { res.send('hello, world!'); }); request(app) .get('/') - .end(function(err, res){ - res.headers.should.not.have.property('etag') - done(); - }) + .expect(shouldNotHaveHeader('ETag')) + .expect(200, done); }) }) }) }) + +function shouldNotHaveHeader(header) { + return function (res) { + assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header) + } +} From b40e74d6b6a3c32b9ce1b28ce533e5e322eb502d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 00:59:56 -0500 Subject: [PATCH 0753/1265] Fix "trust proxy" setting to inherit when app is mounted fixes #2550 fixes #2551 --- History.md | 1 + lib/application.js | 40 +++++++++++++++++- test/app.use.js | 5 ++- test/config.js | 103 ++++++++++++++++++++++++++++++++------------- test/req.ip.js | 17 ++++++++ 5 files changed, 133 insertions(+), 33 deletions(-) diff --git a/History.md b/History.md index 00210c617e4..ad53053ae7d 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Fix `"trust proxy"` setting to inherit when app is mounted * Generate `ETag`s for all request responses - No longer restricted to only responses for `GET` and `HEAD` requests * Use `content-type` to parse `Content-Type` headers diff --git a/lib/application.js b/lib/application.js index 1909fd95754..8b287ae5e0f 100644 --- a/lib/application.js +++ b/lib/application.js @@ -1,5 +1,14 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. + * @api private */ var connect = require('connect') @@ -21,6 +30,13 @@ var merge = require('utils-merge'); var app = exports = module.exports = {}; +/** + * Variable for trust proxy inheritance back-compat + * @api private + */ + +var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default'; + /** * Initialize the server. * @@ -53,14 +69,27 @@ app.defaultConfiguration = function(){ this.set('subdomain offset', 2); this.set('trust proxy', false); + // trust proxy inherit back-compat + Object.defineProperty(this.settings, trustProxyDefaultSymbol, { + configurable: true, + value: true + }); + debug('booting in %s mode', env); // implicit middleware this.use(connect.query()); this.use(middleware.init(this)); - // inherit protos - this.on('mount', function(parent){ + this.on('mount', function onmount(parent) { + // inherit trust proxy + if (this.settings[trustProxyDefaultSymbol] === true + && typeof parent.settings['trust proxy fn'] === 'function') { + delete this.settings['trust proxy']; + delete this.settings['trust proxy fn']; + } + + // inherit protos this.request.__proto__ = parent.request; this.response.__proto__ = parent.response; this.engines.__proto__ = parent.engines; @@ -271,6 +300,13 @@ app.set = function(setting, val){ case 'trust proxy': debug('compile trust proxy %s', val); this.set('trust proxy fn', compileTrust(val)); + + // trust proxy inherit back-compat + Object.defineProperty(this.settings, trustProxyDefaultSymbol, { + configurable: true, + value: false + }); + break; } diff --git a/test/app.use.js b/test/app.use.js index d627bdfe658..ab00617e697 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -1,6 +1,7 @@ -var express = require('../') - , request = require('supertest'); +var assert = require('assert'); +var express = require('..'); +var request = require('supertest'); describe('app', function(){ it('should emit "mount" when mounted', function(done){ diff --git a/test/config.js b/test/config.js index 59d38f07a32..e298e76a5c5 100644 --- a/test/config.js +++ b/test/config.js @@ -1,30 +1,36 @@ -var express = require('../') - , assert = require('assert'); +var assert = require('assert'); +var express = require('..'); -describe('config', function(){ - describe('.set()', function(){ - it('should set a value', function(){ +describe('config', function () { + describe('.set()', function () { + it('should set a value', function () { var app = express(); - app.set('foo', 'bar').should.equal(app); + app.set('foo', 'bar'); + assert.equal(app.get('foo'), 'bar'); + }) + + it('should return the app', function () { + var app = express(); + assert.equal(app.set('foo', 'bar'), app); }) - it('should return the app when undefined', function(){ + it('should return the app when undefined', function () { var app = express(); - app.set('foo', undefined).should.equal(app); + assert.equal(app.set('foo', undefined), app); }) describe('"etag"', function(){ it('should throw on bad value', function(){ - var app = express() - app.set.bind(app, 'etag', 42).should.throw(/unknown value/) + var app = express(); + assert.throws(app.set.bind(app, 'etag', 42), /unknown value/); }) it('should set "etag fn"', function(){ var app = express() var fn = function(){} app.set('etag', fn) - app.get('etag fn').should.equal(fn) + assert.equal(app.get('etag fn'), fn) }) }) @@ -33,7 +39,7 @@ describe('config', function(){ var app = express() var fn = function(){} app.set('trust proxy', fn) - app.get('trust proxy fn').should.equal(fn) + assert.equal(app.get('trust proxy fn'), fn) }) }) }) @@ -41,34 +47,73 @@ describe('config', function(){ describe('.get()', function(){ it('should return undefined when unset', function(){ var app = express(); - assert(undefined === app.get('foo')); + assert.strictEqual(app.get('foo'), undefined); }) it('should otherwise return the value', function(){ var app = express(); app.set('foo', 'bar'); - app.get('foo').should.equal('bar'); + assert.equal(app.get('foo'), 'bar'); }) describe('when mounted', function(){ it('should default to the parent app', function(){ - var app = express() - , blog = express(); + var app = express(); + var blog = express(); app.set('title', 'Express'); app.use(blog); - blog.get('title').should.equal('Express'); + assert.equal(blog.get('title'), 'Express'); }) - + it('should given precedence to the child', function(){ - var app = express() - , blog = express(); + var app = express(); + var blog = express(); app.use(blog); app.set('title', 'Express'); blog.set('title', 'Some Blog'); - blog.get('title').should.equal('Some Blog'); + assert.equal(blog.get('title'), 'Some Blog'); + }) + + it('should inherit "trust proxy" setting', function () { + var app = express(); + var blog = express(); + + function fn() { return false } + + app.set('trust proxy', fn); + assert.equal(app.get('trust proxy'), fn); + assert.equal(app.get('trust proxy fn'), fn); + + app.use(blog); + + assert.equal(blog.get('trust proxy'), fn); + assert.equal(blog.get('trust proxy fn'), fn); + }) + + it('should prefer child "trust proxy" setting', function () { + var app = express(); + var blog = express(); + + function fn1() { return false } + function fn2() { return true } + + app.set('trust proxy', fn1); + assert.equal(app.get('trust proxy'), fn1); + assert.equal(app.get('trust proxy fn'), fn1); + + blog.set('trust proxy', fn2); + assert.equal(blog.get('trust proxy'), fn2); + assert.equal(blog.get('trust proxy fn'), fn2); + + app.use(blog); + + assert.equal(app.get('trust proxy'), fn1); + assert.equal(app.get('trust proxy fn'), fn1); + assert.equal(blog.get('trust proxy'), fn2); + assert.equal(blog.get('trust proxy fn'), fn2); }) }) }) @@ -76,42 +121,42 @@ describe('config', function(){ describe('.enable()', function(){ it('should set the value to true', function(){ var app = express(); - app.enable('tobi').should.equal(app); - app.get('tobi').should.be.true; + assert.equal(app.enable('tobi'), app); + assert.strictEqual(app.get('tobi'), true); }) }) describe('.disable()', function(){ it('should set the value to false', function(){ var app = express(); - app.disable('tobi').should.equal(app); - app.get('tobi').should.be.false; + assert.equal(app.disable('tobi'), app); + assert.strictEqual(app.get('tobi'), false); }) }) describe('.enabled()', function(){ it('should default to false', function(){ var app = express(); - app.enabled('foo').should.be.false; + assert.strictEqual(app.enabled('foo'), false); }) it('should return true when set', function(){ var app = express(); app.set('foo', 'bar'); - app.enabled('foo').should.be.true; + assert.strictEqual(app.enabled('foo'), true); }) }) describe('.disabled()', function(){ it('should default to true', function(){ var app = express(); - app.disabled('foo').should.be.true; + assert.strictEqual(app.disabled('foo'), true); }) it('should return false when set', function(){ var app = express(); app.set('foo', 'bar'); - app.disabled('foo').should.be.false; + assert.strictEqual(app.disabled('foo'), false); }) }) }) diff --git a/test/req.ip.js b/test/req.ip.js index 19d0fee147e..3ca575e11bd 100644 --- a/test/req.ip.js +++ b/test/req.ip.js @@ -35,6 +35,23 @@ describe('req', function(){ .set('X-Forwarded-For', 'client, p1, p2') .expect('p1', done); }) + + it('should return the addr after trusted proxy, from sub app', function (done) { + var app = express(); + var sub = express(); + + app.set('trust proxy', 2); + app.use(sub); + + sub.use(function (req, res, next) { + res.send(req.ip); + }); + + request(app) + .get('/') + .set('X-Forwarded-For', 'client, p1, p2') + .expect(200, 'p1', done); + }) }) describe('when "trust proxy" is disabled', function(){ From 85755e32d9d262db702bee84830462b5275c27e4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 21:25:55 -0500 Subject: [PATCH 0754/1265] 3.20.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index ad53053ae7d..3a215127e23 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.20.0 / 2015-02-18 +=================== * Fix `"trust proxy"` setting to inherit when app is mounted * Generate `ETag`s for all request responses diff --git a/package.json b/package.json index e2dca4d9945..bc2042905d0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.19.2", + "version": "3.20.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 117d0c9796a0a80d09b5eff6542224ea4ac9cbc4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 22:36:20 -0500 Subject: [PATCH 0755/1265] deps: accepts@~1.2.4 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 88cf92df6b0..2979b297a8d 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,10 @@ unreleased * Generate `ETag`s for all request responses - No longer restricted to only responses for `GET` and `HEAD` requests * Use `content-type` to parse `Content-Type` headers + * deps: accepts@~1.2.4 + - Fix preference sorting to be stable for long acceptable lists + - deps: mime-types@~2.0.9 + - deps: negotiator@0.5.1 * deps: cookie-signature@1.0.6 * deps: send@0.12.1 - Always read the stat size from the file diff --git a/package.json b/package.json index 6ced2f3caf8..9e9bf1dd0b0 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.3", + "accepts": "~1.2.4", "content-disposition": "0.5.0", "content-type": "~1.0.1", "cookie-signature": "1.0.6", From e03ed050ef9e8318af45241474d933f5088e2815 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 22:46:34 -0500 Subject: [PATCH 0756/1265] deps: type-is@~1.6.0 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2979b297a8d..54a2f972da4 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,11 @@ unreleased - Always read the stat size from the file - Fix mutating passed-in `options` - deps: mime@1.3.4 + * deps: type-is@~1.6.0 + - fix argument reassignment + - fix false-positives in `hasBody` `Transfer-Encoding` check + - support wildcard for both type and subtype (`*/*`) + - deps: mime-types@~2.0.9 4.11.2 / 2015-02-01 =================== diff --git a/package.json b/package.json index 9e9bf1dd0b0..0d394b5761f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "range-parser": "~1.0.2", "send": "0.12.1", "serve-static": "~1.8.1", - "type-is": "~1.5.6", + "type-is": "~1.6.0", "vary": "~1.0.0", "cookie": "0.1.2", "merge-descriptors": "0.0.2", From ce1abd9f26e262c6232d41e60e33736ccfddc6f5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 22:48:25 -0500 Subject: [PATCH 0757/1265] deps: serve-static@~1.9.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 54a2f972da4..174851d5dc0 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,8 @@ unreleased - Always read the stat size from the file - Fix mutating passed-in `options` - deps: mime@1.3.4 + * deps: serve-static@~1.9.1 + - deps: send@0.12.1 * deps: type-is@~1.6.0 - fix argument reassignment - fix false-positives in `hasBody` `Transfer-Encoding` check diff --git a/package.json b/package.json index 0d394b5761f..25bcc906a16 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "qs": "2.3.3", "range-parser": "~1.0.2", "send": "0.12.1", - "serve-static": "~1.8.1", + "serve-static": "~1.9.1", "type-is": "~1.6.0", "vary": "~1.0.0", "cookie": "0.1.2", From e56141a7a5a4f3422b6a121682168515078ca8cc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 22:49:12 -0500 Subject: [PATCH 0758/1265] deps: jade@~1.9.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25bcc906a16..9aa051d23ec 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "connect-redis": "~2.2.0", "cookie-parser": "~1.3.3", "express-session": "~1.10.2", - "jade": "~1.9.1", + "jade": "~1.9.2", "method-override": "~2.3.1", "morgan": "~1.5.1", "multiparty": "~4.1.1", From 9a8cf77c91f6a3597910e0826c8ada4ae8b88ae1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 22:51:18 -0500 Subject: [PATCH 0759/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9aa051d23ec..92441cfe303 100644 --- a/package.json +++ b/package.json @@ -61,10 +61,10 @@ "should": "~5.0.0", "supertest": "~0.15.0", "hjs": "~0.0.6", - "body-parser": "~1.11.0", + "body-parser": "~1.12.0", "connect-redis": "~2.2.0", - "cookie-parser": "~1.3.3", - "express-session": "~1.10.2", + "cookie-parser": "~1.3.4", + "express-session": "~1.10.3", "jade": "~1.9.2", "method-override": "~2.3.1", "morgan": "~1.5.1", From 53e5991dd1a70d5c57bfd45f1023101ecbac3e65 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 22:57:50 -0500 Subject: [PATCH 0760/1265] tests: add extra setCharset tests --- test/utils.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/utils.js b/test/utils.js index 399b3f5bcdb..ef5a0706eb5 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,6 +1,6 @@ -var utils = require('../lib/utils') - , assert = require('assert'); +var assert = require('assert'); +var utils = require('../lib/utils'); describe('utils.etag(body, encoding)', function(){ it('should support strings', function(){ @@ -25,6 +25,28 @@ describe('utils.etag(body, encoding)', function(){ }) }) +describe('utils.setCharset(type, charset)', function () { + it('should do anything without type', function () { + assert.strictEqual(utils.setCharset(), undefined); + }); + + it('should return type if not given charset', function () { + assert.strictEqual(utils.setCharset('text/html'), 'text/html'); + }); + + it('should keep charset if not given charset', function () { + assert.strictEqual(utils.setCharset('text/html; charset=utf-8'), 'text/html; charset=utf-8'); + }); + + it('should set charset', function () { + assert.strictEqual(utils.setCharset('text/html', 'utf-8'), 'text/html; charset=utf-8'); + }); + + it('should override charset', function () { + assert.strictEqual(utils.setCharset('text/html; charset=iso-8859-1', 'utf-8'), 'text/html; charset=utf-8'); + }); +}); + describe('utils.wetag(body, encoding)', function(){ it('should support strings', function(){ utils.wetag('express!') From 9adfc2d586b18c485c94bf89943d579dd58fd1ba Mon Sep 17 00:00:00 2001 From: Elvin Yung Date: Tue, 3 Feb 2015 08:31:25 -0500 Subject: [PATCH 0761/1265] Fix typos in req.accepts jsdoc closes #2527 --- lib/request.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/request.js b/lib/request.js index 5cd3900ee04..9058ca83288 100644 --- a/lib/request.js +++ b/lib/request.js @@ -63,12 +63,12 @@ req.header = function(name){ * the best match when true, otherwise `undefined`, in which * case you should respond with 406 "Not Acceptable". * - * The `type` value may be a single mime type string - * such as "application/json", the extension name - * such as "json", a comma-delimted list such as "json, html, text/plain", + * The `type` value may be a single MIME type string + * such as "application/json", an extension name + * such as "json", a comma-delimited list such as "json, html, text/plain", * an argument list such as `"json", "html", "text/plain"`, * or an array `["json", "html", "text/plain"]`. When a list - * or array is given the _best_ match, if any is returned. + * or array is given, the _best_ match, if any is returned. * * Examples: * From 24fce9deb374e7259f518e0bd69da8dffb6e282d Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Mon, 9 Feb 2015 02:27:55 +0300 Subject: [PATCH 0762/1265] examples: fixes to mvc example closes #2534 --- examples/mvc/controllers/pet/views/edit.ejs | 2 +- examples/mvc/lib/boot.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mvc/controllers/pet/views/edit.ejs b/examples/mvc/controllers/pet/views/edit.ejs index 91c52fec59f..fc697c25500 100644 --- a/examples/mvc/controllers/pet/views/edit.ejs +++ b/examples/mvc/controllers/pet/views/edit.ejs @@ -8,7 +8,7 @@

<%= pet.name %>

- +
diff --git a/examples/mvc/lib/boot.js b/examples/mvc/lib/boot.js index 82ac8a5186e..78e82db1bfb 100644 --- a/examples/mvc/lib/boot.js +++ b/examples/mvc/lib/boot.js @@ -66,7 +66,7 @@ module.exports = function(parent, options){ app[method](path, obj.before, handler); verbose && console.log(' %s %s -> before -> %s', method.toUpperCase(), path, key); } else { - app[method](path, obj[key]); + app[method](path, handler); verbose && console.log(' %s %s -> %s', method.toUpperCase(), path, key); } } From 3882ba4ba5adbc83ab0657945fa43edb132b74e8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 23:09:47 -0500 Subject: [PATCH 0763/1265] docs: update badges --- Readme.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 748e1ee81f3..479371e465e 100644 --- a/Readme.md +++ b/Readme.md @@ -121,15 +121,15 @@ The current lead maintainer is [Douglas Christopher Wilson](https://github.com/d [MIT](LICENSE) -[npm-image]: https://img.shields.io/npm/v/express.svg?style=flat +[npm-image]: https://img.shields.io/npm/v/express.svg [npm-url]: https://npmjs.org/package/express -[downloads-image]: https://img.shields.io/npm/dm/express.svg?style=flat +[downloads-image]: https://img.shields.io/npm/dm/express.svg [downloads-url]: https://npmjs.org/package/express -[travis-image]: https://img.shields.io/travis/strongloop/express.svg?style=flat +[travis-image]: https://img.shields.io/travis/strongloop/express/master.svg [travis-url]: https://travis-ci.org/strongloop/express -[coveralls-image]: https://img.shields.io/coveralls/strongloop/express.svg?style=flat +[coveralls-image]: https://img.shields.io/coveralls/strongloop/express/master.svg [coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master -[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg?style=flat +[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg [gratipay-url-visionmedia]: https://gratipay.com/visionmedia/ -[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg?style=flat +[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url-dougwilson]: https://gratipay.com/dougwilson/ From 028abf5d70bb610b9858937162e87e0f7674d049 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 18 Feb 2015 23:11:45 -0500 Subject: [PATCH 0764/1265] build: add AppVeyor --- .travis.yml | 2 +- Readme.md | 7 +++++-- appveyor.yml | 13 +++++++++++++ package.json | 4 ++-- 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml index c6be98178db..71e514c2a7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,5 @@ node_js: - "0.10" - "0.12" sudo: false -script: "npm run-script test-travis" +script: "npm run-script test-ci" after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls" diff --git a/Readme.md b/Readme.md index 479371e465e..d2e7a8ba0ba 100644 --- a/Readme.md +++ b/Readme.md @@ -4,7 +4,8 @@ [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] - [![Build Status][travis-image]][travis-url] + [![Linux Build][travis-image]][travis-url] + [![Windows Build][appveyor-image]][appveyor-url] [![Test Coverage][coveralls-image]][coveralls-url] ```js @@ -125,8 +126,10 @@ The current lead maintainer is [Douglas Christopher Wilson](https://github.com/d [npm-url]: https://npmjs.org/package/express [downloads-image]: https://img.shields.io/npm/dm/express.svg [downloads-url]: https://npmjs.org/package/express -[travis-image]: https://img.shields.io/travis/strongloop/express/master.svg +[travis-image]: https://img.shields.io/travis/strongloop/express/master.svg?label=linux [travis-url]: https://travis-ci.org/strongloop/express +[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows +[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express [coveralls-image]: https://img.shields.io/coveralls/strongloop/express/master.svg [coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master [gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..c33a4240add --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,13 @@ +environment: + matrix: + - nodejs_version: "0.10" + - nodejs_version: "0.12" +install: + - ps: Install-Product node $env:nodejs_version + - npm install +build: off +test_script: + - node --version + - npm --version + - npm run test-ci +version: "{build}" diff --git a/package.json b/package.json index 92441cfe303..de02d5cf452 100644 --- a/package.json +++ b/package.json @@ -83,8 +83,8 @@ ], "scripts": { "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", - "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" + "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/" } } From 1507757f49ec70c11c102c98f15bca6f2ec34452 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 20 Feb 2015 19:09:56 -0500 Subject: [PATCH 0765/1265] deps: istanbul@0.3.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de02d5cf452..f8db6413b5f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "devDependencies": { "after": "0.8.1", "ejs": "2.1.4", - "istanbul": "0.3.5", + "istanbul": "0.3.6", "marked": "0.3.3", "mocha": "~2.1.0", "should": "~5.0.0", From fa546bff852e6cc8aa268840775ae57700431bd4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Feb 2015 15:10:12 -0500 Subject: [PATCH 0766/1265] deps: should@~5.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f8db6413b5f..e7b953c97d4 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "istanbul": "0.3.6", "marked": "0.3.3", "mocha": "~2.1.0", - "should": "~5.0.0", + "should": "~5.0.1", "supertest": "~0.15.0", "hjs": "~0.0.6", "body-parser": "~1.12.0", From 8fe5fd89c6392c055bf9a05b7f0fe855b264a91d Mon Sep 17 00:00:00 2001 From: Seth Krasnianski Date: Sat, 21 Feb 2015 13:25:25 -0500 Subject: [PATCH 0767/1265] tests: fix error-handling typo closes #2557 --- test/req.signedCookies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/req.signedCookies.js b/test/req.signedCookies.js index 719cb464d0d..111a0f77df8 100644 --- a/test/req.signedCookies.js +++ b/test/req.signedCookies.js @@ -29,7 +29,7 @@ describe('req', function(){ .get('/') .set('Cookie', cookie) .end(function(err, res){ - if (err) return don(err); + if (err) return done(err); res.body.should.eql({ obj: { foo: 'bar' } }); done(); }); From adb6069bd00d729f9bb4743007c6f116bf7a4468 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 Feb 2015 00:27:17 -0500 Subject: [PATCH 0768/1265] deps: ejs@2.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e7b953c97d4..ca72762b83f 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ }, "devDependencies": { "after": "0.8.1", - "ejs": "2.1.4", + "ejs": "2.3.1", "istanbul": "0.3.6", "marked": "0.3.3", "mocha": "~2.1.0", From 51f960f2977566f8d671fc0e8154466a1b3d78ca Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 Feb 2015 00:56:49 -0500 Subject: [PATCH 0769/1265] 4.12.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 174851d5dc0..d32bd91bc79 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.12.0 / 2015-02-23 +=================== * Fix `"trust proxy"` setting to inherit when app is mounted * Generate `ETag`s for all request responses diff --git a/package.json b/package.json index ca72762b83f..de216aeb92d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.11.2", + "version": "4.12.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From bb4703e199cbbf62203730be275c81a0f7d68d47 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Feb 2015 21:06:03 -0500 Subject: [PATCH 0770/1265] deps: remove un-used devDependency --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index bc2042905d0..91744bfa260 100644 --- a/package.json +++ b/package.json @@ -55,8 +55,7 @@ "marked": "0.3.3", "mocha": "~2.1.0", "should": "~5.0.0", - "supertest": "~0.15.0", - "hjs": "~0.0.6" + "supertest": "~0.15.0" }, "engines": { "node": ">= 0.8.0" From 20aa12616abac9466d590c9fb333fd8a0408eedc Mon Sep 17 00:00:00 2001 From: Paul Serby Date: Sat, 28 Feb 2015 17:06:37 +0000 Subject: [PATCH 0771/1265] Fix req.protocol/req.secure when using "trust proxy" hops count fixes #2569 closes #2570 --- History.md | 5 +++++ lib/request.js | 2 +- test/req.protocol.js | 17 +++++++++++++++++ test/req.secure.js | 17 +++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3a215127e23..0ab72f31169 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.x +=== + + * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count + 3.20.0 / 2015-02-18 =================== diff --git a/lib/request.js b/lib/request.js index c1392396c19..3bae7ad9bc9 100644 --- a/lib/request.js +++ b/lib/request.js @@ -358,7 +358,7 @@ req.__defineGetter__('protocol', function(){ : 'http'; var trust = this.app.get('trust proxy fn'); - if (!trust(this.connection.remoteAddress)) { + if (!trust(this.connection.remoteAddress, 0)) { return proto; } diff --git a/test/req.protocol.js b/test/req.protocol.js index 80cad8a975f..453ad11ca4a 100644 --- a/test/req.protocol.js +++ b/test/req.protocol.js @@ -75,6 +75,23 @@ describe('req', function(){ .get('/') .expect('http', done); }) + + describe('when trusting hop count', function () { + it('should respect X-Forwarded-Proto', function (done) { + var app = express(); + + app.set('trust proxy', 1); + + app.use(function (req, res) { + res.end(req.protocol); + }); + + request(app) + .get('/') + .set('X-Forwarded-Proto', 'https') + .expect('https', done); + }) + }) }) describe('when "trust proxy" is disabled', function(){ diff --git a/test/req.secure.js b/test/req.secure.js index df9ae93fae6..2025c8786b6 100644 --- a/test/req.secure.js +++ b/test/req.secure.js @@ -78,6 +78,23 @@ describe('req', function(){ .set('X-Forwarded-Proto', 'https, http') .expect('yes', done) }) + + describe('when "trust proxy" trusting hop count', function () { + it('should respect X-Forwarded-Proto', function (done) { + var app = express(); + + app.set('trust proxy', 1); + + app.get('/', function (req, res) { + res.send(req.secure ? 'yes' : 'no'); + }); + + request(app) + .get('/') + .set('X-Forwarded-Proto', 'https') + .expect('yes', done) + }) + }) }) }) }) From 2e0f5e781717a44fd07f08d1c28122e43794611b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Feb 2015 21:32:51 -0500 Subject: [PATCH 0772/1265] Fix req.host when using "trust proxy" hops count --- History.md | 1 + lib/request.js | 2 +- test/req.host.js | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0ab72f31169..96a64b0c668 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Fix `req.host` when using "trust proxy" hops count * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count 3.20.0 / 2015-02-18 diff --git a/lib/request.js b/lib/request.js index 3bae7ad9bc9..efa002145fa 100644 --- a/lib/request.js +++ b/lib/request.js @@ -491,7 +491,7 @@ req.__defineGetter__('host', function(){ var trust = this.app.get('trust proxy fn'); var host = this.get('X-Forwarded-Host'); - if (!host || !trust(this.connection.remoteAddress)) { + if (!host || !trust(this.connection.remoteAddress, 0)) { host = this.get('Host'); } diff --git a/test/req.host.js b/test/req.host.js index 66cfff4e549..8fa3409054f 100644 --- a/test/req.host.js +++ b/test/req.host.js @@ -117,6 +117,24 @@ describe('req', function(){ .set('Host', 'example.com') .expect('example.com', done); }) + + describe('when trusting hop count', function () { + it('should respect X-Forwarded-Host', function (done) { + var app = express(); + + app.set('trust proxy', 1); + + app.use(function (req, res) { + res.end(req.host); + }); + + request(app) + .get('/') + .set('Host', 'localhost') + .set('X-Forwarded-Host', 'example.com') + .expect('example.com', done); + }) + }) }) describe('when "trust proxy" is disabled', function(){ From 5873d335bd2d5a1447ef463076ca87413405bfe9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Feb 2015 22:39:06 -0500 Subject: [PATCH 0773/1265] deps: ejs@2.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 91744bfa260..1483f009910 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "connect-redis": "~1.5.0", - "ejs": "2.1.4", + "ejs": "2.3.1", "istanbul": "0.3.5", "marked": "0.3.3", "mocha": "~2.1.0", From ef71373fa3f5d62cb7932f3dad0abc2d14f81fef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Feb 2015 22:39:55 -0500 Subject: [PATCH 0774/1265] deps: istanbul@0.3.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1483f009910..2e772efad75 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "devDependencies": { "connect-redis": "~1.5.0", "ejs": "2.3.1", - "istanbul": "0.3.5", + "istanbul": "0.3.6", "marked": "0.3.3", "mocha": "~2.1.0", "should": "~5.0.0", From 9ca0c66e23fe44e52500ad5e336014d1dfb808a6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Feb 2015 22:41:01 -0500 Subject: [PATCH 0775/1265] build: skip unnecessary dependency in Travis CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4af6d31b546..a13410d9ece 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,6 @@ node_js: - "0.10" - "0.12" sudo: false +before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-travis" after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls" From b2311c74024ceeb90cd7f4c473b856593106ba65 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Feb 2015 23:16:27 -0500 Subject: [PATCH 0776/1265] 3.20.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 96a64b0c668..606d893ff17 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.20.1 / 2015-02-28 +=================== * Fix `req.host` when using "trust proxy" hops count * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count diff --git a/package.json b/package.json index 2e772efad75..e33eedd528f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.20.0", + "version": "3.20.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 7ee56bbe9cadd25a64e900c52d2cc6287d73ba9b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Feb 2015 23:31:27 -0500 Subject: [PATCH 0777/1265] build: skip unnecessary depdency in AppVeyor --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index c33a4240add..c8b765d509d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ environment: - nodejs_version: "0.12" install: - ps: Install-Product node $env:nodejs_version + - npm rm --save-dev connect-redis - npm install build: off test_script: From 31cb541b881d40cb0a16de2aab3799785a138357 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Mar 2015 16:33:09 -0500 Subject: [PATCH 0778/1265] Fix constructing application with non-configurable prototype properties fixes #2561 --- History.md | 2 ++ lib/express.js | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 2770d6bf031..c2f06d42c08 100644 --- a/History.md +++ b/History.md @@ -1,8 +1,10 @@ unreleased ========== + * Fix constructing application with non-configurable prototype properties * Fix `req.host` when using "trust proxy" hops count * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count + * deps: merge-descriptors@1.0.0 4.12.0 / 2015-02-23 =================== diff --git a/lib/express.js b/lib/express.js index 8a6c28464a9..bb8d8082a49 100644 --- a/lib/express.js +++ b/lib/express.js @@ -28,8 +28,8 @@ function createApplication() { app.handle(req, res, next); }; - mixin(app, proto); - mixin(app, EventEmitter.prototype); + mixin(app, EventEmitter.prototype, false); + mixin(app, proto, false); app.request = { __proto__: req, app: app }; app.response = { __proto__: res, app: app }; diff --git a/package.json b/package.json index a5bf135c1e0..c126ff9597b 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "etag": "~1.5.1", "finalhandler": "0.3.3", "fresh": "0.2.4", + "merge-descriptors": "1.0.0", "methods": "~1.1.1", "on-finished": "~2.2.0", "parseurl": "~1.3.0", @@ -49,7 +50,6 @@ "type-is": "~1.6.0", "vary": "~1.0.0", "cookie": "0.1.2", - "merge-descriptors": "0.0.2", "utils-merge": "1.0.0" }, "devDependencies": { From dbc61fc19186b693329895c6be51f32d262da6ea Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Mar 2015 17:27:50 -0500 Subject: [PATCH 0779/1265] Fix wrong code on aborted connections from res.sendFile --- History.md | 1 + lib/response.js | 2 +- test/res.sendFile.js | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index c2f06d42c08..068ecc89fed 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * Fix constructing application with non-configurable prototype properties * Fix `req.host` when using "trust proxy" hops count * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count + * Fix wrong `code` on aborted connections from `res.sendFile` * deps: merge-descriptors@1.0.0 4.12.0 / 2015-02-23 diff --git a/lib/response.js b/lib/response.js index d3759713a61..168bbf5b886 100644 --- a/lib/response.js +++ b/lib/response.js @@ -949,7 +949,7 @@ function sendfile(res, file, options, callback) { done = true; var err = new Error('Request aborted'); - err.code = 'ECONNABORT'; + err.code = 'ECONNABORTED'; callback(err); } diff --git a/test/res.sendFile.js b/test/res.sendFile.js index c53e10ae672..b80f0462890 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -207,7 +207,7 @@ describe('res', function(){ setImmediate(function () { res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { should(err).be.ok; - err.code.should.equal('ECONNABORT'); + err.code.should.equal('ECONNABORTED'); cb(); }); }); @@ -226,7 +226,7 @@ describe('res', function(){ onFinished(res, function () { res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { should(err).be.ok; - err.code.should.equal('ECONNABORT'); + err.code.should.equal('ECONNABORTED'); cb(); }); }); @@ -323,7 +323,7 @@ describe('res', function(){ setImmediate(function () { res.sendfile('test/fixtures/name.txt', function (err) { should(err).be.ok; - err.code.should.equal('ECONNABORT'); + err.code.should.equal('ECONNABORTED'); cb(); }); }); @@ -342,7 +342,7 @@ describe('res', function(){ onFinished(res, function () { res.sendfile('test/fixtures/name.txt', function (err) { should(err).be.ok; - err.code.should.equal('ECONNABORT'); + err.code.should.equal('ECONNABORTED'); cb(); }); }); From 14a58759c3955d4129990b14ff7f6f621d446855 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Mar 2015 17:28:48 -0500 Subject: [PATCH 0780/1265] Fix ECONNRESET errors from res.sendFile usage fixes #2571 --- History.md | 1 + lib/response.js | 1 + 2 files changed, 2 insertions(+) diff --git a/History.md b/History.md index 068ecc89fed..050ac51befb 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Fix constructing application with non-configurable prototype properties + * Fix `ECONNRESET` errors from `res.sendFile` usage * Fix `req.host` when using "trust proxy" hops count * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count * Fix wrong `code` on aborted connections from `res.sendFile` diff --git a/lib/response.js b/lib/response.js index 168bbf5b886..a78d894c458 100644 --- a/lib/response.js +++ b/lib/response.js @@ -984,6 +984,7 @@ function sendfile(res, file, options, callback) { // finished function onfinish(err) { + if (err && err.code === 'ECONNRESET') return onaborted(); if (err) return onerror(err); if (done) return; From 1e6d2654a284f00c4bb92e201d87982e3dfb9a7c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 1 Mar 2015 19:11:02 -0500 Subject: [PATCH 0781/1265] 4.12.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 050ac51befb..cdf2bfd0c6a 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.12.1 / 2015-03-01 +=================== * Fix constructing application with non-configurable prototype properties * Fix `ECONNRESET` errors from `res.sendFile` usage diff --git a/package.json b/package.json index c126ff9597b..25ad015addd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.12.0", + "version": "4.12.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 7e0afa826816bea6fe048691fdb66bacdc517351 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 2 Mar 2015 13:11:31 -0500 Subject: [PATCH 0782/1265] Fix regression where "Request aborted" is logged using res.sendFile closes #2571 --- History.md | 5 +++++ lib/response.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index cdf2bfd0c6a..bab38b8deb0 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix regression where `"Request aborted"` is logged using `res.sendFile` + 4.12.1 / 2015-03-01 =================== diff --git a/lib/response.js b/lib/response.js index a78d894c458..b759eb95e42 100644 --- a/lib/response.js +++ b/lib/response.js @@ -404,7 +404,7 @@ res.sendFile = function sendFile(path, options, fn) { if (err && err.code === 'EISDIR') return next(); // next() all but write errors - if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') { + if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') { next(err); } }); From dee9fbbbda2f2483c657cf912f68db1a5ba1fcac Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 3 Mar 2015 00:06:24 -0500 Subject: [PATCH 0783/1265] 4.12.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index bab38b8deb0..ee3e97aa5f4 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.12.2 / 2015-03-02 +=================== * Fix regression where `"Request aborted"` is logged using `res.sendFile` diff --git a/package.json b/package.json index 25ad015addd..4257a7fbf62 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.12.1", + "version": "4.12.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From d34d60ce92f363b703fdc7a030e7cd38f17caacc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:13:14 -0400 Subject: [PATCH 0784/1265] deps: mocha@~2.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e33eedd528f..ff14962cdb3 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "ejs": "2.3.1", "istanbul": "0.3.6", "marked": "0.3.3", - "mocha": "~2.1.0", + "mocha": "~2.2.1", "should": "~5.0.0", "supertest": "~0.15.0" }, From 5d8a7a610f99701d694da6a020ad28b4f9f88507 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:14:09 -0400 Subject: [PATCH 0785/1265] deps: should@~5.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff14962cdb3..db12797a2c7 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "istanbul": "0.3.6", "marked": "0.3.3", "mocha": "~2.2.1", - "should": "~5.0.0", + "should": "~5.2.0", "supertest": "~0.15.0" }, "engines": { From 20c040db22bd3b7167c32055df6363d1a540c1e2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:15:07 -0400 Subject: [PATCH 0786/1265] deps: istanbul@0.3.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index db12797a2c7..53d7153bbfa 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "devDependencies": { "connect-redis": "~1.5.0", "ejs": "2.3.1", - "istanbul": "0.3.6", + "istanbul": "0.3.8", "marked": "0.3.3", "mocha": "~2.2.1", "should": "~5.2.0", From 100e50f23dc57367dd99f9a401bdd5b355b24193 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:17:34 -0400 Subject: [PATCH 0787/1265] deps: connect@2.29.1 --- History.md | 18 ++++++++++++++++++ package.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 606d893ff17..6ef21f759eb 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,21 @@ +3.x +=== + + * deps: connect@2.29.1 + - deps: body-parser@~1.12.2 + - deps: compression@~1.4.3 + - deps: connect-timeout@~1.6.1 + - deps: debug@~2.1.3 + - deps: errorhandler@~1.3.5 + - deps: express-session@~1.10.4 + - deps: finalhandler@0.3.4 + - deps: method-override@~2.3.2 + - deps: morgan@~1.5.2 + - deps: qs@2.4.1 + - deps: serve-index@~1.6.3 + - deps: serve-static@~1.9.2 + - deps: type-is@~1.6.1 + 3.20.1 / 2015-02-28 =================== diff --git a/package.json b/package.json index 53d7153bbfa..093df5c2d4d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.29.0", + "connect": "2.29.1", "content-disposition": "0.5.0", "content-type": "~1.0.1", "commander": "2.6.0", From ff44e0f9ae51709eefe93c04cd7ea265b3997771 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:21:58 -0400 Subject: [PATCH 0788/1265] deps: send@0.12.2 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6ef21f759eb..9bc2a129c28 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,9 @@ - deps: serve-index@~1.6.3 - deps: serve-static@~1.9.2 - deps: type-is@~1.6.1 + * deps: send@0.12.2 + - Throw errors early for invalid `extensions` or `index` options + - deps: debug@~2.1.3 3.20.1 / 2015-02-28 =================== diff --git a/package.json b/package.json index 093df5c2d4d..ee809a9900a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.6", "range-parser": "~1.0.2", - "send": "0.12.1", + "send": "0.12.2", "utils-merge": "1.0.0", "vary": "~1.0.0", "cookie": "0.1.2", From d7a6d709affd76b3cf14f7b870c5c09d78644d8f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:23:23 -0400 Subject: [PATCH 0789/1265] deps: merge-descriptors@1.0.0 --- History.md | 1 + package.json | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 9bc2a129c28..01453bcadf9 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,7 @@ - deps: serve-index@~1.6.3 - deps: serve-static@~1.9.2 - deps: type-is@~1.6.1 + * deps: merge-descriptors@1.0.0 * deps: send@0.12.2 - Throw errors early for invalid `extensions` or `index` options - deps: debug@~2.1.3 diff --git a/package.json b/package.json index ee809a9900a..60ffa192f16 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,14 @@ "content-disposition": "0.5.0", "content-type": "~1.0.1", "commander": "2.6.0", + "cookie": "0.1.2", "cookie-signature": "1.0.6", "debug": "~2.1.1", "depd": "~1.0.0", "escape-html": "1.0.1", "etag": "~1.5.1", "fresh": "0.2.4", + "merge-descriptors": "1.0.0", "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0", @@ -44,9 +46,7 @@ "range-parser": "~1.0.2", "send": "0.12.2", "utils-merge": "1.0.0", - "vary": "~1.0.0", - "cookie": "0.1.2", - "merge-descriptors": "0.0.2" + "vary": "~1.0.0" }, "devDependencies": { "connect-redis": "~1.5.0", From 6744f811b4ba6497683ab1e2327f2156caae700f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:25:00 -0400 Subject: [PATCH 0790/1265] deps: debug@~2.1.3 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 01453bcadf9..f9c91ae035a 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,9 @@ - deps: serve-index@~1.6.3 - deps: serve-static@~1.9.2 - deps: type-is@~1.6.1 + * deps: debug@~2.1.3 + - Fix high intensity foreground color for bold + - deps: ms@0.7.0 * deps: merge-descriptors@1.0.0 * deps: send@0.12.2 - Throw errors early for invalid `extensions` or `index` options diff --git a/package.json b/package.json index 60ffa192f16..f2a919733a9 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "commander": "2.6.0", "cookie": "0.1.2", "cookie-signature": "1.0.6", - "debug": "~2.1.1", + "debug": "~2.1.3", "depd": "~1.0.0", "escape-html": "1.0.1", "etag": "~1.5.1", From 279c8bbec306768c5a22ca9cd0b237ec1c4c2a00 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 00:47:15 -0400 Subject: [PATCH 0791/1265] deps: proxy-addr@~1.0.7 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f9c91ae035a..4ecb2e35fa5 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,8 @@ - Fix high intensity foreground color for bold - deps: ms@0.7.0 * deps: merge-descriptors@1.0.0 + * deps: proxy-addr@~1.0.7 + - deps: ipaddr.js@0.1.9 * deps: send@0.12.2 - Throw errors early for invalid `extensions` or `index` options - deps: debug@~2.1.3 diff --git a/package.json b/package.json index f2a919733a9..6d1a39d0a04 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0", - "proxy-addr": "~1.0.6", + "proxy-addr": "~1.0.7", "range-parser": "~1.0.2", "send": "0.12.2", "utils-merge": "1.0.0", From 389ab1b19fe5af63f4dbd119050c604ddcd60885 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 01:02:08 -0400 Subject: [PATCH 0792/1265] tests: add test for cookie-sessions example --- test/acceptance/cookie-sessions.js | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/acceptance/cookie-sessions.js diff --git a/test/acceptance/cookie-sessions.js b/test/acceptance/cookie-sessions.js new file mode 100644 index 00000000000..ad950fc9c21 --- /dev/null +++ b/test/acceptance/cookie-sessions.js @@ -0,0 +1,36 @@ + +var app = require('../../examples/cookie-sessions') +var request = require('supertest') + +function getCookie(res) { + return res.headers['set-cookie'][0].split(';')[0] +} + +describe('cookie-sessions', function () { + describe('GET /', function () { + it('should display no views', function (done) { + request(app) + .get('/') + .expect(200, 'viewed 0 times\n', done) + }) + + it('should set a session cookie', function (done) { + request(app) + .get('/') + .expect('Set-Cookie', /connect\.sess=/) + .expect(200, done) + }) + + it('should display 1 view on revisit', function (done) { + request(app) + .get('/') + .expect(200, 'viewed 0 times\n', function (err, res) { + if (err) return done(err) + request(app) + .get('/') + .set('Cookie', getCookie(res)) + .expect(200, 'viewed 1 times\n', done) + }) + }) + }) +}) From 011e5dc24185eb213cfc09e027498ca34c742103 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 01:03:53 -0400 Subject: [PATCH 0793/1265] 3.20.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 4ecb2e35fa5..e1b644528c7 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.20.2 / 2015-03-16 +=================== * deps: connect@2.29.1 - deps: body-parser@~1.12.2 diff --git a/package.json b/package.json index 6d1a39d0a04..475efa018a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.20.1", + "version": "3.20.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 9d16bae6821616033389c6cb20652453d155b586 Mon Sep 17 00:00:00 2001 From: Roman Zubenko Date: Wed, 11 Mar 2015 19:44:45 -0400 Subject: [PATCH 0794/1265] docs: fix typo in readme closes #2584 --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index d2e7a8ba0ba..65aed5c99ae 100644 --- a/Readme.md +++ b/Readme.md @@ -103,7 +103,7 @@ $ node examples/content-negotiation ## Tests - To run the test suite, first install the dependancies, then run `npm test`: + To run the test suite, first install the dependencies, then run `npm test`: ```bash $ npm install From 1114ca1ab651707abaf5d7505d9d5144cc1bbd89 Mon Sep 17 00:00:00 2001 From: Phat Date: Sat, 14 Mar 2015 17:52:47 +0700 Subject: [PATCH 0795/1265] tests: fix assert usage mistake fixes #2592 --- test/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/app.js b/test/app.js index 117f4dffeb5..941d35ff1cc 100644 --- a/test/app.js +++ b/test/app.js @@ -12,7 +12,7 @@ describe('app', function(){ it('should be callable', function(){ var app = express(); - assert(typeof app, 'function'); + assert.equal(typeof app, 'function'); }) it('should 404 without routes', function(done){ From 01e059ca742dc606a2951f9d8bd5b6bcd31a438c Mon Sep 17 00:00:00 2001 From: Yang Wang <250801860@qq.com> Date: Fri, 13 Mar 2015 21:13:34 +0800 Subject: [PATCH 0796/1265] examples: add missing cookie-session module fixes #2589 --- examples/cookie-sessions/index.js | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/cookie-sessions/index.js b/examples/cookie-sessions/index.js index b7b9ce51e10..73653f63af9 100644 --- a/examples/cookie-sessions/index.js +++ b/examples/cookie-sessions/index.js @@ -2,6 +2,7 @@ * Module dependencies. */ +var cookieSession = require('cookie-session'); var express = require('../../'); var app = module.exports = express(); diff --git a/package.json b/package.json index 4257a7fbf62..344cde52481 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "body-parser": "~1.12.0", "connect-redis": "~2.2.0", "cookie-parser": "~1.3.4", + "cookie-session": "~1.1.0", "express-session": "~1.10.3", "jade": "~1.9.2", "method-override": "~2.3.1", From 410f561b1bce997a39f119e3691f7fd2727839ae Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 01:57:36 -0400 Subject: [PATCH 0797/1265] deps: serve-static@~1.9.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2dee7de4563..e1559a0bd82 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,8 @@ unreleased * deps: send@0.12.2 - Throw errors early for invalid `extensions` or `index` options - deps: debug@~2.1.3 + * deps: serve-static@~1.9.2 + - deps: send@0.12.2 4.12.2 / 2015-03-02 =================== diff --git a/package.json b/package.json index 875dda8f5da..963d6617937 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "qs": "2.3.3", "range-parser": "~1.0.2", "send": "0.12.2", - "serve-static": "~1.9.1", + "serve-static": "~1.9.2", "type-is": "~1.6.0", "vary": "~1.0.0", "utils-merge": "1.0.0" From 9e3727bb23ed6f5560565fceb4b9a1be1b3efc41 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 01:58:25 -0400 Subject: [PATCH 0798/1265] deps: finalhandler@0.3.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e1559a0bd82..fe6823e2124 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * deps: debug@~2.1.3 - Fix high intensity foreground color for bold - deps: ms@0.7.0 + * deps: finalhandler@0.3.4 + - deps: debug@~2.1.3 * deps: proxy-addr@~1.0.7 - deps: ipaddr.js@0.1.9 * deps: send@0.12.2 diff --git a/package.json b/package.json index 963d6617937..f801e1d082c 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "depd": "~1.0.0", "escape-html": "1.0.1", "etag": "~1.5.1", - "finalhandler": "0.3.3", + "finalhandler": "0.3.4", "fresh": "0.2.4", "merge-descriptors": "1.0.0", "methods": "~1.1.1", From 07217205bb6bf04a7740cf178dbe375c65cac39a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 01:59:10 -0400 Subject: [PATCH 0799/1265] deps: type-is@~1.6.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index fe6823e2124..102659723a2 100644 --- a/History.md +++ b/History.md @@ -13,6 +13,8 @@ unreleased - deps: debug@~2.1.3 * deps: serve-static@~1.9.2 - deps: send@0.12.2 + * deps: type-is@~1.6.1 + - deps: mime-types@~2.0.10 4.12.2 / 2015-03-02 =================== diff --git a/package.json b/package.json index f801e1d082c..e8021c6cf6c 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "range-parser": "~1.0.2", "send": "0.12.2", "serve-static": "~1.9.2", - "type-is": "~1.6.0", + "type-is": "~1.6.1", "vary": "~1.0.0", "utils-merge": "1.0.0" }, From d0a830bb425c687337629ddbb815077858cdbc51 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 02:00:03 -0400 Subject: [PATCH 0800/1265] deps: accepts@~1.2.5 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 102659723a2..328cbeae43b 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ unreleased ========== + * deps: accepts@~1.2.5 + - deps: mime-types@~2.0.10 * deps: debug@~2.1.3 - Fix high intensity foreground color for bold - deps: ms@0.7.0 diff --git a/package.json b/package.json index e8021c6cf6c..982e68f91ac 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.4", + "accepts": "~1.2.5", "content-disposition": "0.5.0", "content-type": "~1.0.1", "cookie": "0.1.2", From 8ddf158d8960e2dfe7b2f90c9025564832dadcba Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 02:00:56 -0400 Subject: [PATCH 0801/1265] deps: qs@2.4.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 328cbeae43b..8b528a793ab 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,8 @@ unreleased - deps: debug@~2.1.3 * deps: proxy-addr@~1.0.7 - deps: ipaddr.js@0.1.9 + * deps: qs@2.4.1 + - Fix error when parameter `hasOwnProperty` is present * deps: send@0.12.2 - Throw errors early for invalid `extensions` or `index` options - deps: debug@~2.1.3 diff --git a/package.json b/package.json index 982e68f91ac..34b663fd1f0 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.7", - "qs": "2.3.3", + "qs": "2.4.1", "range-parser": "~1.0.2", "send": "0.12.2", "serve-static": "~1.9.2", From 4597e118ae7c5d945d4374b572a2a570fc2acf84 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 02:02:23 -0400 Subject: [PATCH 0802/1265] deps: update example dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 34b663fd1f0..be40affcc49 100644 --- a/package.json +++ b/package.json @@ -60,14 +60,14 @@ "mocha": "~2.2.1", "should": "~5.2.0", "supertest": "~0.15.0", - "body-parser": "~1.12.0", + "body-parser": "~1.12.2", "connect-redis": "~2.2.0", "cookie-parser": "~1.3.4", "cookie-session": "~1.1.0", - "express-session": "~1.10.3", + "express-session": "~1.10.4", "jade": "~1.9.2", - "method-override": "~2.3.1", - "morgan": "~1.5.1", + "method-override": "~2.3.2", + "morgan": "~1.5.2", "multiparty": "~4.1.1", "vhost": "~3.0.0" }, From c894c84e4ab1d3bc08d7776d437131244bc6329b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 02:03:36 -0400 Subject: [PATCH 0803/1265] build: support io.js 1.x closes #2539 --- .travis.yml | 2 ++ appveyor.yml | 2 ++ test/res.send.js | 7 ++----- test/res.sendFile.js | 13 ++++--------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91038947d01..dc2e2c8e236 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: node_js node_js: - "0.10" - "0.12" + - "1.0" + - "1.5" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index c8b765d509d..eb8dbcc6d1b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,8 @@ environment: matrix: - nodejs_version: "0.10" - nodejs_version: "0.12" + - nodejs_version: "1.0" + - nodejs_version: "1.5" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis diff --git a/test/res.send.js b/test/res.send.js index 6c1361b5b1c..c5040631fe6 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -16,7 +16,7 @@ describe('res', function(){ request(app) .get('/') .expect('Content-Length', '0') - .expect('', done); + .expect(200, '', done); }) }) @@ -30,10 +30,7 @@ describe('res', function(){ request(app) .get('/') - .expect('', function(req, res){ - res.header.should.not.have.property('content-length'); - done(); - }); + .expect(200, '', done); }) }) diff --git a/test/res.sendFile.js b/test/res.sendFile.js index b80f0462890..f4868b39766 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -388,12 +388,12 @@ describe('res', function(){ }); it('should invoke the callback on 404', function(done){ - var app = express() - , calls = 0; + var app = express(); + var calls = 0; app.use(function(req, res){ res.sendfile('test/fixtures/nope.html', function(err){ - ++calls; + assert.equal(calls++, 0); assert(!res.headersSent); res.send(err.message); }); @@ -401,12 +401,7 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - assert(1 == calls, 'called too many times'); - res.text.should.startWith("ENOENT, stat"); - res.statusCode.should.equal(200); - done(); - }); + .expect(200, /^ENOENT.*?, stat/, done); }) it('should not override manual content-types', function(done){ From f56463f8bf24015736978d0dc4d398fa22a9d758 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Mar 2015 10:59:48 -0400 Subject: [PATCH 0804/1265] 4.12.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 8b528a793ab..c0b9ed6e602 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.12.3 / 2015-03-17 +=================== * deps: accepts@~1.2.5 - deps: mime-types@~2.0.10 diff --git a/package.json b/package.json index be40affcc49..3c693a57700 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.12.2", + "version": "4.12.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 2f8a69b7101e212e0e18bed1509cd2e7343148db Mon Sep 17 00:00:00 2001 From: Igor Mozharovsky Date: Wed, 18 Mar 2015 20:25:11 +0200 Subject: [PATCH 0805/1265] docs: fix typo in readme closes #2598 --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 65aed5c99ae..8da83a517e1 100644 --- a/Readme.md +++ b/Readme.md @@ -87,7 +87,7 @@ $ npm start ## Examples - To view the examples, clone the Express repo and install the dependancies: + To view the examples, clone the Express repo and install the dependencies: ```bash $ git clone git://github.com/strongloop/express.git --depth 1 From bbcc1e1f52cb3706660d88bc2884057d71ae1f92 Mon Sep 17 00:00:00 2001 From: Alex Dixon Date: Thu, 19 Mar 2015 17:54:36 -0700 Subject: [PATCH 0806/1265] examples: fix route-separation example's dev logger closes #2599 --- examples/route-separation/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/route-separation/index.js b/examples/route-separation/index.js index bac61ea8944..3d93d5cfd9c 100644 --- a/examples/route-separation/index.js +++ b/examples/route-separation/index.js @@ -21,7 +21,7 @@ app.set('views', __dirname + '/views'); /* istanbul ignore next */ if (!module.parent) { - app.use(express.logger('dev')); + app.use(logger('dev')); } app.use(methodOverride('_method')); From ab3e7b2465e07f0c63c66a4c520ed87c861b704f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 11 Apr 2015 09:54:09 -0400 Subject: [PATCH 0807/1265] examples: remove problematic file from download example closes #2393 --- .../files/utf-8 \355\225\234\344\270\255\346\227\245.txt" | 1 - examples/downloads/index.js | 1 - 2 files changed, 2 deletions(-) delete mode 100644 "examples/downloads/files/utf-8 \355\225\234\344\270\255\346\227\245.txt" diff --git "a/examples/downloads/files/utf-8 \355\225\234\344\270\255\346\227\245.txt" "b/examples/downloads/files/utf-8 \355\225\234\344\270\255\346\227\245.txt" deleted file mode 100644 index 2a4ee9c7d25..00000000000 --- "a/examples/downloads/files/utf-8 \355\225\234\344\270\255\346\227\245.txt" +++ /dev/null @@ -1 +0,0 @@ -한中日 \ No newline at end of file diff --git a/examples/downloads/index.js b/examples/downloads/index.js index d7bdc0c0430..6ab6ba0213e 100644 --- a/examples/downloads/index.js +++ b/examples/downloads/index.js @@ -8,7 +8,6 @@ var app = module.exports = express(); app.get('/', function(req, res){ res.send(''); From 8dd1b3a61802a4bd74cd803c6f8a95783dfc1f6a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 11 Apr 2015 09:59:44 -0400 Subject: [PATCH 0808/1265] build: io.js@1.6 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc2e2c8e236..d51b8d188dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "0.10" - "0.12" - "1.0" - - "1.5" + - "1.6" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index eb8dbcc6d1b..1f48f1812a0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ environment: - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "1.0" - - nodejs_version: "1.5" + - nodejs_version: "1.6" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From ea6e4d3b6f434016a60e4d077d37fd7e76744eb6 Mon Sep 17 00:00:00 2001 From: Ignacio Carbajo Date: Fri, 1 May 2015 16:15:27 +0200 Subject: [PATCH 0809/1265] tests: add a missing test description closes #2631 --- test/app.all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/app.all.js b/test/app.all.js index a0c68d429d5..e9ef08831df 100644 --- a/test/app.all.js +++ b/test/app.all.js @@ -19,7 +19,7 @@ describe('app.all()', function(){ }); }) - it('should ', function(done){ + it('should run the callback for a method just once', function(done){ var app = express() , n = 0; From 6d43bacb4691f255e8d67a8d074e7a3062c8cd5a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 1 May 2015 22:24:05 -0400 Subject: [PATCH 0810/1265] build: io.js@1.8 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d51b8d188dc..b163d5dc22d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "0.10" - "0.12" - "1.0" - - "1.6" + - "1.8" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index 1f48f1812a0..8be4511b02a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ environment: - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "1.0" - - nodejs_version: "1.6" + - nodejs_version: "1.8" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From d0e8ac795d580a4da9a84aa6574fe6d8134ace9f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 20:56:52 -0400 Subject: [PATCH 0811/1265] deps: connect@2.29.2 --- History.md | 20 ++++++++++++++++++++ package.json | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e1b644528c7..426ba80dfb4 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,23 @@ +3.x +=== + + * deps: connect@2.29.2 + - deps: body-parser@~1.12.4 + - deps: compression@~1.4.4 + - deps: connect-timeout@~1.6.2 + - deps: debug@~2.2.0 + - deps: depd@~1.0.1 + - deps: errorhandler@~1.3.6 + - deps: finalhandler@0.3.6 + - deps: method-override@~2.3.3 + - deps: morgan@~1.5.3 + - deps: qs@2.4.2 + - deps: response-time@~2.3.1 + - deps: serve-favicon@~2.2.1 + - deps: serve-index@~1.6.4 + - deps: serve-static@~1.9.3 + - deps: type-is@~1.6.2 + 3.20.2 / 2015-03-16 =================== diff --git a/package.json b/package.json index 475efa018a9..72dd1d49320 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.29.1", + "connect": "2.29.2", "content-disposition": "0.5.0", "content-type": "~1.0.1", "commander": "2.6.0", From cac867da843e611c26bb208eb98f6c76dbade826 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 20:58:21 -0400 Subject: [PATCH 0812/1265] deps: istanbul@0.3.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72dd1d49320..eab6e8f5051 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "devDependencies": { "connect-redis": "~1.5.0", "ejs": "2.3.1", - "istanbul": "0.3.8", + "istanbul": "0.3.9", "marked": "0.3.3", "mocha": "~2.2.1", "should": "~5.2.0", From c90de122c8fe8e3296275d74eb3db6c0bc7c2f25 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 20:59:02 -0400 Subject: [PATCH 0813/1265] deps: mocha@2.2.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eab6e8f5051..62274cca2a9 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "ejs": "2.3.1", "istanbul": "0.3.9", "marked": "0.3.3", - "mocha": "~2.2.1", + "mocha": "2.2.5", "should": "~5.2.0", "supertest": "~0.15.0" }, From f7455227e05b55f21ece5064688c66f5b3f10a90 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 21:04:02 -0400 Subject: [PATCH 0814/1265] deps: proxy-addr@~1.0.8 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 426ba80dfb4..b13be3bc43b 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,8 @@ - deps: serve-index@~1.6.4 - deps: serve-static@~1.9.3 - deps: type-is@~1.6.2 + * deps: proxy-addr@~1.0.8 + - deps: ipaddr.js@1.0.1 3.20.2 / 2015-03-16 =================== diff --git a/package.json b/package.json index 62274cca2a9..5c5fcfbc3d0 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0", - "proxy-addr": "~1.0.7", + "proxy-addr": "~1.0.8", "range-parser": "~1.0.2", "send": "0.12.2", "utils-merge": "1.0.0", From 519f655f1785f8f66cfa26053efabaf250c06465 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 21:07:06 -0400 Subject: [PATCH 0815/1265] deps: send@0.12.3 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b13be3bc43b..b699462ea1e 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,12 @@ - deps: type-is@~1.6.2 * deps: proxy-addr@~1.0.8 - deps: ipaddr.js@1.0.1 + * deps: send@0.12.3 + - deps: debug@~2.2.0 + - deps: depd@~1.0.1 + - deps: etag@~1.6.0 + - deps: ms@0.7.1 + - deps: on-finished@~2.2.1 3.20.2 / 2015-03-16 =================== diff --git a/package.json b/package.json index 5c5fcfbc3d0..722d0b17188 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.8", "range-parser": "~1.0.2", - "send": "0.12.2", + "send": "0.12.3", "utils-merge": "1.0.0", "vary": "~1.0.0" }, From 96b4a76382a274f1d68b2f69bf0b9502062d51ef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 23:38:35 -0400 Subject: [PATCH 0816/1265] deps: depd@~1.0.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b699462ea1e..80aec28c521 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,7 @@ - deps: serve-index@~1.6.4 - deps: serve-static@~1.9.3 - deps: type-is@~1.6.2 + * deps: depd@~1.0.1 * deps: proxy-addr@~1.0.8 - deps: ipaddr.js@1.0.1 * deps: send@0.12.3 diff --git a/package.json b/package.json index 722d0b17188..d3bd623f423 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "cookie": "0.1.2", "cookie-signature": "1.0.6", "debug": "~2.1.3", - "depd": "~1.0.0", + "depd": "~1.0.1", "escape-html": "1.0.1", "etag": "~1.5.1", "fresh": "0.2.4", From 7df8fa3be5a3a5b528f6192afe9b1b04cefce6c5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 23:44:09 -0400 Subject: [PATCH 0817/1265] deps: supertest@1.0.1 --- examples/params/app.js | 12 ++++++++++-- package.json | 2 +- test/acceptance/mvc.js | 4 ++-- test/acceptance/params.js | 8 ++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/examples/params/app.js b/examples/params/app.js index 69973c878cd..e1a4b693aa7 100644 --- a/examples/params/app.js +++ b/examples/params/app.js @@ -16,12 +16,20 @@ var users = [ , { name: 'bandit' } ]; +// Create HTTP error + +function createError(status, message) { + var err = new Error(message); + err.status = status; + return err; +} + // Convert :to and :from to integers app.param(['to', 'from'], function(req, res, next, num, name){ req.params[name] = parseInt(num, 10); if( isNaN(req.params[name]) ){ - next(new Error('failed to parseInt '+num)); + next(createError(400, 'failed to parseInt '+num)); } else { next(); } @@ -33,7 +41,7 @@ app.param('user', function(req, res, next, id){ if (req.user = users[id]) { next(); } else { - next(new Error('failed to find user')); + next(createError(404, 'failed to find user')); } }); diff --git a/package.json b/package.json index d3bd623f423..1033c10967f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "marked": "0.3.3", "mocha": "2.2.5", "should": "~5.2.0", - "supertest": "~0.15.0" + "supertest": "1.0.1" }, "engines": { "node": ">= 0.8.0" diff --git a/test/acceptance/mvc.js b/test/acceptance/mvc.js index df0ce7d9bf9..8b97a7ddbf9 100644 --- a/test/acceptance/mvc.js +++ b/test/acceptance/mvc.js @@ -35,7 +35,7 @@ describe('mvc', function(){ .put('/pet/3') .set('Content-Type', 'application/x-www-form-urlencoded') .send({ pet: { name: 'Boots' } }) - .end(function(err, res){ + .expect(302, function (err, res) { if (err) return done(err); request(app) .get('/pet/3/edit') @@ -98,7 +98,7 @@ describe('mvc', function(){ .put('/user/1') .set('Content-Type', 'application/x-www-form-urlencoded') .send({ user: { name: 'Tobo' }}) - .end(function(err, res){ + .expect(302, function (err, res) { if (err) return done(err); request(app) .get('/user/1/edit') diff --git a/test/acceptance/params.js b/test/acceptance/params.js index cfa65896e63..1b5e1d5efe8 100644 --- a/test/acceptance/params.js +++ b/test/acceptance/params.js @@ -21,8 +21,8 @@ describe('params', function(){ describe('GET /user/9', function(){ it('should fail to find user', function(done){ request(app) - .get('/user/9') - .expect(/failed to find user/,done) + .get('/user/9') + .expect(404, /failed to find user/, done) }) }) @@ -37,8 +37,8 @@ describe('params', function(){ describe('GET /users/foo-bar', function(){ it('should fail integer parsing', function(done){ request(app) - .get('/users/foo-bar') - .expect(/failed to parseInt foo/,done) + .get('/users/foo-bar') + .expect(400, /failed to parseInt foo/, done) }) }) }) From ee2e4f17bb21c8667adcb07cd1b89ed176662456 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 23:53:35 -0400 Subject: [PATCH 0818/1265] deps: should@6.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1033c10967f..0635d10777c 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "istanbul": "0.3.9", "marked": "0.3.3", "mocha": "2.2.5", - "should": "~5.2.0", + "should": "6.0.1", "supertest": "1.0.1" }, "engines": { From 630c650c3ec7ff370308963e211673cab89434bb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 May 2015 23:54:59 -0400 Subject: [PATCH 0819/1265] deps: debug@~2.2.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 80aec28c521..47b50f45bf3 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,8 @@ - deps: serve-index@~1.6.4 - deps: serve-static@~1.9.3 - deps: type-is@~1.6.2 + * deps: debug@~2.2.0 + - deps: ms@0.7.1 * deps: depd@~1.0.1 * deps: proxy-addr@~1.0.8 - deps: ipaddr.js@1.0.1 diff --git a/package.json b/package.json index 0635d10777c..dc33f604fa1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "commander": "2.6.0", "cookie": "0.1.2", "cookie-signature": "1.0.6", - "debug": "~2.1.3", + "debug": "~2.2.0", "depd": "~1.0.1", "escape-html": "1.0.1", "etag": "~1.5.1", From 057898bbe8ae0a9d462eda7dc11ba0a04bf3a54f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:03:54 -0400 Subject: [PATCH 0820/1265] docs: update badges --- Readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 4200fe730eb..0c84aa6183c 100644 --- a/Readme.md +++ b/Readme.md @@ -2,10 +2,10 @@ Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). - [![NPM version](https://img.shields.io/npm/v/express.svg?style=flat)](https://www.npmjs.org/package/express) - [![Build Status](https://img.shields.io/travis/strongloop/express.svg?style=flat)](https://travis-ci.org/strongloop/express) - [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg?style=flat)](https://coveralls.io/r/strongloop/express) - [![Gratipay](https://img.shields.io/gratipay/dougwilson.svg?style=flat)](https://gratipay.com/dougwilson/) + [![NPM version](https://img.shields.io/npm/v/express.svg)](https://www.npmjs.org/package/express) + [![Build Status](https://img.shields.io/travis/strongloop/express/3.x.svg)](https://travis-ci.org/strongloop/express) + [![Coverage Status](https://img.shields.io/coveralls/strongloop/express/3.x.svg)](https://coveralls.io/r/strongloop/express) + [![Gratipay](https://img.shields.io/gratipay/dougwilson.svg)](https://gratipay.com/dougwilson/) ```js var express = require('express'); From b149430114b42299be84b5c1dfe25a8303605db5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:04:41 -0400 Subject: [PATCH 0821/1265] 3.20.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 47b50f45bf3..fbbed9e1357 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.20.3 / 2015-05-17 +=================== * deps: connect@2.29.2 - deps: body-parser@~1.12.4 diff --git a/package.json b/package.json index dc33f604fa1..6dfbe7e3628 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.20.2", + "version": "3.20.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 13300f48339b138a10e2b924cb35b4a102cd2bc1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:13:48 -0400 Subject: [PATCH 0822/1265] deps: serve-static@~1.9.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5e197c35bcc..716de5f7eb3 100644 --- a/History.md +++ b/History.md @@ -12,6 +12,8 @@ unreleased - deps: etag@~1.6.0 - deps: ms@0.7.1 - deps: on-finished@~2.2.1 + * deps: serve-static@~1.9.3 + - deps: send@0.12.3 4.12.3 / 2015-03-17 =================== diff --git a/package.json b/package.json index 26a82d2d583..2211fd4ef89 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "qs": "2.4.1", "range-parser": "~1.0.2", "send": "0.12.3", - "serve-static": "~1.9.2", + "serve-static": "~1.9.3", "type-is": "~1.6.1", "vary": "~1.0.0", "utils-merge": "1.0.0" From cd52263d232067c19c4ebdf8761209083acbbfef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:15:11 -0400 Subject: [PATCH 0823/1265] deps: finalhandler@0.3.6 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 716de5f7eb3..a1fa11c280f 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,9 @@ unreleased * deps: debug@~2.2.0 - deps: ms@0.7.1 * deps: depd@~1.0.1 + * deps: finalhandler@0.3.6 + - deps: debug@~2.2.0 + - deps: on-finished@~2.2.1 * deps: proxy-addr@~1.0.8 - deps: ipaddr.js@1.0.1 * deps: send@0.12.3 diff --git a/package.json b/package.json index 2211fd4ef89..af2a327b790 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "depd": "~1.0.1", "escape-html": "1.0.1", "etag": "~1.5.1", - "finalhandler": "0.3.4", + "finalhandler": "0.3.6", "fresh": "0.2.4", "merge-descriptors": "1.0.0", "methods": "~1.1.1", From 57252060b2eaaa582027cbad46a6db093f1a6433 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:16:14 -0400 Subject: [PATCH 0824/1265] deps: type-is@~1.6.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a1fa11c280f..99a0d6baaa3 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,8 @@ unreleased - deps: on-finished@~2.2.1 * deps: serve-static@~1.9.3 - deps: send@0.12.3 + * deps: type-is@~1.6.2 + - deps: mime-types@~2.0.11 4.12.3 / 2015-03-17 =================== diff --git a/package.json b/package.json index af2a327b790..96da188b39f 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "range-parser": "~1.0.2", "send": "0.12.3", "serve-static": "~1.9.3", - "type-is": "~1.6.1", + "type-is": "~1.6.2", "vary": "~1.0.0", "utils-merge": "1.0.0" }, From d84bdd6e7d345876a47f860234ed24788d877b34 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:17:10 -0400 Subject: [PATCH 0825/1265] deps: qs@2.4.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 99a0d6baaa3..ab698508a7c 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,8 @@ unreleased - deps: on-finished@~2.2.1 * deps: proxy-addr@~1.0.8 - deps: ipaddr.js@1.0.1 + * deps: qs@2.4.2 + - Fix allowing parameters like `constructor` * deps: send@0.12.3 - deps: debug@~2.2.0 - deps: depd@~1.0.1 diff --git a/package.json b/package.json index 96da188b39f..d7bbd888b28 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.8", - "qs": "2.4.1", + "qs": "2.4.2", "range-parser": "~1.0.2", "send": "0.12.3", "serve-static": "~1.9.3", From 1255bca3529541d41cc270eb73fbd1cfe76e4da4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:18:19 -0400 Subject: [PATCH 0826/1265] deps: on-finished@~2.2.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ab698508a7c..7aadf628389 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ unreleased * deps: finalhandler@0.3.6 - deps: debug@~2.2.0 - deps: on-finished@~2.2.1 + * deps: on-finished@~2.2.1 + - Fix `isFinished(req)` when data buffered * deps: proxy-addr@~1.0.8 - deps: ipaddr.js@1.0.1 * deps: qs@2.4.2 diff --git a/package.json b/package.json index d7bbd888b28..9dca3eab930 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "fresh": "0.2.4", "merge-descriptors": "1.0.0", "methods": "~1.1.1", - "on-finished": "~2.2.0", + "on-finished": "~2.2.1", "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.8", From 2efe7da0a053be4f2ce4a273f1ceb22abe346537 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:19:43 -0400 Subject: [PATCH 0827/1265] deps: accepts@~1.2.7 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7aadf628389..9c2e4e760b3 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,9 @@ unreleased ========== + * deps: accepts@~1.2.7 + - deps: mime-types@~2.0.11 + - deps: negotiator@0.5.3 * deps: debug@~2.2.0 - deps: ms@0.7.1 * deps: depd@~1.0.1 diff --git a/package.json b/package.json index 9dca3eab930..4d4887a6dbd 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.5", + "accepts": "~1.2.7", "content-disposition": "0.5.0", "content-type": "~1.0.1", "cookie": "0.1.2", From 18c30d46aa6f411b5f710202c14b191d226b3a0c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:21:33 -0400 Subject: [PATCH 0828/1265] deps: update example dependencies --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 4d4887a6dbd..30b90646103 100644 --- a/package.json +++ b/package.json @@ -60,15 +60,15 @@ "mocha": "2.2.5", "should": "6.0.1", "supertest": "1.0.1", - "body-parser": "~1.12.2", - "connect-redis": "~2.2.0", + "body-parser": "~1.12.4", + "connect-redis": "~2.3.0", "cookie-parser": "~1.3.4", "cookie-session": "~1.1.0", - "express-session": "~1.10.4", + "express-session": "~1.11.2", "jade": "~1.9.2", - "method-override": "~2.3.2", - "morgan": "~1.5.2", - "multiparty": "~4.1.1", + "method-override": "~2.3.3", + "morgan": "~1.5.3", + "multiparty": "~4.1.2", "vhost": "~3.0.0" }, "engines": { From 4952127f5bddad74bf292f80ed156391d86285db Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:24:03 -0400 Subject: [PATCH 0829/1265] deps: etag@~1.6.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9c2e4e760b3..b873ef0bcfb 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,9 @@ unreleased * deps: debug@~2.2.0 - deps: ms@0.7.1 * deps: depd@~1.0.1 + * deps: etag@~1.6.0 + - Improve support for JXcore + - Support "fake" stats objects in environments without `fs` * deps: finalhandler@0.3.6 - deps: debug@~2.2.0 - deps: on-finished@~2.2.1 diff --git a/package.json b/package.json index 30b90646103..afa86c3ef77 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "debug": "~2.2.0", "depd": "~1.0.1", "escape-html": "1.0.1", - "etag": "~1.5.1", + "etag": "~1.6.0", "finalhandler": "0.3.6", "fresh": "0.2.4", "merge-descriptors": "1.0.0", From e9c9f95ade0f20a048861ac886d4767a839d5286 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 18 May 2015 00:38:34 -0400 Subject: [PATCH 0830/1265] 4.12.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b873ef0bcfb..3ce212fa52c 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.12.4 / 2015-05-17 +=================== * deps: accepts@~1.2.7 - deps: mime-types@~2.0.11 diff --git a/package.json b/package.json index afa86c3ef77..63fe46b3dcc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.12.3", + "version": "4.12.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 9ae08f932e11dcf53f938c8e6ef184cc2c5adf68 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Jun 2015 01:17:42 -0400 Subject: [PATCH 0831/1265] build: should@6.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6dfbe7e3628..57f85757014 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "istanbul": "0.3.9", "marked": "0.3.3", "mocha": "2.2.5", - "should": "6.0.1", + "should": "6.0.3", "supertest": "1.0.1" }, "engines": { From a20a9a1a2e4dee052ca6832af6ae16a74c1ed9e0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Jun 2015 01:21:20 -0400 Subject: [PATCH 0832/1265] deps: mkdirp@0.5.1 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index fbbed9e1357..8aa0e86df18 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +3.x +=== + + * deps: mkdirp@0.5.1 + - Work in global strict mode + 3.20.3 / 2015-05-17 =================== diff --git a/package.json b/package.json index 57f85757014..f4642558481 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "fresh": "0.2.4", "merge-descriptors": "1.0.0", "methods": "~1.1.1", - "mkdirp": "0.5.0", + "mkdirp": "0.5.1", "parseurl": "~1.3.0", "proxy-addr": "~1.0.8", "range-parser": "~1.0.2", From 29f51c67a612ecdf08494bc440f22918ce72a32e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Jun 2015 01:24:21 -0400 Subject: [PATCH 0833/1265] docs: fix typos in history closes #2676 closes #2677 closes #2678 --- History.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 8aa0e86df18..e6af31f0b63 100644 --- a/History.md +++ b/History.md @@ -852,7 +852,7 @@ * update commander * jsonp: check if callback is a function * router: wrap encodeURIComponent in a try/catch #1735 (@lxe) - * res.format: now includes chraset @1747 (@sorribas) + * res.format: now includes charset @1747 (@sorribas) * res.links: allow multiple calls @1746 (@sorribas) 3.4.0 / 2013-09-07 @@ -1131,7 +1131,7 @@ * Added another example to content-negotiation * Added `fresh` dep * Changed: `res.send()` always checks freshness - * Fixed: expose connects mime module. Cloases #1165 + * Fixed: expose connects mime module. Closes #1165 3.0.0beta2 / 2012-06-06 ================== @@ -1213,7 +1213,7 @@ * Added `req.ips` * Added `req.fresh` * Added `req.stale` - * Added comma-delmited / array support for `req.accepts()` + * Added comma-delimited / array support for `req.accepts()` * Added debug instrumentation * Added `res.set(obj)` * Added `res.set(field, value)` From 62dfa792b26e32c99c27b07d490fa156d61a7782 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:08:32 -0400 Subject: [PATCH 0834/1265] deps: connect@2.30.0 --- History.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e6af31f0b63..4fc52c4b75e 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,22 @@ 3.x === + * deps: connect@2.30.0 + - deps: body-parser@~1.13.1 + - deps: bytes@2.1.0 + - deps: compression@~1.5.0 + - deps: cookie@0.1.3 + - deps: cookie-parser@~1.3.5 + - deps: csurf@~1.8.3 + - deps: errorhandler@~1.4.0 + - deps: express-session@~1.11.3 + - deps: finalhandler@0.4.0 + - deps: fresh@0.3.0 + - deps: morgan@~1.6.0 + - deps: serve-favicon@~2.3.0 + - deps: serve-index@~1.7.0 + - deps: serve-static@~1.10.0 + - deps: type-is@~1.6.3 * deps: mkdirp@0.5.1 - Work in global strict mode diff --git a/package.json b/package.json index f4642558481..e060ace59a4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.0", - "connect": "2.29.2", + "connect": "2.30.0", "content-disposition": "0.5.0", "content-type": "~1.0.1", "commander": "2.6.0", From 92b5fa8c53fd451623523a41c3cedfd2efb8f4aa Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:10:16 -0400 Subject: [PATCH 0835/1265] build: should@7.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e060ace59a4..123a2c5ee64 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "istanbul": "0.3.9", "marked": "0.3.3", "mocha": "2.2.5", - "should": "6.0.3", + "should": "7.0.1", "supertest": "1.0.1" }, "engines": { From 5207b99e0874df268cb8f54eabedb314485890cd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:34:04 -0400 Subject: [PATCH 0836/1265] deps: basic-auth@1.0.2 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4fc52c4b75e..e681d5d75b1 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,11 @@ 3.x === + * deps: basic-auth@1.0.2 + - perf: enable strict mode + - perf: hoist regular expression + - perf: parse with regular expressions + - perf: remove argument reassignment * deps: connect@2.30.0 - deps: body-parser@~1.13.1 - deps: bytes@2.1.0 diff --git a/package.json b/package.json index 123a2c5ee64..7ce2bfc0c3e 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "api" ], "dependencies": { - "basic-auth": "1.0.0", + "basic-auth": "1.0.2", "connect": "2.30.0", "content-disposition": "0.5.0", "content-type": "~1.0.1", From 77402110b9402a6d327e232cc1518bc5110e651c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:35:56 -0400 Subject: [PATCH 0837/1265] deps: cookie@0.1.3 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e681d5d75b1..3d09788d390 100644 --- a/History.md +++ b/History.md @@ -22,6 +22,9 @@ - deps: serve-index@~1.7.0 - deps: serve-static@~1.10.0 - deps: type-is@~1.6.3 + * deps: cookie@0.1.3 + - perf: deduce the scope of try-catch deopt + - perf: remove argument reassignments * deps: mkdirp@0.5.1 - Work in global strict mode diff --git a/package.json b/package.json index 7ce2bfc0c3e..80e444a6749 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "content-disposition": "0.5.0", "content-type": "~1.0.1", "commander": "2.6.0", - "cookie": "0.1.2", + "cookie": "0.1.3", "cookie-signature": "1.0.6", "debug": "~2.2.0", "depd": "~1.0.1", From 0fbf2078e16cd315fd1b1769c430488f70e7faba Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:36:48 -0400 Subject: [PATCH 0838/1265] deps: escape-html@1.0.2 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3d09788d390..a533c2415db 100644 --- a/History.md +++ b/History.md @@ -25,6 +25,7 @@ * deps: cookie@0.1.3 - perf: deduce the scope of try-catch deopt - perf: remove argument reassignments + * deps: escape-html@1.0.2 * deps: mkdirp@0.5.1 - Work in global strict mode diff --git a/package.json b/package.json index 80e444a6749..a771f9f42f4 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "cookie-signature": "1.0.6", "debug": "~2.2.0", "depd": "~1.0.1", - "escape-html": "1.0.1", + "escape-html": "1.0.2", "etag": "~1.5.1", "fresh": "0.2.4", "merge-descriptors": "1.0.0", From c8d61b62693948568083d5ad3c4491e5cc6f5338 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:54:26 -0400 Subject: [PATCH 0839/1265] deps: etag@~1.7.0 fixes #2667 --- History.md | 8 ++++++++ package.json | 2 +- test/res.send.js | 18 +++++++++--------- test/utils.js | 16 ++++++++-------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/History.md b/History.md index a533c2415db..6ed7c762c23 100644 --- a/History.md +++ b/History.md @@ -26,6 +26,14 @@ - perf: deduce the scope of try-catch deopt - perf: remove argument reassignments * deps: escape-html@1.0.2 + * deps: etag@~1.7.0 + - Always include entity length in ETags for hash length extensions + - Generate non-Stats ETags using MD5 only (no longer CRC32) + - Improve stat performance by removing hashing + - Improve support for JXcore + - Remove base64 padding in ETags to shorten + - Support "fake" stats objects in environments without fs + - Use MD5 instead of MD4 in weak ETags over 1KB * deps: mkdirp@0.5.1 - Work in global strict mode diff --git a/package.json b/package.json index a771f9f42f4..f3d51791a9d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "debug": "~2.2.0", "depd": "~1.0.1", "escape-html": "1.0.2", - "etag": "~1.5.1", + "etag": "~1.7.0", "fresh": "0.2.4", "merge-descriptors": "1.0.0", "methods": "~1.1.1", diff --git a/test/res.send.js b/test/res.send.js index 9ad8fd88fee..67f872285c5 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -121,7 +121,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') + .expect('ETag', 'W/"7ff-fFD7Se+Vsq6deAl063thow"') .expect(200, done); }) @@ -193,7 +193,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') + .expect('ETag', 'W/"7ff-fFD7Se+Vsq6deAl063thow"') .expect(200, done); }) @@ -309,7 +309,7 @@ describe('res', function(){ request(app) .get('/') - .set('If-None-Match', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') + .set('If-None-Match', 'W/"7ff-fFD7Se+Vsq6deAl063thow"') .expect(304, done); }) @@ -355,7 +355,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"c-5aee35d8"') + .expect('ETag', 'W/"c-ZUfd0NJ26qwjlKF4r8qb2g"') .expect(200, done); }); @@ -371,7 +371,7 @@ describe('res', function(){ request(app) [method]('/') - .expect('ETag', 'W/"c-5aee35d8"') + .expect('ETag', 'W/"c-ZUfd0NJ26qwjlKF4r8qb2g"') .expect(200, done); }) }); @@ -387,7 +387,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"0-0"') + .expect('ETag', 'W/"0-1B2M2Y8AsgTpgAmY7PhCfg"') .expect(200, done); }) @@ -403,7 +403,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"fz/jGo0ONwzb+aKy/rWipg=="') + .expect('ETag', 'W/"7ff-fFD7Se+Vsq6deAl063thow"') .expect(200, done); }); @@ -485,7 +485,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', '"Otu60XkfuuPskIiUxJY4cA=="') + .expect('ETag', '"d-Otu60XkfuuPskIiUxJY4cA"') .expect(200, done); }) }) @@ -502,7 +502,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"d-58988d13"') + .expect('ETag', 'W/"d-Otu60XkfuuPskIiUxJY4cA"') .expect(200, done) }) }) diff --git a/test/utils.js b/test/utils.js index b811762c591..750c84605f3 100644 --- a/test/utils.js +++ b/test/utils.js @@ -5,46 +5,46 @@ var utils = require('../lib/utils') describe('utils.etag(body, encoding)', function(){ it('should support strings', function(){ utils.etag('express!') - .should.eql('"zZdv4imtWD49AHEviejT6A=="') + .should.eql('"8-zZdv4imtWD49AHEviejT6A"') }) it('should support utf8 strings', function(){ utils.etag('express❤', 'utf8') - .should.eql('"fsFba4IxwQS6h6Umb+FNxw=="') + .should.eql('"a-fsFba4IxwQS6h6Umb+FNxw"') }) it('should support buffer', function(){ var buf = new Buffer('express!') utils.etag(buf) - .should.eql('"zZdv4imtWD49AHEviejT6A=="'); + .should.eql('"8-zZdv4imtWD49AHEviejT6A"'); }) it('should support empty string', function(){ utils.etag('') - .should.eql('"1B2M2Y8AsgTpgAmY7PhCfg=="'); + .should.eql('"0-1B2M2Y8AsgTpgAmY7PhCfg"'); }) }) describe('utils.wetag(body, encoding)', function(){ it('should support strings', function(){ utils.wetag('express!') - .should.eql('W/"8-b8aabac7"') + .should.eql('W/"8-zZdv4imtWD49AHEviejT6A"') }) it('should support utf8 strings', function(){ utils.wetag('express❤', 'utf8') - .should.eql('W/"a-686b0af1"') + .should.eql('W/"a-fsFba4IxwQS6h6Umb+FNxw"') }) it('should support buffer', function(){ var buf = new Buffer('express!') utils.wetag(buf) - .should.eql('W/"8-b8aabac7"'); + .should.eql('W/"8-zZdv4imtWD49AHEviejT6A"'); }) it('should support empty string', function(){ utils.wetag('') - .should.eql('W/"0-0"'); + .should.eql('W/"0-1B2M2Y8AsgTpgAmY7PhCfg"'); }) }) From 14b849246e9b72eb61dd9118b0409ca49d50f55e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:56:03 -0400 Subject: [PATCH 0840/1265] deps: send@0.13.0 --- History.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6ed7c762c23..6c3684d8942 100644 --- a/History.md +++ b/History.md @@ -36,6 +36,19 @@ - Use MD5 instead of MD4 in weak ETags over 1KB * deps: mkdirp@0.5.1 - Work in global strict mode + * deps: send@0.13.0 + - Allow Node.js HTTP server to set `Date` response header + - Fix incorrectly removing `Content-Location` on 304 response + - Improve the default redirect response headers + - Send appropriate headers on default error response + - Use `http-errors` for standard emitted errors + - Use `statuses` instead of `http` module for status messages + - deps: escape-html@1.0.2 + - deps: etag@~1.7.0 + - deps: fresh@0.3.0 + - deps: on-finished@~2.3.0 + - perf: enable strict mode + - perf: remove unnecessary array allocations 3.20.3 / 2015-05-17 =================== diff --git a/package.json b/package.json index f3d51791a9d..a36a43c3824 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "parseurl": "~1.3.0", "proxy-addr": "~1.0.8", "range-parser": "~1.0.2", - "send": "0.12.3", + "send": "0.13.0", "utils-merge": "1.0.0", "vary": "~1.0.0" }, From 4729685912b8d69c53739b04a2f3477b67dcc602 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 20:56:48 -0400 Subject: [PATCH 0841/1265] deps: fresh@0.3.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6c3684d8942..dbe149cddd5 100644 --- a/History.md +++ b/History.md @@ -34,6 +34,8 @@ - Remove base64 padding in ETags to shorten - Support "fake" stats objects in environments without fs - Use MD5 instead of MD4 in weak ETags over 1KB + * deps: fresh@0.3.0 + - Add weak `ETag` matching support * deps: mkdirp@0.5.1 - Work in global strict mode * deps: send@0.13.0 diff --git a/package.json b/package.json index a36a43c3824..7b077c9b9ad 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "depd": "~1.0.1", "escape-html": "1.0.2", "etag": "~1.7.0", - "fresh": "0.2.4", + "fresh": "0.3.0", "merge-descriptors": "1.0.0", "methods": "~1.1.1", "mkdirp": "0.5.1", From 115dbe1a4d817d925d2dc87731a7ceb1663152ed Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 21:14:56 -0400 Subject: [PATCH 0842/1265] 3.21.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index dbe149cddd5..bb06bdb6f42 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.21.0 / 2015-06-18 +=================== * deps: basic-auth@1.0.2 - perf: enable strict mode diff --git a/package.json b/package.json index 7b077c9b9ad..e8d2f00395f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.20.3", + "version": "3.21.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 4b70375d2280e3b9a0d69e2d57e7e7a609fec206 Mon Sep 17 00:00:00 2001 From: Phat Date: Sun, 22 Mar 2015 19:21:48 +0700 Subject: [PATCH 0843/1265] docs: update res.set jsdoc closes #2600 --- lib/response.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/response.js b/lib/response.js index b759eb95e42..1874300c514 100644 --- a/lib/response.js +++ b/lib/response.js @@ -682,8 +682,8 @@ res.append = function append(field, val) { * * Aliased as `res.header()`. * - * @param {String|Object|Array} field - * @param {String} val + * @param {String|Object} field + * @param {String|Array} val * @return {ServerResponse} for chaining * @api public */ From fce3d14b5ce51e75a1636ac4ebc251c4017e038b Mon Sep 17 00:00:00 2001 From: Alexander Marenin Date: Thu, 28 May 2015 18:09:05 +0300 Subject: [PATCH 0844/1265] docs: update return types for req.accept*() closes #2663 --- lib/request.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/request.js b/lib/request.js index e52dfe554e9..99964925572 100644 --- a/lib/request.js +++ b/lib/request.js @@ -98,7 +98,7 @@ req.header = function(name){ * // => "json" * * @param {String|Array} type(s) - * @return {String} + * @return {String|Array|Boolean} * @api public */ @@ -111,7 +111,7 @@ req.accepts = function(){ * Check if the given `encoding`s are accepted. * * @param {String} ...encoding - * @return {Boolean} + * @return {String|Array} * @api public */ @@ -128,7 +128,7 @@ req.acceptsEncoding = deprecate.function(req.acceptsEncodings, * otherwise you should respond with 406 "Not Acceptable". * * @param {String} ...charset - * @return {Boolean} + * @return {String|Array} * @api public */ @@ -145,7 +145,7 @@ req.acceptsCharset = deprecate.function(req.acceptsCharsets, * otherwise you should respond with 406 "Not Acceptable". * * @param {String} ...lang - * @return {Boolean} + * @return {String|Array} * @api public */ From 8da51e3acc0520f67daa92309e294a72a6256726 Mon Sep 17 00:00:00 2001 From: Radu Dan Date: Tue, 19 May 2015 22:37:06 +0300 Subject: [PATCH 0845/1265] Fix issue where next('route') in app.param would incorrectly skip values fixes #2655 --- History.md | 1 + lib/router/index.js | 3 ++- test/app.param.js | 60 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0f57672d34e..06c2c2be323 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix issue where `next('route')` in `app.param` would incorrectly skip values * deps: cookie@0.1.3 - perf: deduce the scope of try-catch deopt - perf: remove argument reassignments diff --git a/lib/router/index.js b/lib/router/index.js index 209f881b1eb..a20c592f075 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -357,7 +357,8 @@ proto.process_params = function(layer, called, req, res, done) { } // param previously called with same value or error occurred - if (paramCalled && (paramCalled.error || paramCalled.match === paramVal)) { + if (paramCalled && (paramCalled.match === paramVal + || (paramCalled.error && paramCalled.error !== 'route'))) { // restore value req.params[name] = paramCalled.value; diff --git a/test/app.param.js b/test/app.param.js index 858ea2d5f6a..30885bcdc89 100644 --- a/test/app.param.js +++ b/test/app.param.js @@ -303,5 +303,65 @@ describe('app', function(){ .get('/user/new') .expect('get.new', done); }) + + it('should not call when values differ on error', function(done) { + var app = express(); + var called = 0; + var count = 0; + + app.param('user', function(req, res, next, user) { + called++; + if (user === 'foo') throw new Error('err!'); + req.user = user; + next(); + }); + + app.get('/:user/bob', function(req, res, next) { + count++; + next(); + }); + app.get('/foo/:user', function(req, res, next) { + count++; + next(); + }); + + app.use(function(err, req, res, next) { + res.status(500); + res.send([count, called, err.message].join(' ')); + }); + + request(app) + .get('/foo/bob') + .expect(500, '0 1 err!', done) + }); + + it('should call when values differ when using "next"', function(done) { + var app = express(); + var called = 0; + var count = 0; + + app.param('user', function(req, res, next, user) { + called++; + if (user === 'foo') return next('route'); + req.user = user; + next(); + }); + + app.get('/:user/bob', function(req, res, next) { + count++; + next(); + }); + app.get('/foo/:user', function(req, res, next) { + count++; + next(); + }); + app.use(function(req, res) { + res.end([count, called, req.user].join(' ')); + }); + + request(app) + .get('/foo/bob') + .expect('1 2 bob', done); + }) }) }) From f7e94a30bce66ba4de1b6388910bfdd8b1e6edd1 Mon Sep 17 00:00:00 2001 From: Deepak Kapoor Date: Wed, 22 Apr 2015 17:36:55 +1000 Subject: [PATCH 0846/1265] Use array-flatten module for flattening arrays closes #2624 --- History.md | 1 + lib/application.js | 2 +- lib/router/index.js | 4 ++-- lib/router/route.js | 6 +++--- lib/utils.js | 15 +++------------ package.json | 1 + 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/History.md b/History.md index 06c2c2be323..de6a68f0ca8 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Fix issue where `next('route')` in `app.param` would incorrectly skip values + * Use `array-flatten` module for flattening arrays * deps: cookie@0.1.3 - perf: deduce the scope of try-catch deopt - perf: remove argument reassignments diff --git a/lib/application.js b/lib/application.js index 5ec44248cad..fe386d7b368 100644 --- a/lib/application.js +++ b/lib/application.js @@ -12,7 +12,6 @@ */ var finalhandler = require('finalhandler'); -var flatten = require('./utils').flatten; var Router = require('./router'); var methods = require('methods'); var middleware = require('./middleware/init'); @@ -24,6 +23,7 @@ var compileETag = require('./utils').compileETag; var compileQueryParser = require('./utils').compileQueryParser; var compileTrust = require('./utils').compileTrust; var deprecate = require('depd')('express'); +var flatten = require('array-flatten'); var merge = require('utils-merge'); var resolve = require('path').resolve; var slice = Array.prototype.slice; diff --git a/lib/router/index.js b/lib/router/index.js index a20c592f075..d0989da2090 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -9,8 +9,8 @@ var methods = require('methods'); var mixin = require('utils-merge'); var debug = require('debug')('express:router'); var deprecate = require('depd')('express'); +var flatten = require('array-flatten'); var parseUrl = require('parseurl'); -var utils = require('../utils'); /** * Module variables. @@ -436,7 +436,7 @@ proto.use = function use(fn) { } } - var callbacks = utils.flatten(slice.call(arguments, offset)); + var callbacks = flatten(slice.call(arguments, offset)); if (callbacks.length === 0) { throw new TypeError('Router.use() requires middleware functions'); diff --git a/lib/router/route.js b/lib/router/route.js index 6213b821704..d3ef53bc176 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -3,9 +3,9 @@ */ var debug = require('debug')('express:router:route'); +var flatten = require('array-flatten'); var Layer = require('./layer'); var methods = require('methods'); -var utils = require('../utils'); /** * Expose `Route`. @@ -141,7 +141,7 @@ Route.prototype.dispatch = function(req, res, done){ */ Route.prototype.all = function(){ - var callbacks = utils.flatten([].slice.call(arguments)); + var callbacks = flatten([].slice.call(arguments)); callbacks.forEach(function(fn) { if (typeof fn !== 'function') { var type = {}.toString.call(fn); @@ -161,7 +161,7 @@ Route.prototype.all = function(){ methods.forEach(function(method){ Route.prototype[method] = function(){ - var callbacks = utils.flatten([].slice.call(arguments)); + var callbacks = flatten([].slice.call(arguments)); callbacks.forEach(function(fn) { if (typeof fn !== 'function') { diff --git a/lib/utils.js b/lib/utils.js index ce53ad8b99b..42ea76acde6 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -13,6 +13,7 @@ var contentDisposition = require('content-disposition'); var contentType = require('content-type'); var deprecate = require('depd')('express'); +var flatten = require('array-flatten'); var mime = require('send').mime; var basename = require('path').basename; var etag = require('etag'); @@ -76,18 +77,8 @@ exports.isAbsolute = function(path){ * @api private */ -exports.flatten = function(arr, ret){ - ret = ret || []; - var len = arr.length; - for (var i = 0; i < len; ++i) { - if (Array.isArray(arr[i])) { - exports.flatten(arr[i], ret); - } else { - ret.push(arr[i]); - } - } - return ret; -}; +exports.flatten = deprecate.function(flatten, + 'utils.flatten: use array-flatten npm module instead'); /** * Normalize the given `type`, for example "html" becomes "text/html". diff --git a/package.json b/package.json index 74efb91cc06..e14953f13b9 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ ], "dependencies": { "accepts": "~1.2.7", + "array-flatten": "1.1.0", "content-disposition": "0.5.0", "content-type": "~1.0.1", "cookie": "0.1.3", From b5f98ab3b3861161a92fee7f64a22cbb04f85ba9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 22:26:48 -0400 Subject: [PATCH 0847/1265] deps: serve-static@~1.10.0 --- History.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index de6a68f0ca8..1acab96b1ef 100644 --- a/History.md +++ b/History.md @@ -30,6 +30,15 @@ unreleased - deps: on-finished@~2.3.0 - perf: enable strict mode - perf: remove unnecessary array allocations + * deps: serve-static@~1.10.0 + - Add `fallthrough` option + - Fix reading options from options prototype + - Improve the default redirect response headers + - Malformed URLs now `next()` instead of 400 + - deps: escape-html@1.0.2 + - deps: send@0.13.0 + - perf: enable strict mode + - perf: remove argument reassignment 4.12.4 / 2015-05-17 =================== diff --git a/package.json b/package.json index e14953f13b9..2e3fa5be1ed 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "qs": "2.4.2", "range-parser": "~1.0.2", "send": "0.13.0", - "serve-static": "~1.9.3", + "serve-static": "~1.10.0", "type-is": "~1.6.2", "vary": "~1.0.0", "utils-merge": "1.0.0" From 7b7aaf0bf3c8a245c7e9a0ac91af314adba4ea1d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 22:39:57 -0400 Subject: [PATCH 0848/1265] deps: finalhandler@0.4.0 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1acab96b1ef..2f41a60a81b 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,14 @@ unreleased - Remove base64 padding in ETags to shorten - Support "fake" stats objects in environments without fs - Use MD5 instead of MD4 in weak ETags over 1KB + * deps: finalhandler@0.4.0 + - Fix a false-positive when unpiping in Node.js 0.8 + - Support `statusCode` property on `Error` objects + - Use `unpipe` module for unpiping requests + - deps: escape-html@1.0.2 + - deps: on-finished@~2.3.0 + - perf: enable strict mode + - perf: remove argument reassignment * deps: fresh@0.3.0 - Add weak `ETag` matching support * deps: send@0.13.0 diff --git a/package.json b/package.json index 2e3fa5be1ed..a2e66089bcf 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "depd": "~1.0.1", "escape-html": "1.0.2", "etag": "~1.7.0", - "finalhandler": "0.3.6", + "finalhandler": "0.4.0", "fresh": "0.3.0", "merge-descriptors": "1.0.0", "methods": "~1.1.1", From 8ad7e8f5e143768ef62adbde899e5b9099185f52 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 22:41:28 -0400 Subject: [PATCH 0849/1265] deps: on-finished@~2.3.0 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2f41a60a81b..65de61f8729 100644 --- a/History.md +++ b/History.md @@ -25,6 +25,10 @@ unreleased - perf: remove argument reassignment * deps: fresh@0.3.0 - Add weak `ETag` matching support + * deps: on-finished@~2.3.0 + - Add defined behavior for HTTP `CONNECT` requests + - Add defined behavior for HTTP `Upgrade` requests + - deps: ee-first@1.1.1 * deps: send@0.13.0 - Allow Node.js HTTP server to set `Date` response header - Fix incorrectly removing `Content-Location` on 304 response diff --git a/package.json b/package.json index a2e66089bcf..19cf6ad615a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "fresh": "0.3.0", "merge-descriptors": "1.0.0", "methods": "~1.1.1", - "on-finished": "~2.2.1", + "on-finished": "~2.3.0", "parseurl": "~1.3.0", "path-to-regexp": "0.1.3", "proxy-addr": "~1.0.8", From 7b86a0ec98690784f196efa6ca5ba1ccf4c9e10f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 22:42:19 -0400 Subject: [PATCH 0850/1265] deps: type-is@~1.6.3 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 65de61f8729..9a0f49ac0fd 100644 --- a/History.md +++ b/History.md @@ -51,6 +51,10 @@ unreleased - deps: send@0.13.0 - perf: enable strict mode - perf: remove argument reassignment + * deps: type-is@~1.6.3 + - deps: mime-types@~2.1.1 + - perf: reduce try block size + - perf: remove bitwise operations 4.12.4 / 2015-05-17 =================== diff --git a/package.json b/package.json index 19cf6ad615a..43376f4a817 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "range-parser": "~1.0.2", "send": "0.13.0", "serve-static": "~1.10.0", - "type-is": "~1.6.2", + "type-is": "~1.6.3", "vary": "~1.0.0", "utils-merge": "1.0.0" }, From 4212efad74aa002d0e722b80c66f058b6b2b3969 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 22:43:51 -0400 Subject: [PATCH 0851/1265] deps: accepts@~1.2.9 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9a0f49ac0fd..0db529dcfd5 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,12 @@ unreleased * Fix issue where `next('route')` in `app.param` would incorrectly skip values * Use `array-flatten` module for flattening arrays + * deps: accepts@~1.2.9 + - deps: mime-types@~2.1.1 + - perf: avoid argument reassignment & argument slice + - perf: avoid negotiator recursive construction + - perf: enable strict mode + - perf: remove unnecessary bitwise operator * deps: cookie@0.1.3 - perf: deduce the scope of try-catch deopt - perf: remove argument reassignments diff --git a/package.json b/package.json index 43376f4a817..e5a66451b4c 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.7", + "accepts": "~1.2.9", "array-flatten": "1.1.0", "content-disposition": "0.5.0", "content-type": "~1.0.1", From 9073bb4fbc7e5b4b53d00696a3cda0678502379a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 22:45:33 -0400 Subject: [PATCH 0852/1265] deps: update example dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e5a66451b4c..0d1858911e5 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,14 @@ "mocha": "2.2.5", "should": "7.0.1", "supertest": "1.0.1", - "body-parser": "~1.12.4", + "body-parser": "~1.13.1", "connect-redis": "~2.3.0", - "cookie-parser": "~1.3.4", + "cookie-parser": "~1.3.5", "cookie-session": "~1.1.0", - "express-session": "~1.11.2", - "jade": "~1.9.2", + "express-session": "~1.11.3", + "jade": "~1.11.0", "method-override": "~2.3.3", - "morgan": "~1.5.3", + "morgan": "~1.6.0", "multiparty": "~4.1.2", "vhost": "~3.0.0" }, From 91731b4b9ce23fe4bb702f341d0a46d78c8ccdbf Mon Sep 17 00:00:00 2001 From: Thomas Cort Date: Mon, 23 Mar 2015 07:31:21 -0400 Subject: [PATCH 0853/1265] perf: use saved reference to http.STATUS_CODES closes #2602 --- History.md | 1 + lib/response.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 0db529dcfd5..d33981cdf8f 100644 --- a/History.md +++ b/History.md @@ -61,6 +61,7 @@ unreleased - deps: mime-types@~2.1.1 - perf: reduce try block size - perf: remove bitwise operations + * perf: use saved reference to `http.STATUS_CODES` 4.12.4 / 2015-05-17 =================== diff --git a/lib/response.js b/lib/response.js index 1874300c514..8a976217a24 100644 --- a/lib/response.js +++ b/lib/response.js @@ -119,7 +119,7 @@ res.send = function send(body) { deprecate('res.send(status): Use res.sendStatus(status) instead'); this.statusCode = chunk; - chunk = http.STATUS_CODES[chunk]; + chunk = statusCodes[chunk]; } switch (typeof chunk) { @@ -324,7 +324,7 @@ res.jsonp = function jsonp(obj) { */ res.sendStatus = function sendStatus(statusCode) { - var body = http.STATUS_CODES[statusCode] || String(statusCode); + var body = statusCodes[statusCode] || String(statusCode); this.statusCode = statusCode; this.type('txt'); From 95ad276cad3369bf5f7253d0110a6e04425bd32a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 23:00:20 -0400 Subject: [PATCH 0854/1265] docs: add license comments --- index.js | 7 +++++++ lib/express.js | 8 ++++++++ lib/middleware/init.js | 8 ++++++++ lib/middleware/query.js | 8 ++++++++ lib/request.js | 8 ++++++++ lib/router/index.js | 7 +++++++ lib/router/layer.js | 8 ++++++++ lib/router/route.js | 8 ++++++++ lib/view.js | 8 ++++++++ 9 files changed, 70 insertions(+) diff --git a/index.js b/index.js index 3da33783794..e6cf8225c2e 100644 --- a/index.js +++ b/index.js @@ -1,2 +1,9 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ module.exports = require('./lib/express'); diff --git a/lib/express.js b/lib/express.js index bb8d8082a49..0d06c8205d7 100644 --- a/lib/express.js +++ b/lib/express.js @@ -1,3 +1,11 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. */ diff --git a/lib/middleware/init.js b/lib/middleware/init.js index 1e3e903f04f..0c3644da1b9 100644 --- a/lib/middleware/init.js +++ b/lib/middleware/init.js @@ -1,3 +1,11 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Initialization middleware, exposing the * request and response to each other, as well diff --git a/lib/middleware/query.js b/lib/middleware/query.js index 092bbd9985d..80d65859e98 100644 --- a/lib/middleware/query.js +++ b/lib/middleware/query.js @@ -1,3 +1,11 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. */ diff --git a/lib/request.js b/lib/request.js index 99964925572..4d756deb900 100644 --- a/lib/request.js +++ b/lib/request.js @@ -1,3 +1,11 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. */ diff --git a/lib/router/index.js b/lib/router/index.js index d0989da2090..d79a1eb4ce3 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -1,3 +1,10 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ /** * Module dependencies. diff --git a/lib/router/layer.js b/lib/router/layer.js index 88ebd3964c2..cc8a1f2c7b4 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -1,3 +1,11 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. */ diff --git a/lib/router/route.js b/lib/router/route.js index d3ef53bc176..adb833cef96 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -1,3 +1,11 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. */ diff --git a/lib/view.js b/lib/view.js index e0989b4ddac..acde752ebbd 100644 --- a/lib/view.js +++ b/lib/view.js @@ -1,3 +1,11 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + /** * Module dependencies. */ From e71014f522fb8db9ba1ef634f2e9f2c8069e4b6c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 23:01:18 -0400 Subject: [PATCH 0855/1265] perf: enable strict mode --- History.md | 1 + index.js | 2 ++ lib/application.js | 2 ++ lib/express.js | 2 ++ lib/middleware/init.js | 2 ++ lib/middleware/query.js | 2 ++ lib/request.js | 2 ++ lib/response.js | 2 ++ lib/router/index.js | 2 ++ lib/router/layer.js | 2 ++ lib/router/route.js | 2 ++ lib/utils.js | 2 ++ lib/view.js | 2 ++ 13 files changed, 25 insertions(+) diff --git a/History.md b/History.md index d33981cdf8f..f36c515619f 100644 --- a/History.md +++ b/History.md @@ -61,6 +61,7 @@ unreleased - deps: mime-types@~2.1.1 - perf: reduce try block size - perf: remove bitwise operations + * perf: enable strict mode * perf: use saved reference to `http.STATUS_CODES` 4.12.4 / 2015-05-17 diff --git a/index.js b/index.js index e6cf8225c2e..d219b0c878d 100644 --- a/index.js +++ b/index.js @@ -6,4 +6,6 @@ * MIT Licensed */ +'use strict'; + module.exports = require('./lib/express'); diff --git a/lib/application.js b/lib/application.js index fe386d7b368..b31c88b7b05 100644 --- a/lib/application.js +++ b/lib/application.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. * @api private diff --git a/lib/express.js b/lib/express.js index 0d06c8205d7..540c8be6f41 100644 --- a/lib/express.js +++ b/lib/express.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. */ diff --git a/lib/middleware/init.js b/lib/middleware/init.js index 0c3644da1b9..f3119ed3a15 100644 --- a/lib/middleware/init.js +++ b/lib/middleware/init.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Initialization middleware, exposing the * request and response to each other, as well diff --git a/lib/middleware/query.js b/lib/middleware/query.js index 80d65859e98..d86474a05a5 100644 --- a/lib/middleware/query.js +++ b/lib/middleware/query.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. */ diff --git a/lib/request.js b/lib/request.js index 4d756deb900..962f48d094d 100644 --- a/lib/request.js +++ b/lib/request.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. */ diff --git a/lib/response.js b/lib/response.js index 8a976217a24..50b0579b57e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -5,6 +5,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. * @api private diff --git a/lib/router/index.js b/lib/router/index.js index d79a1eb4ce3..8786dc15d3e 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. */ diff --git a/lib/router/layer.js b/lib/router/layer.js index cc8a1f2c7b4..4747f70bea4 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. */ diff --git a/lib/router/route.js b/lib/router/route.js index adb833cef96..dadd2c7b6d4 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. */ diff --git a/lib/utils.js b/lib/utils.js index 42ea76acde6..d10391c43d9 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -5,6 +5,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. * @api private diff --git a/lib/view.js b/lib/view.js index acde752ebbd..072422180c6 100644 --- a/lib/view.js +++ b/lib/view.js @@ -6,6 +6,8 @@ * MIT Licensed */ +'use strict'; + /** * Module dependencies. */ From 24d1c98c0ae4cc5dfd79bfff5d536a95034f7569 Mon Sep 17 00:00:00 2001 From: Behcet Uyar Date: Fri, 29 May 2015 17:13:15 -0400 Subject: [PATCH 0856/1265] Fix res.format error when only default provided fixes #2665 --- History.md | 1 + lib/response.js | 4 +++- test/res.format.js | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f36c515619f..7c33d28450f 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix `res.format` error when only `default` provided * Fix issue where `next('route')` in `app.param` would incorrectly skip values * Use `array-flatten` module for flattening arrays * deps: accepts@~1.2.9 diff --git a/lib/response.js b/lib/response.js index 50b0579b57e..5334515eeb4 100644 --- a/lib/response.js +++ b/lib/response.js @@ -606,7 +606,9 @@ res.format = function(obj){ if (fn) delete obj.default; var keys = Object.keys(obj); - var key = req.accepts(keys); + var key = keys.length > 0 + ? req.accepts(keys) + : false; this.vary("Accept"); diff --git a/test/res.format.js b/test/res.format.js index 28534a199a1..2b0dfd517e7 100644 --- a/test/res.format.js +++ b/test/res.format.js @@ -67,6 +67,14 @@ app4.use(function(err, req, res, next){ res.send(err.status, 'Supports: ' + err.types.join(', ')); }) +var app5 = express(); + +app5.use(function (req, res, next) { + res.format({ + default: function () { res.send('hey') } + }); +}); + describe('res', function(){ describe('.format(obj)', function(){ describe('with canonicalized mime types', function(){ @@ -102,6 +110,13 @@ describe('res', function(){ .set('Accept', 'text/html') .expect('default', done); }) + + it('should work when only .default is provided', function (done) { + request(app5) + .get('/') + .set('Accept', '*/*') + .expect('hey', done); + }) }) describe('in router', function(){ From e66bb4f328c80540ba1b66ec4b8275d1a43941b5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Jun 2015 23:15:13 -0400 Subject: [PATCH 0857/1265] deps: path-to-regexp@0.1.4 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7c33d28450f..4db593509e8 100644 --- a/History.md +++ b/History.md @@ -36,6 +36,7 @@ unreleased - Add defined behavior for HTTP `CONNECT` requests - Add defined behavior for HTTP `Upgrade` requests - deps: ee-first@1.1.1 + * deps: path-to-regexp@0.1.4 * deps: send@0.13.0 - Allow Node.js HTTP server to set `Date` response header - Fix incorrectly removing `Content-Location` on 304 response diff --git a/package.json b/package.json index 0d1858911e5..ba69a020565 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "methods": "~1.1.1", "on-finished": "~2.3.0", "parseurl": "~1.3.0", - "path-to-regexp": "0.1.3", + "path-to-regexp": "0.1.4", "proxy-addr": "~1.0.8", "qs": "2.4.2", "range-parser": "~1.0.2", From 60e2008dee01a90551623371da939de41c05422e Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Fri, 19 Jun 2015 22:13:57 +1000 Subject: [PATCH 0858/1265] deps: path-to-regexp@0.1.6 fixes #2491 fixes #2617 closes #2637 closes #2683 --- History.md | 4 +++- lib/router/layer.js | 16 +++++----------- package.json | 2 +- test/app.router.js | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/History.md b/History.md index 4db593509e8..c6b3cf81f8f 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,8 @@ unreleased * Fix `res.format` error when only `default` provided * Fix issue where `next('route')` in `app.param` would incorrectly skip values + * Fix using `*` before params in routes + * Fix using capture groups before params in routes * Use `array-flatten` module for flattening arrays * deps: accepts@~1.2.9 - deps: mime-types@~2.1.1 @@ -36,7 +38,7 @@ unreleased - Add defined behavior for HTTP `CONNECT` requests - Add defined behavior for HTTP `Upgrade` requests - deps: ee-first@1.1.1 - * deps: path-to-regexp@0.1.4 + * deps: path-to-regexp@0.1.6 * deps: send@0.13.0 - Allow Node.js HTTP server to set `Date` response header - Fix incorrectly removing `Content-Location` on 304 response diff --git a/lib/router/layer.js b/lib/router/layer.js index 4747f70bea4..b5c1f58958b 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -133,17 +133,11 @@ Layer.prototype.match = function match(path) { var keys = this.keys; var params = this.params; - var prop; - var n = 0; - var key; - var val; - - for (var i = 1, len = m.length; i < len; ++i) { - key = keys[i - 1]; - prop = key - ? key.name - : n++; - val = decode_param(m[i]); + + for (var i = 1; i < m.length; i++) { + var key = keys[i - 1]; + var prop = key.name; + var val = decode_param(m[i]); if (val !== undefined || !(hasOwnProperty.call(params, prop))) { params[prop] = val; diff --git a/package.json b/package.json index ba69a020565..95a4a472f87 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "methods": "~1.1.1", "on-finished": "~2.3.0", "parseurl": "~1.3.0", - "path-to-regexp": "0.1.4", + "path-to-regexp": "0.1.6", "proxy-addr": "~1.0.8", "qs": "2.4.2", "range-parser": "~1.0.2", diff --git a/test/app.router.js b/test/app.router.js index def50da34fb..491de358f07 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -641,6 +641,30 @@ describe('app.router', function(){ .get('/file') .expect(404, done); }) + + it('should keep correct parameter indexes', function(done){ + var app = express(); + + app.get('/*/user/:id', function (req, res) { + res.send(req.params); + }); + + request(app) + .get('/1/user/2') + .expect(200, '{"0":"1","id":"2"}', done); + }) + + it('should work within arrays', function(done){ + var app = express(); + + app.get(['/user/:id', '/foo/*', '/:bar'], function (req, res) { + res.send(req.params.bar); + }); + + request(app) + .get('/test') + .expect(200, 'test', done); + }) }) describe(':name', function(){ @@ -680,6 +704,23 @@ describe('app.router', function(){ .expect('editing tj', done); }) + it('should work following a partial capture group', function(done){ + var app = express(); + var cb = after(2, done); + + app.get('/user(s)?/:user/:op', function(req, res){ + res.end(req.params.op + 'ing ' + req.params.user + (req.params[0] ? ' (old)' : '')); + }); + + request(app) + .get('/user/tj/edit') + .expect('editing tj', cb); + + request(app) + .get('/users/tj/edit') + .expect('editing tj (old)', cb); + }) + it('should work in array of paths', function(done){ var app = express(); var cb = after(2, done); From 0634e7e189a0ea12261b8fa81c7ca7234994b26d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 12:54:52 -0400 Subject: [PATCH 0859/1265] tests: add test for rendering extensionless file without view engine --- test/res.render.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/res.render.js b/test/res.render.js index a843b2af159..d4d2a7616d1 100644 --- a/test/res.render.js +++ b/test/res.render.js @@ -34,6 +34,20 @@ describe('res', function(){ .expect('

tobi

', done); }) + it('should error without "view engine" set and no file extension', function (done) { + var app = createApp(); + + app.locals.user = { name: 'tobi' }; + + app.use(function(req, res){ + res.render(__dirname + '/fixtures/user'); + }); + + request(app) + .get('/') + .expect(500, /No default engine was specified/, done); + }) + it('should expose app.locals', function(done){ var app = createApp(); From a8a8564459688bdc0b2653da2f28a4fefde7dfdb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 13:06:08 -0400 Subject: [PATCH 0860/1265] perf: remove argument reassignments in View --- History.md | 1 + lib/view.js | 73 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/History.md b/History.md index c6b3cf81f8f..c1cef158219 100644 --- a/History.md +++ b/History.md @@ -66,6 +66,7 @@ unreleased - perf: reduce try block size - perf: remove bitwise operations * perf: enable strict mode + * perf: remove argument reassignments in `View` * perf: use saved reference to `http.STATUS_CODES` 4.12.4 / 2015-05-17 diff --git a/lib/view.js b/lib/view.js index 072422180c6..52415d4c28b 100644 --- a/lib/view.js +++ b/lib/view.js @@ -10,6 +10,7 @@ /** * Module dependencies. + * @private */ var debug = require('debug')('express:view'); @@ -29,7 +30,8 @@ var join = path.join; var resolve = path.resolve; /** - * Expose `View`. + * Module exports. + * @public */ module.exports = View; @@ -43,30 +45,51 @@ module.exports = View; * - `engines` template engine require() cache * - `root` root path for view lookup * - * @param {String} name - * @param {Object} options - * @api private + * @param {string} name + * @param {object} options + * @public */ function View(name, options) { - options = options || {}; + var opts = options || {}; + + this.defaultEngine = opts.defaultEngine; + this.ext = extname(name); this.name = name; - this.root = options.root; - var engines = options.engines; - this.defaultEngine = options.defaultEngine; - var ext = this.ext = extname(name); - if (!ext && !this.defaultEngine) throw new Error('No default engine was specified and no extension was provided.'); - if (!ext) name += (ext = this.ext = ('.' != this.defaultEngine[0] ? '.' : '') + this.defaultEngine); - this.engine = engines[ext] || (engines[ext] = require(ext.slice(1)).__express); - this.path = this.lookup(name); + this.root = opts.root; + + if (!this.ext && !this.defaultEngine) { + throw new Error('No default engine was specified and no extension was provided.'); + } + + var fileName = name; + + if (!this.ext) { + // get extension from default engine name + this.ext = this.defaultEngine[0] !== '.' + ? '.' + this.defaultEngine + : this.defaultEngine; + + fileName += this.ext; + } + + if (!opts.engines[this.ext]) { + // load engine + opts.engines[this.ext] = require(this.ext.substr(1)).__express; + } + + // store loaded engine + this.engine = opts.engines[this.ext]; + + // lookup path + this.path = this.lookup(fileName); } /** * Lookup view by the given `name` * - * @param {String} name - * @return {String} - * @api private + * @param {string} name + * @private */ View.prototype.lookup = function lookup(name) { @@ -91,16 +114,16 @@ View.prototype.lookup = function lookup(name) { }; /** - * Render with the given `options` and callback `fn(err, str)`. + * Render with the given options. * - * @param {Object} options - * @param {Function} fn - * @api private + * @param {object} options + * @param {function} callback + * @private */ -View.prototype.render = function render(options, fn) { +View.prototype.render = function render(options, callback) { debug('render "%s"', this.path); - this.engine(this.path, options, fn); + this.engine(this.path, options, callback); }; /** @@ -113,12 +136,10 @@ View.prototype.render = function render(options, fn) { View.prototype.resolve = function resolve(dir, file) { var ext = this.ext; - var path; - var stat; // . - path = join(dir, file); - stat = tryStat(path); + var path = join(dir, file); + var stat = tryStat(path); if (stat && stat.isFile()) { return path; From 10502480d0f286442654852dba4ec57f8d3391fd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 13:31:03 -0400 Subject: [PATCH 0861/1265] perf: remove argument reassignments in application --- History.md | 1 + lib/application.js | 174 ++++++++++++++++++++++++++------------------- 2 files changed, 101 insertions(+), 74 deletions(-) diff --git a/History.md b/History.md index c1cef158219..84738af0966 100644 --- a/History.md +++ b/History.md @@ -66,6 +66,7 @@ unreleased - perf: reduce try block size - perf: remove bitwise operations * perf: enable strict mode + * perf: remove argument reassignments in application * perf: remove argument reassignments in `View` * perf: use saved reference to `http.STATUS_CODES` diff --git a/lib/application.js b/lib/application.js index b31c88b7b05..7db0f14d4ac 100644 --- a/lib/application.js +++ b/lib/application.js @@ -10,7 +10,7 @@ /** * Module dependencies. - * @api private + * @private */ var finalhandler = require('finalhandler'); @@ -38,7 +38,7 @@ var app = exports = module.exports = {}; /** * Variable for trust proxy inheritance back-compat - * @api private + * @private */ var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default'; @@ -50,27 +50,28 @@ var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default'; * - setup default middleware * - setup route reflection methods * - * @api private + * @private */ -app.init = function(){ +app.init = function init() { this.cache = {}; - this.settings = {}; this.engines = {}; + this.settings = {}; + this.defaultConfiguration(); }; /** * Initialize application configuration. - * - * @api private + * @private */ -app.defaultConfiguration = function(){ +app.defaultConfiguration = function defaultConfiguration() { + var env = process.env.NODE_ENV || 'development'; + // default settings this.enable('x-powered-by'); this.set('etag', 'weak'); - var env = process.env.NODE_ENV || 'development'; this.set('env', env); this.set('query parser', 'extended'); this.set('subdomain offset', 2); @@ -130,9 +131,9 @@ app.defaultConfiguration = function(){ * We cannot add the base router in the defaultConfiguration because * it reads app settings which might be set after that has run. * - * @api private + * @private */ -app.lazyrouter = function() { +app.lazyrouter = function lazyrouter() { if (!this._router) { this._router = new Router({ caseSensitive: this.enabled('case sensitive routing'), @@ -147,17 +148,17 @@ app.lazyrouter = function() { /** * Dispatch a req, res pair into the application. Starts pipeline processing. * - * If no _done_ callback is provided, then default error handlers will respond + * If no callback is provided, then default error handlers will respond * in the event of an error bubbling through the stack. * - * @api private + * @private */ -app.handle = function(req, res, done) { +app.handle = function handle(req, res, callback) { var router = this._router; // final handler - done = done || finalhandler(req, res, { + var done = callback || finalhandler(req, res, { env: this.get('env'), onerror: logerror.bind(this) }); @@ -179,7 +180,7 @@ app.handle = function(req, res, done) { * If the _fn_ parameter is an express app, then it will be * mounted at the _route_ specified. * - * @api public + * @public */ app.use = function use(fn) { @@ -246,10 +247,10 @@ app.use = function use(fn) { * Routes are isolated middleware stacks for specific paths. * See the Route api docs for details. * - * @api public + * @public */ -app.route = function(path){ +app.route = function route(path) { this.lazyrouter(); return this._router.route(path); }; @@ -285,13 +286,22 @@ app.route = function(path){ * @param {String} ext * @param {Function} fn * @return {app} for chaining - * @api public + * @public */ -app.engine = function(ext, fn){ - if ('function' != typeof fn) throw new Error('callback function required'); - if ('.' != ext[0]) ext = '.' + ext; - this.engines[ext] = fn; +app.engine = function engine(ext, fn) { + if (typeof fn !== 'function') { + throw new Error('callback function required'); + } + + // get file extension + var extension = ext[0] !== '.' + ? '.' + ext + : ext; + + // store engine + this.engines[extension] = fn; + return this; }; @@ -304,20 +314,22 @@ app.engine = function(ext, fn){ * @param {String|Array} name * @param {Function} fn * @return {app} for chaining - * @api public + * @public */ -app.param = function(name, fn){ +app.param = function param(name, fn) { this.lazyrouter(); if (Array.isArray(name)) { - name.forEach(function(key) { - this.param(key, fn); - }, this); + for (var i = 0; i < name.length; i++) { + this.param(name[i], fn); + } + return this; } this._router.param(name, fn); + return this; }; @@ -333,10 +345,10 @@ app.param = function(name, fn){ * @param {String} setting * @param {*} [val] * @return {Server} for chaining - * @api public + * @public */ -app.set = function(setting, val){ +app.set = function set(setting, val) { if (arguments.length === 1) { // app.get(setting) return this.settings[setting]; @@ -382,10 +394,10 @@ app.set = function(setting, val){ * return value would be "/blog/admin". * * @return {String} - * @api private + * @private */ -app.path = function(){ +app.path = function path() { return this.parent ? this.parent.path() + this.mountpath : ''; @@ -403,11 +415,11 @@ app.path = function(){ * * @param {String} setting * @return {Boolean} - * @api public + * @public */ -app.enabled = function(setting){ - return !!this.set(setting); +app.enabled = function enabled(setting) { + return Boolean(this.set(setting)); }; /** @@ -422,10 +434,10 @@ app.enabled = function(setting){ * * @param {String} setting * @return {Boolean} - * @api public + * @public */ -app.disabled = function(setting){ +app.disabled = function disabled(setting) { return !this.set(setting); }; @@ -434,10 +446,10 @@ app.disabled = function(setting){ * * @param {String} setting * @return {app} for chaining - * @api public + * @public */ -app.enable = function(setting){ +app.enable = function enable(setting) { return this.set(setting, true); }; @@ -446,10 +458,10 @@ app.enable = function(setting){ * * @param {String} setting * @return {app} for chaining - * @api public + * @public */ -app.disable = function(setting){ +app.disable = function disable(setting) { return this.set(setting, false); }; @@ -459,7 +471,10 @@ app.disable = function(setting){ methods.forEach(function(method){ app[method] = function(path){ - if ('get' == method && 1 == arguments.length) return this.set(path); + if (method === 'get' && arguments.length === 1) { + // app.get(setting) + return this.set(path); + } this.lazyrouter(); @@ -476,17 +491,18 @@ methods.forEach(function(method){ * @param {String} path * @param {Function} ... * @return {app} for chaining - * @api public + * @public */ -app.all = function(path){ +app.all = function all(path) { this.lazyrouter(); var route = this._router.route(path); var args = slice.call(arguments, 1); - methods.forEach(function(method){ - route[method].apply(route, args); - }); + + for (var i = 0; i < methods.length; i++) { + route[methods[i]].apply(route, args); + } return this; }; @@ -508,43 +524,50 @@ app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead'); * * @param {String} name * @param {String|Function} options or fn - * @param {Function} fn - * @api public + * @param {Function} callback + * @public */ -app.render = function(name, options, fn){ - var opts = {}; +app.render = function render(name, options, callback) { var cache = this.cache; + var done = callback; var engines = this.engines; + var opts = options; + var renderOptions = {}; var view; // support callback function as second arg - if ('function' == typeof options) { - fn = options, options = {}; + if (typeof options === 'function') { + done = options; + opts = {}; } // merge app.locals - merge(opts, this.locals); + merge(renderOptions, this.locals); // merge options._locals - if (options._locals) { - merge(opts, options._locals); + if (opts._locals) { + merge(renderOptions, opts._locals); } // merge options - merge(opts, options); + merge(renderOptions, opts); // set .cache unless explicitly provided - opts.cache = null == opts.cache - ? this.enabled('view cache') - : opts.cache; + if (renderOptions.cache == null) { + renderOptions.cache = this.enabled('view cache'); + } // primed cache - if (opts.cache) view = cache[name]; + if (renderOptions.cache) { + view = cache[name]; + } // view if (!view) { - view = new (this.get('view'))(name, { + var View = this.get('view'); + + view = new View(name, { defaultEngine: this.get('view engine'), root: this.get('views'), engines: engines @@ -556,18 +579,20 @@ app.render = function(name, options, fn){ : 'directory "' + view.root + '"' var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs); err.view = view; - return fn(err); + return done(err); } // prime the cache - if (opts.cache) cache[name] = view; + if (renderOptions.cache) { + cache[name] = view; + } } // render try { - view.render(opts, fn); + view.render(renderOptions, done); } catch (err) { - fn(err); + done(err); } }; @@ -589,21 +614,22 @@ app.render = function(name, options, fn){ * https.createServer({ ... }, app).listen(443); * * @return {http.Server} - * @api public + * @public */ -app.listen = function(){ +app.listen = function listen() { var server = http.createServer(this); return server.listen.apply(server, arguments); }; /** -* Log error using console.error. -* -* @param {Error} err -* @api private -*/ + * Log error using console.error. + * + * @param {Error} err + * @private + */ -function logerror(err){ +function logerror(err) { + /* istanbul ignore next */ if (this.get('env') !== 'test') console.error(err.stack || err.toString()); } From f5a240636d71781c7875191d2048279efce5ad56 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 13:36:40 -0400 Subject: [PATCH 0862/1265] perf: isolate app.render try block --- History.md | 1 + lib/application.js | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index 84738af0966..a50fb367407 100644 --- a/History.md +++ b/History.md @@ -66,6 +66,7 @@ unreleased - perf: reduce try block size - perf: remove bitwise operations * perf: enable strict mode + * perf: isolate `app.render` try block * perf: remove argument reassignments in application * perf: remove argument reassignments in `View` * perf: use saved reference to `http.STATUS_CODES` diff --git a/lib/application.js b/lib/application.js index 7db0f14d4ac..b230ad8d629 100644 --- a/lib/application.js +++ b/lib/application.js @@ -589,11 +589,7 @@ app.render = function render(name, options, callback) { } // render - try { - view.render(renderOptions, done); - } catch (err) { - done(err); - } + tryRender(view, renderOptions, done); }; /** @@ -633,3 +629,16 @@ function logerror(err) { /* istanbul ignore next */ if (this.get('env') !== 'test') console.error(err.stack || err.toString()); } + +/** + * Try rendering a view. + * @private + */ + +function tryRender(view, options, callback) { + try { + view.render(options, callback); + } catch (err) { + callback(err); + } +} From d414a2dc733167114e9a37107cc27f078181d1c2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 13:48:58 -0400 Subject: [PATCH 0863/1265] perf: remove argument reassignments in request prototype --- History.md | 1 + lib/request.js | 72 +++++++++++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/History.md b/History.md index a50fb367407..68d9f7db2ed 100644 --- a/History.md +++ b/History.md @@ -68,6 +68,7 @@ unreleased * perf: enable strict mode * perf: isolate `app.render` try block * perf: remove argument reassignments in application + * perf: remove argument reassignments in request prototype * perf: remove argument reassignments in `View` * perf: use saved reference to `http.STATUS_CODES` diff --git a/lib/request.js b/lib/request.js index 962f48d094d..33cac180ed7 100644 --- a/lib/request.js +++ b/lib/request.js @@ -10,6 +10,7 @@ /** * Module dependencies. + * @private */ var accepts = require('accepts'); @@ -51,18 +52,20 @@ var req = exports = module.exports = { * * @param {String} name * @return {String} - * @api public + * @public */ req.get = -req.header = function(name){ - switch (name = name.toLowerCase()) { +req.header = function header(name) { + var lc = name.toLowerCase(); + + switch (lc) { case 'referer': case 'referrer': return this.headers.referrer || this.headers.referer; default: - return this.headers[name]; + return this.headers[lc]; } }; @@ -109,7 +112,7 @@ req.header = function(name){ * * @param {String|Array} type(s) * @return {String|Array|Boolean} - * @api public + * @public */ req.accepts = function(){ @@ -122,7 +125,7 @@ req.accepts = function(){ * * @param {String} ...encoding * @return {String|Array} - * @api public + * @public */ req.acceptsEncodings = function(){ @@ -139,7 +142,7 @@ req.acceptsEncoding = deprecate.function(req.acceptsEncodings, * * @param {String} ...charset * @return {String|Array} - * @api public + * @public */ req.acceptsCharsets = function(){ @@ -156,7 +159,7 @@ req.acceptsCharset = deprecate.function(req.acceptsCharsets, * * @param {String} ...lang * @return {String|Array} - * @api public + * @public */ req.acceptsLanguages = function(){ @@ -184,7 +187,7 @@ req.acceptsLanguage = deprecate.function(req.acceptsLanguages, * * @param {Number} size * @return {Array} - * @api public + * @public */ req.range = function(size){ @@ -207,7 +210,7 @@ req.range = function(size){ * @param {String} name * @param {Mixed} [defaultValue] * @return {String} - * @api public + * @public */ req.param = function param(name, defaultValue) { @@ -248,14 +251,23 @@ req.param = function param(name, defaultValue) { * req.is('html'); * // => false * - * @param {String} type - * @return {Boolean} - * @api public + * @param {String|Array} types... + * @return {String|false|null} + * @public */ -req.is = function(types){ - if (!Array.isArray(types)) types = [].slice.call(arguments); - return typeis(this, types); +req.is = function is(types) { + var arr = types; + + // support flattened arguments + if (!Array.isArray(types)) { + arr = new Array(arguments.length); + for (var i = 0; i < arr.length; i++) { + arr[i] = arguments[i]; + } + } + + return typeis(this, arr); }; /** @@ -269,7 +281,7 @@ req.is = function(types){ * supplies https for you this may be enabled. * * @return {String} - * @api public + * @public */ defineGetter(req, 'protocol', function protocol(){ @@ -294,11 +306,11 @@ defineGetter(req, 'protocol', function protocol(){ * req.protocol == 'https' * * @return {Boolean} - * @api public + * @public */ defineGetter(req, 'secure', function secure(){ - return 'https' == this.protocol; + return this.protocol === 'https'; }); /** @@ -308,7 +320,7 @@ defineGetter(req, 'secure', function secure(){ * "trust proxy" is set. * * @return {String} - * @api public + * @public */ defineGetter(req, 'ip', function ip(){ @@ -325,7 +337,7 @@ defineGetter(req, 'ip', function ip(){ * "proxy2" were trusted. * * @return {Array} - * @api public + * @public */ defineGetter(req, 'ips', function ips() { @@ -346,7 +358,7 @@ defineGetter(req, 'ips', function ips() { * If "subdomain offset" is 3, req.subdomains is `["tobi"]`. * * @return {Array} - * @api public + * @public */ defineGetter(req, 'subdomains', function subdomains() { @@ -366,7 +378,7 @@ defineGetter(req, 'subdomains', function subdomains() { * Short-hand for `url.parse(req.url).pathname`. * * @return {String} - * @api public + * @public */ defineGetter(req, 'path', function path() { @@ -381,7 +393,7 @@ defineGetter(req, 'path', function path() { * be trusted. * * @return {String} - * @api public + * @public */ defineGetter(req, 'hostname', function hostname(){ @@ -400,7 +412,7 @@ defineGetter(req, 'hostname', function hostname(){ : 0; var index = host.indexOf(':', offset); - return ~index + return index !== -1 ? host.substring(0, index) : host; }); @@ -417,7 +429,7 @@ defineGetter(req, 'host', deprecate.function(function host(){ * still match. * * @return {Boolean} - * @api public + * @public */ defineGetter(req, 'fresh', function(){ @@ -441,7 +453,7 @@ defineGetter(req, 'fresh', function(){ * resource has changed. * * @return {Boolean} - * @api public + * @public */ defineGetter(req, 'stale', function stale(){ @@ -452,12 +464,12 @@ defineGetter(req, 'stale', function stale(){ * Check if the request was an _XMLHttpRequest_. * * @return {Boolean} - * @api public + * @public */ defineGetter(req, 'xhr', function xhr(){ var val = this.get('X-Requested-With') || ''; - return 'xmlhttprequest' == val.toLowerCase(); + return val.toLowerCase() === 'xmlhttprequest'; }); /** @@ -466,7 +478,7 @@ defineGetter(req, 'xhr', function xhr(){ * @param {Object} obj * @param {String} name * @param {Function} getter - * @api private + * @private */ function defineGetter(obj, name, getter) { Object.defineProperty(obj, name, { From bb53b20d4c72548b03af97742bbef4ca15a4801c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 14:36:48 -0400 Subject: [PATCH 0864/1265] perf: remove argument reassignments in response prototype --- History.md | 1 + lib/response.js | 217 +++++++++++++++++++++++++++--------------------- 2 files changed, 124 insertions(+), 94 deletions(-) diff --git a/History.md b/History.md index 68d9f7db2ed..bc5a3d95eab 100644 --- a/History.md +++ b/History.md @@ -69,6 +69,7 @@ unreleased * perf: isolate `app.render` try block * perf: remove argument reassignments in application * perf: remove argument reassignments in request prototype + * perf: remove argument reassignments in response prototype * perf: remove argument reassignments in `View` * perf: use saved reference to `http.STATUS_CODES` diff --git a/lib/response.js b/lib/response.js index 5334515eeb4..b9d6cc0e9bc 100644 --- a/lib/response.js +++ b/lib/response.js @@ -9,7 +9,7 @@ /** * Module dependencies. - * @api private + * @private */ var contentDisposition = require('content-disposition'); @@ -40,15 +40,22 @@ var res = module.exports = { __proto__: http.ServerResponse.prototype }; +/** + * Module variables. + * @private + */ + +var charsetRegExp = /;\s*charset\s*=/; + /** * Set status `code`. * * @param {Number} code * @return {ServerResponse} - * @api public + * @public */ -res.status = function(code){ +res.status = function status(code) { this.statusCode = code; return this; }; @@ -65,7 +72,7 @@ res.status = function(code){ * * @param {Object} links * @return {ServerResponse} - * @api public + * @public */ res.links = function(links){ @@ -86,7 +93,7 @@ res.links = function(links){ * res.send('

some html

'); * * @param {string|number|boolean|object|Buffer} body - * @api public + * @public */ res.send = function send(body) { @@ -209,7 +216,7 @@ res.send = function send(body) { * res.json({ user: 'tj' }); * * @param {string|number|boolean|object} obj - * @api public + * @public */ res.json = function json(obj) { @@ -251,7 +258,7 @@ res.json = function json(obj) { * res.jsonp({ user: 'tj' }); * * @param {string|number|boolean|object} obj - * @api public + * @public */ res.jsonp = function jsonp(obj) { @@ -322,7 +329,7 @@ res.jsonp = function jsonp(obj) { * res.sendStatus(200); * * @param {number} statusCode - * @api public + * @public */ res.sendStatus = function sendStatus(statusCode) { @@ -338,7 +345,7 @@ res.sendStatus = function sendStatus(statusCode) { * Transfer the file at the given `path`. * * Automatically sets the _Content-Type_ response header field. - * The callback `fn(err)` is invoked when the transfer is complete + * The callback `callback(err)` is invoked when the transfer is complete * or when an error occurs. Be sure to check `res.sentHeader` * if you wish to attempt responding, as the header and some data * may have already been transferred. @@ -372,13 +379,15 @@ res.sendStatus = function sendStatus(statusCode) { * }); * }); * - * @api public + * @public */ -res.sendFile = function sendFile(path, options, fn) { +res.sendFile = function sendFile(path, options, callback) { + var done = callback; var req = this.req; var res = this; var next = req.next; + var opts = options || {}; if (!path) { throw new TypeError('path argument is required to res.sendFile'); @@ -386,23 +395,21 @@ res.sendFile = function sendFile(path, options, fn) { // support function as second arg if (typeof options === 'function') { - fn = options; - options = {}; + done = options; + opts = {}; } - options = options || {}; - - if (!options.root && !isAbsolute(path)) { + if (!opts.root && !isAbsolute(path)) { throw new TypeError('path must be absolute or specify root to res.sendFile'); } // create file stream var pathname = encodeURI(path); - var file = send(req, pathname, options); + var file = send(req, pathname, opts); // transfer - sendfile(res, file, options, function (err) { - if (fn) return fn(err); + sendfile(res, file, opts, function (err) { + if (done) return done(err); if (err && err.code === 'EISDIR') return next(); // next() all but write errors @@ -416,7 +423,7 @@ res.sendFile = function sendFile(path, options, fn) { * Transfer the file at the given `path`. * * Automatically sets the _Content-Type_ response header field. - * The callback `fn(err)` is invoked when the transfer is complete + * The callback `callback(err)` is invoked when the transfer is complete * or when an error occurs. Be sure to check `res.sentHeader` * if you wish to attempt responding, as the header and some data * may have already been transferred. @@ -450,28 +457,28 @@ res.sendFile = function sendFile(path, options, fn) { * }); * }); * - * @api public + * @public */ -res.sendfile = function(path, options, fn){ +res.sendfile = function (path, options, callback) { + var done = callback; var req = this.req; var res = this; var next = req.next; + var opts = options || {}; // support function as second arg if (typeof options === 'function') { - fn = options; - options = {}; + done = options; + opts = {}; } - options = options || {}; - // create file stream - var file = send(req, path, options); + var file = send(req, path, opts); // transfer - sendfile(res, file, options, function (err) { - if (fn) return fn(err); + sendfile(res, file, opts, function (err) { + if (done) return done(err); if (err && err.code === 'EISDIR') return next(); // next() all but write errors @@ -488,33 +495,34 @@ res.sendfile = deprecate.function(res.sendfile, * Transfer the file at the given `path` as an attachment. * * Optionally providing an alternate attachment `filename`, - * and optional callback `fn(err)`. The callback is invoked + * and optional callback `callback(err)`. The callback is invoked * when the data transfer is complete, or when an error has * ocurred. Be sure to check `res.headersSent` if you plan to respond. * * This method uses `res.sendfile()`. * - * @api public + * @public */ -res.download = function download(path, filename, fn) { +res.download = function download(path, filename, callback) { + var done = callback; + var name = filename; + // support function as second arg if (typeof filename === 'function') { - fn = filename; - filename = null; + done = filename; + name = null; } - filename = filename || path; - // set Content-Disposition when file is sent var headers = { - 'Content-Disposition': contentDisposition(filename) + 'Content-Disposition': contentDisposition(name || path) }; // Resolve the full path for sendFile var fullPath = resolve(path); - return this.sendFile(fullPath, { headers: headers }, fn); + return this.sendFile(fullPath, { headers: headers }, done); }; /** @@ -531,14 +539,16 @@ res.download = function download(path, filename, fn) { * * @param {String} type * @return {ServerResponse} for chaining - * @api public + * @public */ res.contentType = -res.type = function(type){ - return this.set('Content-Type', ~type.indexOf('/') - ? type - : mime.lookup(type)); +res.type = function contentType(type) { + var ct = type.indexOf('/') === -1 + ? mime.lookup(type) + : type; + + return this.set('Content-Type', ct); }; /** @@ -595,7 +605,7 @@ res.type = function(type){ * * @param {Object} obj * @return {ServerResponse} for chaining - * @api public + * @public */ res.format = function(obj){ @@ -632,7 +642,7 @@ res.format = function(obj){ * * @param {String} filename * @return {ServerResponse} - * @api public + * @public */ res.attachment = function attachment(filename) { @@ -657,7 +667,7 @@ res.attachment = function attachment(filename) { * @param {String} field * @param {String|Array} val * @return {ServerResponse} for chaining - * @api public + * @public */ res.append = function append(field, val) { @@ -689,19 +699,23 @@ res.append = function append(field, val) { * @param {String|Object} field * @param {String|Array} val * @return {ServerResponse} for chaining - * @api public + * @public */ res.set = res.header = function header(field, val) { if (arguments.length === 2) { - if (Array.isArray(val)) val = val.map(String); - else val = String(val); - if ('content-type' == field.toLowerCase() && !/;\s*charset\s*=/.test(val)) { - var charset = mime.charsets.lookup(val.split(';')[0]); - if (charset) val += '; charset=' + charset.toLowerCase(); + var value = Array.isArray(val) + ? val.map(String) + : String(val); + + // add charset to content-type + if (field.toLowerCase() === 'content-type' && !charsetRegExp.test(value)) { + var charset = mime.charsets.lookup(value.split(';')[0]); + if (charset) value += '; charset=' + charset.toLowerCase(); } - this.setHeader(field, val); + + this.setHeader(field, value); } else { for (var key in field) { this.set(key, field[key]); @@ -715,7 +729,7 @@ res.header = function header(field, val) { * * @param {String} field * @return {String} - * @api public + * @public */ res.get = function(field){ @@ -728,18 +742,17 @@ res.get = function(field){ * @param {String} name * @param {Object} options * @return {ServerResponse} for chaining - * @api public + * @public */ -res.clearCookie = function(name, options){ - var opts = { expires: new Date(1), path: '/' }; - return this.cookie(name, '', options - ? merge(opts, options) - : opts); +res.clearCookie = function clearCookie(name, options) { + var opts = merge({ expires: new Date(1), path: '/' }, options); + + return this.cookie(name, '', opts); }; /** - * Set cookie `name` to `val`, with the given `options`. + * Set cookie `name` to `value`, with the given `options`. * * Options: * @@ -756,26 +769,39 @@ res.clearCookie = function(name, options){ * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true }) * * @param {String} name - * @param {String|Object} val + * @param {String|Object} value * @param {Options} options * @return {ServerResponse} for chaining - * @api public + * @public */ -res.cookie = function(name, val, options){ - options = merge({}, options); +res.cookie = function (name, value, options) { + var opts = merge({}, options); var secret = this.req.secret; - var signed = options.signed; - if (signed && !secret) throw new Error('cookieParser("secret") required for signed cookies'); - if ('number' == typeof val) val = val.toString(); - if ('object' == typeof val) val = 'j:' + JSON.stringify(val); - if (signed) val = 's:' + sign(val, secret); - if ('maxAge' in options) { - options.expires = new Date(Date.now() + options.maxAge); - options.maxAge /= 1000; + var signed = opts.signed; + + if (signed && !secret) { + throw new Error('cookieParser("secret") required for signed cookies'); } - if (null == options.path) options.path = '/'; - var headerVal = cookie.serialize(name, String(val), options); + + var val = typeof value === 'object' + ? 'j:' + JSON.stringify(value) + : String(value); + + if (signed) { + val = 's:' + sign(val, secret); + } + + if ('maxAge' in opts) { + opts.expires = new Date(Date.now() + opts.maxAge); + opts.maxAge /= 1000; + } + + if (opts.path == null) { + opts.path = '/'; + } + + var headerVal = cookie.serialize(name, String(val), opts); // supports multiple 'res.cookie' calls by getting previous value var prev = this.get('Set-Cookie'); @@ -790,7 +816,6 @@ res.cookie = function(name, val, options){ return this; }; - /** * Set the location header to `url`. * @@ -805,17 +830,19 @@ res.cookie = function(name, val, options){ * * @param {String} url * @return {ServerResponse} for chaining - * @api public + * @public */ -res.location = function(url){ - var req = this.req; +res.location = function location(url) { + var loc = url; // "back" is an alias for the referrer - if ('back' == url) url = req.get('Referrer') || '/'; + if (url === 'back') { + loc = this.req.get('Referrer') || '/'; + } - // Respond - this.set('Location', url); + // set location + this.set('Location', loc); return this; }; @@ -834,7 +861,7 @@ res.location = function(url){ * res.redirect(301, 'http://example.com'); * res.redirect('../login'); // /blog/post/1 -> /blog/login * - * @api public + * @public */ res.redirect = function redirect(url) { @@ -890,7 +917,7 @@ res.redirect = function redirect(url) { * * @param {Array|String} field * @return {ServerResponse} for chaining - * @api public + * @public */ res.vary = function(field){ @@ -915,31 +942,33 @@ res.vary = function(field){ * - `cache` boolean hinting to the engine it should cache * - `filename` filename of the view being rendered * - * @api public + * @public */ -res.render = function(view, options, fn){ - options = options || {}; - var self = this; +res.render = function render(view, options, callback) { + var app = this.req.app; + var done = callback; + var opts = options || {}; var req = this.req; - var app = req.app; + var self = this; // support callback function as second arg - if ('function' == typeof options) { - fn = options, options = {}; + if (typeof options === 'function') { + done = options; + opts = {}; } // merge res.locals - options._locals = self.locals; + opts._locals = self.locals; // default callback to respond - fn = fn || function(err, str){ + done = done || function (err, str) { if (err) return req.next(err); self.send(str); }; // render - app.render(view, options, fn); + app.render(view, opts, done); }; // pipe the send file stream From 5915894af3f14e75dd3121fdc2d92ae55206e398 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 14:38:30 -0400 Subject: [PATCH 0865/1265] Simplify res.cookie to call res.append --- History.md | 1 + lib/response.js | 12 +----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/History.md b/History.md index bc5a3d95eab..5778a23bba5 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased * Fix issue where `next('route')` in `app.param` would incorrectly skip values * Fix using `*` before params in routes * Fix using capture groups before params in routes + * Simplify `res.cookie` to call `res.append` * Use `array-flatten` module for flattening arrays * deps: accepts@~1.2.9 - deps: mime-types@~2.1.1 diff --git a/lib/response.js b/lib/response.js index b9d6cc0e9bc..8f74f951df0 100644 --- a/lib/response.js +++ b/lib/response.js @@ -801,18 +801,8 @@ res.cookie = function (name, value, options) { opts.path = '/'; } - var headerVal = cookie.serialize(name, String(val), opts); + this.append('Set-Cookie', cookie.serialize(name, String(val), opts)); - // supports multiple 'res.cookie' calls by getting previous value - var prev = this.get('Set-Cookie'); - if (prev) { - if (Array.isArray(prev)) { - headerVal = prev.concat(headerVal); - } else { - headerVal = [prev, headerVal]; - } - } - this.set('Set-Cookie', headerVal); return this; }; From 3b3e1fc38a8e2763679fc11ff07aed1617946867 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 15:20:35 -0400 Subject: [PATCH 0866/1265] Fix hiding platform issues with decodeURIComponent closes #2652 --- History.md | 2 ++ lib/router/layer.js | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index 5778a23bba5..b591d9d0d85 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,8 @@ unreleased * Fix `res.format` error when only `default` provided * Fix issue where `next('route')` in `app.param` would incorrectly skip values + * Fix hiding platform issues with `decodeURIComponent` + - Only `URIError`s are a 400 * Fix using `*` before params in routes * Fix using capture groups before params in routes * Simplify `res.cookie` to call `res.append` diff --git a/lib/router/layer.js b/lib/router/layer.js index b5c1f58958b..a29cf26bfcf 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -152,19 +152,22 @@ Layer.prototype.match = function match(path) { * * @param {string} val * @return {string} - * @api private + * @private */ -function decode_param(val){ +function decode_param(val) { if (typeof val !== 'string') { return val; } try { return decodeURIComponent(val); - } catch (e) { - var err = new TypeError("Failed to decode param '" + val + "'"); - err.status = 400; + } catch (err) { + if (err instanceof URIError) { + err.message = 'Failed to decode param \'' + val + '\''; + err.status = 400; + } + throw err; } } From 7d6c1e5c5c17b88da21e30ffd2e58999881c0d67 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 15:23:35 -0400 Subject: [PATCH 0867/1265] perf: skip attempting to decode zero length string --- History.md | 1 + lib/router/layer.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index b591d9d0d85..db5c13d953f 100644 --- a/History.md +++ b/History.md @@ -74,6 +74,7 @@ unreleased * perf: remove argument reassignments in request prototype * perf: remove argument reassignments in response prototype * perf: remove argument reassignments in `View` + * perf: skip attempting to decode zero length string * perf: use saved reference to `http.STATUS_CODES` 4.12.4 / 2015-05-17 diff --git a/lib/router/layer.js b/lib/router/layer.js index a29cf26bfcf..b1dd04cf23a 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -156,7 +156,7 @@ Layer.prototype.match = function match(path) { */ function decode_param(val) { - if (typeof val !== 'string') { + if (typeof val !== 'string' || val.length === 0) { return val; } From 5b4d4b4ab1324743534fbcd4709f4e75bb4b4e9d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 15:27:47 -0400 Subject: [PATCH 0868/1265] Add statusCode properties to two errors --- lib/response.js | 2 +- lib/router/layer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/response.js b/lib/response.js index 8f74f951df0..641704b04ae 100644 --- a/lib/response.js +++ b/lib/response.js @@ -629,7 +629,7 @@ res.format = function(obj){ fn(); } else { var err = new Error('Not Acceptable'); - err.status = 406; + err.status = err.statusCode = 406; err.types = normalizeTypes(keys).map(function(o){ return o.value }); next(err); } diff --git a/lib/router/layer.js b/lib/router/layer.js index b1dd04cf23a..846bdadba01 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -165,7 +165,7 @@ function decode_param(val) { } catch (err) { if (err instanceof URIError) { err.message = 'Failed to decode param \'' + val + '\''; - err.status = 400; + err.status = err.statusCode = 400; } throw err; From 9302acc5e449768b3ca2b03701d5379d86453af5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 16:13:59 -0400 Subject: [PATCH 0869/1265] perf: remove argument reassignments in routing --- History.md | 1 + lib/router/index.js | 38 +++++++++++++------------ lib/router/layer.js | 11 +++++--- lib/router/route.js | 69 ++++++++++++++++++++++++++++----------------- 4 files changed, 71 insertions(+), 48 deletions(-) diff --git a/History.md b/History.md index db5c13d953f..f69a1335f26 100644 --- a/History.md +++ b/History.md @@ -73,6 +73,7 @@ unreleased * perf: remove argument reassignments in application * perf: remove argument reassignments in request prototype * perf: remove argument reassignments in response prototype + * perf: remove argument reassignments in routing * perf: remove argument reassignments in `View` * perf: skip attempting to decode zero length string * perf: use saved reference to `http.STATUS_CODES` diff --git a/lib/router/index.js b/lib/router/index.js index 8786dc15d3e..1f3ec6d49ce 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -10,6 +10,7 @@ /** * Module dependencies. + * @private */ var Route = require('./route'); @@ -23,6 +24,7 @@ var parseUrl = require('parseurl'); /** * Module variables. + * @private */ var objectRegExp = /^\[object (\S+)\]$/; @@ -34,11 +36,11 @@ var toString = Object.prototype.toString; * * @param {Object} options * @return {Router} which is an callable function - * @api public + * @public */ var proto = module.exports = function(options) { - options = options || {}; + var opts = options || {}; function router(req, res, next) { router.handle(req, res, next); @@ -49,9 +51,9 @@ var proto = module.exports = function(options) { router.params = {}; router._params = []; - router.caseSensitive = options.caseSensitive; - router.mergeParams = options.mergeParams; - router.strict = options.strict; + router.caseSensitive = opts.caseSensitive; + router.mergeParams = opts.mergeParams; + router.strict = opts.strict; router.stack = []; return router; @@ -88,7 +90,7 @@ var proto = module.exports = function(options) { * @param {String} name * @param {Function} fn * @return {app} for chaining - * @api public + * @public */ proto.param = function param(name, fn) { @@ -127,11 +129,10 @@ proto.param = function param(name, fn) { /** * Dispatch a req, res into the router. - * - * @api private + * @private */ -proto.handle = function(req, res, done) { +proto.handle = function handle(req, res, out) { var self = this; debug('dispatching %s %s', req.method, req.url); @@ -155,7 +156,7 @@ proto.handle = function(req, res, done) { // manage inter-router variables var parentParams = req.params; var parentUrl = req.baseUrl || ''; - done = restore(done, req, 'baseUrl', 'next', 'params'); + var done = restore(out, req, 'baseUrl', 'next', 'params'); // setup next layer req.next = next; @@ -315,11 +316,10 @@ proto.handle = function(req, res, done) { /** * Process any parameters for the layer. - * - * @api private + * @private */ -proto.process_params = function(layer, called, req, res, done) { +proto.process_params = function process_params(layer, called, req, res, done) { var params = this.params; // captured parameters from the layer, keys and values @@ -422,7 +422,7 @@ proto.process_params = function(layer, called, req, res, done) { * handlers can operate without any code changes regardless of the "prefix" * pathname. * - * @api public + * @public */ proto.use = function use(fn) { @@ -451,7 +451,9 @@ proto.use = function use(fn) { throw new TypeError('Router.use() requires middleware functions'); } - callbacks.forEach(function (fn) { + for (var i = 0; i < callbacks.length; i++) { + var fn = callbacks[i]; + if (typeof fn !== 'function') { throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn)); } @@ -468,7 +470,7 @@ proto.use = function use(fn) { layer.route = undefined; this.stack.push(layer); - }, this); + } return this; }; @@ -483,10 +485,10 @@ proto.use = function use(fn) { * * @param {String} path * @return {Route} - * @api public + * @public */ -proto.route = function(path){ +proto.route = function route(path) { var route = new Route(path); var layer = new Layer(path, { diff --git a/lib/router/layer.js b/lib/router/layer.js index 846bdadba01..fe9210cb9de 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -10,6 +10,7 @@ /** * Module dependencies. + * @private */ var pathRegexp = require('path-to-regexp'); @@ -17,12 +18,14 @@ var debug = require('debug')('express:router:layer'); /** * Module variables. + * @private */ var hasOwnProperty = Object.prototype.hasOwnProperty; /** - * Expose `Layer`. + * Module exports. + * @public */ module.exports = Layer; @@ -33,15 +36,15 @@ function Layer(path, options, fn) { } debug('new %s', path); - options = options || {}; + var opts = options || {}; this.handle = fn; this.name = fn.name || ''; this.params = undefined; this.path = undefined; - this.regexp = pathRegexp(path, this.keys = [], options); + this.regexp = pathRegexp(path, this.keys = [], opts); - if (path === '/' && options.end === false) { + if (path === '/' && opts.end === false) { this.regexp.fast_slash = true; } } diff --git a/lib/router/route.js b/lib/router/route.js index dadd2c7b6d4..2788d7b7353 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -10,6 +10,7 @@ /** * Module dependencies. + * @private */ var debug = require('debug')('express:router:route'); @@ -18,7 +19,16 @@ var Layer = require('./layer'); var methods = require('methods'); /** - * Expose `Route`. + * Module variables. + * @private + */ + +var slice = Array.prototype.slice; +var toString = Object.prototype.toString; + +/** + * Module exports. + * @public */ module.exports = Route; @@ -27,20 +37,22 @@ module.exports = Route; * Initialize `Route` with the given `path`, * * @param {String} path - * @api private + * @public */ function Route(path) { - debug('new %s', path); this.path = path; this.stack = []; + debug('new %s', path); + // route handlers for various http methods this.methods = {}; } /** - * @api private + * Determine if the route handles a given method. + * @private */ Route.prototype._handles_method = function _handles_method(method) { @@ -48,18 +60,18 @@ Route.prototype._handles_method = function _handles_method(method) { return true; } - method = method.toLowerCase(); + var name = method.toLowerCase(); - if (method === 'head' && !this.methods['head']) { - method = 'get'; + if (name === 'head' && !this.methods['head']) { + name = 'get'; } - return Boolean(this.methods[method]); + return Boolean(this.methods[name]); }; /** * @return {Array} supported HTTP methods - * @api private + * @private */ Route.prototype._options = function _options() { @@ -80,11 +92,10 @@ Route.prototype._options = function _options() { /** * dispatch req, res into this route - * - * @api private + * @private */ -Route.prototype.dispatch = function(req, res, done){ +Route.prototype.dispatch = function dispatch(req, res, done) { var idx = 0; var stack = this.stack; if (stack.length === 0) { @@ -150,44 +161,50 @@ Route.prototype.dispatch = function(req, res, done){ * @api public */ -Route.prototype.all = function(){ - var callbacks = flatten([].slice.call(arguments)); - callbacks.forEach(function(fn) { - if (typeof fn !== 'function') { - var type = {}.toString.call(fn); +Route.prototype.all = function all() { + var handles = flatten(slice.call(arguments)); + + for (var i = 0; i < handles.length; i++) { + var handle = handles[i]; + + if (typeof handle !== 'function') { + var type = toString.call(handle); var msg = 'Route.all() requires callback functions but got a ' + type; - throw new Error(msg); + throw new TypeError(msg); } - var layer = Layer('/', {}, fn); + var layer = Layer('/', {}, handle); layer.method = undefined; this.methods._all = true; this.stack.push(layer); - }, this); + } return this; }; methods.forEach(function(method){ Route.prototype[method] = function(){ - var callbacks = flatten([].slice.call(arguments)); + var handles = flatten(slice.call(arguments)); + + for (var i = 0; i < handles.length; i++) { + var handle = handles[i]; - callbacks.forEach(function(fn) { - if (typeof fn !== 'function') { - var type = {}.toString.call(fn); + if (typeof handle !== 'function') { + var type = toString.call(handle); var msg = 'Route.' + method + '() requires callback functions but got a ' + type; throw new Error(msg); } debug('%s %s', method, this.path); - var layer = Layer('/', {}, fn); + var layer = Layer('/', {}, handle); layer.method = method; this.methods[method] = true; this.stack.push(layer); - }, this); + } + return this; }; }); From 2a455890b9f68642457698163224f49e31ffff2a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 16:21:12 -0400 Subject: [PATCH 0870/1265] Add settings to debug output closes #2675 --- History.md | 1 + lib/application.js | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index f69a1335f26..d72226591e2 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Add settings to debug output * Fix `res.format` error when only `default` provided * Fix issue where `next('route')` in `app.param` would incorrectly skip values * Fix hiding platform issues with `decodeURIComponent` diff --git a/lib/application.js b/lib/application.js index b230ad8d629..a9df9103540 100644 --- a/lib/application.js +++ b/lib/application.js @@ -354,21 +354,20 @@ app.set = function set(setting, val) { return this.settings[setting]; } + debug('set "%s" to %o', setting, val); + // set value this.settings[setting] = val; // trigger matched settings switch (setting) { case 'etag': - debug('compile etag %s', val); this.set('etag fn', compileETag(val)); break; case 'query parser': - debug('compile query parser %s', val); this.set('query parser fn', compileQueryParser(val)); break; case 'trust proxy': - debug('compile trust proxy %s', val); this.set('trust proxy fn', compileTrust(val)); // trust proxy inherit back-compat From f73ff9243006ea010fffdaa748f06df3a5b986e7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 20 Jun 2015 19:20:52 -0400 Subject: [PATCH 0871/1265] build: support io.js 2.x --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index b163d5dc22d..ebdea3cbf62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - "0.12" - "1.0" - "1.8" + - "2.0" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index 8be4511b02a..aa7554cfd53 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ environment: - nodejs_version: "0.12" - nodejs_version: "1.0" - nodejs_version: "1.8" + - nodejs_version: "2.0" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From 6c7a36733891ddd6089ee4f267d731383bf58ea9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 21 Jun 2015 01:46:44 -0400 Subject: [PATCH 0872/1265] 4.13.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index d72226591e2..0f13c459517 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.13.0 / 2015-06-20 +=================== * Add settings to debug output * Fix `res.format` error when only `default` provided diff --git a/package.json b/package.json index 95a4a472f87..c3fd59ae9f2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.12.4", + "version": "4.13.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 3ec7cca5506d87e2f7e0146514c6180950e46fd9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 00:38:10 -0400 Subject: [PATCH 0873/1265] deps: connect@2.30.1 --- History.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index bb06bdb6f42..659356ef01a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,16 @@ +3.x +=== + + * deps: connect@2.30.1 + - deps: body-parser@~1.13.2 + - deps: compression@~1.5.1 + - deps: errorhandler@~1.4.1 + - deps: morgan@~1.6.1 + - deps: pause@0.1.0 + - deps: qs@4.0.0 + - deps: serve-index@~1.7.1 + - deps: type-is@~1.6.4 + 3.21.0 / 2015-06-18 =================== diff --git a/package.json b/package.json index e8d2f00395f..e39c7881f4a 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "1.0.2", - "connect": "2.30.0", + "connect": "2.30.1", "content-disposition": "0.5.0", "content-type": "~1.0.1", "commander": "2.6.0", From 71d56db947dcd4da7a75189a8df784da964a1216 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 00:39:06 -0400 Subject: [PATCH 0874/1265] build: ejs@2.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e39c7881f4a..f2521113ffc 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "connect-redis": "~1.5.0", - "ejs": "2.3.1", + "ejs": "2.3.2", "istanbul": "0.3.9", "marked": "0.3.3", "mocha": "2.2.5", From f247a4182f9e459e1bf1ca8a2261e9f088718ff0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 00:39:42 -0400 Subject: [PATCH 0875/1265] deps: basic-auth@~1.0.3 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 659356ef01a..53aac06e412 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * deps: basic-auth@~1.0.3 * deps: connect@2.30.1 - deps: body-parser@~1.13.2 - deps: compression@~1.5.1 diff --git a/package.json b/package.json index f2521113ffc..ab70b40216f 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "api" ], "dependencies": { - "basic-auth": "1.0.2", + "basic-auth": "~1.0.3", "connect": "2.30.1", "content-disposition": "0.5.0", "content-type": "~1.0.1", From 3c0ff8133bace4a0dc1356b8d8e6e83b38d2dd95 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 00:53:25 -0400 Subject: [PATCH 0876/1265] 3.21.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 53aac06e412..581960b7111 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.21.1 / 2015-07-05 +=================== * deps: basic-auth@~1.0.3 * deps: connect@2.30.1 diff --git a/package.json b/package.json index ab70b40216f..d78a2576efa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.21.0", + "version": "3.21.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 2870add2305038948dd9bb20aed60ab48d486ece Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 00:59:27 -0400 Subject: [PATCH 0877/1265] deps: type-is@~1.6.4 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 8a2387b8101..200c0ca7c5e 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +unreleased +========== + + * deps: type-is@~1.6.4 + - deps: mime-types@~2.1.2 + - perf: enable strict mode + - perf: remove argument reassignment + 4.13.0 / 2015-06-20 =================== diff --git a/package.json b/package.json index 621a1040fa6..ab82ad51f1c 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "range-parser": "~1.0.2", "send": "0.13.0", "serve-static": "~1.10.0", - "type-is": "~1.6.3", + "type-is": "~1.6.4", "vary": "~1.0.0", "utils-merge": "1.0.0" }, From 3314f767e1e9e06731f2d0a19b9be982829e390e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 01:00:12 -0400 Subject: [PATCH 0878/1265] deps: accepts@~1.2.10 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 200c0ca7c5e..0f9e6177708 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ unreleased ========== + * deps: accepts@~1.2.10 + - deps: mime-types@~2.1.2 * deps: type-is@~1.6.4 - deps: mime-types@~2.1.2 - perf: enable strict mode diff --git a/package.json b/package.json index ab82ad51f1c..c1328c7e3e6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.9", + "accepts": "~1.2.10", "array-flatten": "1.1.0", "content-disposition": "0.5.0", "content-type": "~1.0.1", From 7bea53b92b52764df2cb1ae32145fb4f4a242c1c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 01:20:09 -0400 Subject: [PATCH 0879/1265] deps: qs@4.0.0 --- History.md | 3 +++ lib/middleware/query.js | 15 +++++++++++++-- lib/utils.js | 16 +++++++++++++++- package.json | 2 +- test/req.query.js | 25 +++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 0f9e6177708..f410867ad88 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,9 @@ unreleased * deps: accepts@~1.2.10 - deps: mime-types@~2.1.2 + * deps: qs@4.0.0 + - Fix dropping parameters like `hasOwnProperty` + - Fix various parsing edge cases * deps: type-is@~1.6.4 - deps: mime-types@~2.1.2 - perf: enable strict mode diff --git a/lib/middleware/query.js b/lib/middleware/query.js index d86474a05a5..a665f3f1431 100644 --- a/lib/middleware/query.js +++ b/lib/middleware/query.js @@ -22,17 +22,28 @@ var qs = require('qs'); */ module.exports = function query(options) { + var opts = Object.create(options || null); var queryparse = qs.parse; if (typeof options === 'function') { queryparse = options; - options = undefined; + opts = undefined; + } + + if (opts !== undefined) { + if (opts.allowDots === undefined) { + opts.allowDots = false; + } + + if (opts.allowPrototypes === undefined) { + opts.allowPrototypes = true; + } } return function query(req, res, next){ if (!req.query) { var val = parseUrl(req).query; - req.query = queryparse(val, options); + req.query = queryparse(val, opts); } next(); diff --git a/lib/utils.js b/lib/utils.js index d10391c43d9..3d54247ad28 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -209,7 +209,7 @@ exports.compileQueryParser = function compileQueryParser(val) { fn = newObject; break; case 'extended': - fn = qs.parse; + fn = parseExtendedQueryString; break; case 'simple': fn = querystring.parse; @@ -274,6 +274,20 @@ exports.setCharset = function setCharset(type, charset) { return contentType.format(parsed); }; +/** + * Parse an extended query string with qs. + * + * @return {Object} + * @private + */ + +function parseExtendedQueryString(str) { + return qs.parse(str, { + allowDots: false, + allowPrototypes: true + }); +} + /** * Return new empty object. * diff --git a/package.json b/package.json index c1328c7e3e6..9aecced520e 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "parseurl": "~1.3.0", "path-to-regexp": "0.1.6", "proxy-addr": "~1.0.8", - "qs": "2.4.2", + "qs": "4.0.0", "range-parser": "~1.0.2", "send": "0.13.0", "serve-static": "~1.10.0", diff --git a/test/req.query.js b/test/req.query.js index f243293125b..19151411995 100644 --- a/test/req.query.js +++ b/test/req.query.js @@ -28,6 +28,14 @@ describe('req', function(){ .get('/?user[name]=tj') .expect(200, '{"user":{"name":"tj"}}', done); }); + + it('should parse parameters with dots', function (done) { + var app = createApp('extended'); + + request(app) + .get('/?user.name=tj') + .expect(200, '{"user.name":"tj"}', done); + }); }); describe('when "query parser" is simple', function () { @@ -72,6 +80,23 @@ describe('req', function(){ }); }); + describe('when "query parser fn" is missing', function () { + it('should act like "extended"', function (done) { + var app = express(); + + delete app.settings['query parser']; + delete app.settings['query parser fn']; + + app.use(function (req, res) { + res.send(req.query); + }); + + request(app) + .get('/?user[name]=tj&user.name=tj') + .expect(200, '{"user":{"name":"tj"},"user.name":"tj"}', done); + }); + }); + describe('when "query parser" an unknown value', function () { it('should throw', function () { createApp.bind(null, 'bogus').should.throw(/unknown value.*query parser/); From a48c55896b3b4fe34aa7d10baa75e140c67cad66 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 01:21:26 -0400 Subject: [PATCH 0880/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9aecced520e..fa902e8e553 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,14 @@ "mocha": "2.2.5", "should": "7.0.1", "supertest": "1.0.1", - "body-parser": "~1.13.1", + "body-parser": "~1.13.2", "connect-redis": "~2.3.0", "cookie-parser": "~1.3.5", - "cookie-session": "~1.1.0", + "cookie-session": "~1.2.0", "express-session": "~1.11.3", "jade": "~1.11.0", "method-override": "~2.3.3", - "morgan": "~1.6.0", + "morgan": "~1.6.1", "multiparty": "~4.1.2", "vhost": "~3.0.0" }, From def241f91f73c456b48100c693230b4fda51c139 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 01:36:51 -0400 Subject: [PATCH 0881/1265] build: io.js@2.3 --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ebdea3cbf62..df087b4a0f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ node_js: - "1.0" - "1.8" - "2.0" + - "2.3" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index aa7554cfd53..b1f13d167bd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,7 @@ environment: - nodejs_version: "1.0" - nodejs_version: "1.8" - nodejs_version: "2.0" + - nodejs_version: "2.3" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From 2ac25098548f739c4f2b526b2a00aa60a74c8e75 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Jul 2015 01:38:44 -0400 Subject: [PATCH 0882/1265] 4.13.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index f410867ad88..3362daefb49 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.13.1 / 2015-07-05 +=================== * deps: accepts@~1.2.10 - deps: mime-types@~2.1.2 diff --git a/package.json b/package.json index fa902e8e553..4c4a3b7a767 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.13.0", + "version": "4.13.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From de7ffca33ff30932bdaa2dbe51862af32e8a30b1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 24 Jul 2015 21:36:56 -0400 Subject: [PATCH 0883/1265] tests: add test for matching route after error --- test/app.routes.error.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/app.routes.error.js b/test/app.routes.error.js index ac517efdee2..7c49d50ffe2 100644 --- a/test/app.routes.error.js +++ b/test/app.routes.error.js @@ -3,6 +3,22 @@ var express = require('../') describe('app', function(){ describe('.VERB()', function(){ + it('should not get invoked without error handler on error', function(done) { + var app = express(); + + app.use(function(req, res, next){ + next(new Error('boom!')) + }); + + app.get('/bar', function(req, res){ + res.send('hello, world!'); + }); + + request(app) + .post('/bar') + .expect(500, /Error: boom!/, done); + }); + it('should only call an error handling routing callback when an error is propagated', function(done){ var app = express(); From fc95112145a122b9e3aaa56f82b00eae9b8fe001 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 27 Jul 2015 22:09:34 -0400 Subject: [PATCH 0884/1265] build: should@7.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d78a2576efa..8cf5203b6f1 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "istanbul": "0.3.9", "marked": "0.3.3", "mocha": "2.2.5", - "should": "7.0.1", + "should": "7.0.2", "supertest": "1.0.1" }, "engines": { From d51d1ea57afea4a2df288e3f541d092fce8721b7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 27 Jul 2015 22:11:54 -0400 Subject: [PATCH 0885/1265] build: ejs@2.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8cf5203b6f1..78f40ce989a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "connect-redis": "~1.5.0", - "ejs": "2.3.2", + "ejs": "2.3.3", "istanbul": "0.3.9", "marked": "0.3.3", "mocha": "2.2.5", From b53feaa1d8b8701b6c0085ff520f59cd1e7dccd8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 27 Jul 2015 22:12:39 -0400 Subject: [PATCH 0886/1265] deps: vary@~1.0.1 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 581960b7111..27650df168a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +3.x +=== + + * deps: vary@~1.0.1 + - Fix setting empty header from empty `field` + - perf: enable strict mode + - perf: remove argument reassignments + 3.21.1 / 2015-07-05 =================== diff --git a/package.json b/package.json index 78f40ce989a..24fdca64021 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "range-parser": "~1.0.2", "send": "0.13.0", "utils-merge": "1.0.0", - "vary": "~1.0.0" + "vary": "~1.0.1" }, "devDependencies": { "connect-redis": "~1.5.0", From 09c80bf823e16daafafc2ed013b07c62380a6912 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 28 Jul 2015 23:24:00 -0400 Subject: [PATCH 0887/1265] deps: array-flatten@1.1.1 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3362daefb49..dbcde7e4053 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: array-flatten@1.1.1 + - perf: enable strict mode + 4.13.1 / 2015-07-05 =================== diff --git a/package.json b/package.json index 4c4a3b7a767..973067eb653 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ ], "dependencies": { "accepts": "~1.2.10", - "array-flatten": "1.1.0", + "array-flatten": "1.1.1", "content-disposition": "0.5.0", "content-type": "~1.0.1", "cookie": "0.1.3", From 659c0b154c965f4945e061adcc52c2abf6254dbe Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 28 Jul 2015 23:26:31 -0400 Subject: [PATCH 0888/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 973067eb653..7b2f63143c2 100644 --- a/package.json +++ b/package.json @@ -62,15 +62,15 @@ "should": "7.0.1", "supertest": "1.0.1", "body-parser": "~1.13.2", - "connect-redis": "~2.3.0", + "connect-redis": "~2.4.1", "cookie-parser": "~1.3.5", "cookie-session": "~1.2.0", "express-session": "~1.11.3", "jade": "~1.11.0", - "method-override": "~2.3.3", + "method-override": "~2.3.4", "morgan": "~1.6.1", "multiparty": "~4.1.2", - "vhost": "~3.0.0" + "vhost": "~3.0.1" }, "engines": { "node": ">= 0.10.0" From 93dd15cd615f29315f68043a453953af37a870dc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 16:13:09 -0400 Subject: [PATCH 0889/1265] deps: connect@2.30.2 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 27650df168a..3bb407e7d19 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,14 @@ 3.x === + * deps: connect@2.30.2 + - deps: body-parser@~1.13.3 + - deps: compression@~1.5.2 + - deps: errorhandler@~1.4.2 + - deps: method-override@~2.3.5 + - deps: serve-index@~1.7.2 + - deps: type-is@~1.6.6 + - deps: vhost@~3.0.1 * deps: vary@~1.0.1 - Fix setting empty header from empty `field` - perf: enable strict mode diff --git a/package.json b/package.json index 24fdca64021..486a7e39467 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "basic-auth": "~1.0.3", - "connect": "2.30.1", + "connect": "2.30.2", "content-disposition": "0.5.0", "content-type": "~1.0.1", "commander": "2.6.0", From ce087e559ea416a7dc2f5a6e5eb0aa4f6be8ff2c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 16:13:41 -0400 Subject: [PATCH 0890/1265] build: marked@0.3.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 486a7e39467..c129cb95312 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "connect-redis": "~1.5.0", "ejs": "2.3.3", "istanbul": "0.3.9", - "marked": "0.3.3", + "marked": "0.3.5", "mocha": "2.2.5", "should": "7.0.2", "supertest": "1.0.1" From cb59086305367d9fcd7d63b53cfca1a3e4ef77d7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 16:15:06 -0400 Subject: [PATCH 0891/1265] 3.21.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 3bb407e7d19..f95055ae6e0 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -3.x -=== +3.21.2 / 2015-07-31 +=================== * deps: connect@2.30.2 - deps: body-parser@~1.13.3 diff --git a/package.json b/package.json index c129cb95312..321a07e7655 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.21.1", + "version": "3.21.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From e33c5035bb3e96f465e8a6c5678706fcb1bcb236 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Tue, 28 Jul 2015 13:15:34 +1000 Subject: [PATCH 0892/1265] deps: path-to-regexp@0.1.7 closes #2717 --- History.md | 2 ++ package.json | 2 +- test/app.router.js | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index dd2366d32b2..4e7e76c6f86 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,8 @@ unreleased * deps: array-flatten@1.1.1 - perf: enable strict mode + * deps: path-to-regexp@0.1.7 + - Fix regression with escaped round brackets and matching groups 4.13.1 / 2015-07-05 =================== diff --git a/package.json b/package.json index f952bc1df76..d9981e71dd3 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "methods": "~1.1.1", "on-finished": "~2.3.0", "parseurl": "~1.3.0", - "path-to-regexp": "0.1.6", + "path-to-regexp": "0.1.7", "proxy-addr": "~1.0.8", "qs": "4.0.0", "range-parser": "~1.0.2", diff --git a/test/app.router.js b/test/app.router.js index 491de358f07..f528a4cb21f 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -721,6 +721,18 @@ describe('app.router', function(){ .expect('editing tj (old)', cb); }) + it('should work inside literal paranthesis', function(done){ + var app = express(); + + app.get('/:user\\(:op\\)', function(req, res){ + res.end(req.params.op + 'ing ' + req.params.user); + }); + + request(app) + .get('/tj(edit)') + .expect('editing tj', done); + }) + it('should work in array of paths', function(done){ var app = express(); var cb = after(2, done); From 1cea9cedec212695b298afcebadc7473a28a98e6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 17:01:35 -0400 Subject: [PATCH 0893/1265] deps: accepts@~1.2.12 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4e7e76c6f86..1f1b091fdf0 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ unreleased ========== + * deps: accepts@~1.2.12 + - deps: mime-types@~2.1.4 * deps: array-flatten@1.1.1 - perf: enable strict mode * deps: path-to-regexp@0.1.7 diff --git a/package.json b/package.json index d9981e71dd3..3bdb417394d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.10", + "accepts": "~1.2.12", "array-flatten": "1.1.1", "content-disposition": "0.5.0", "content-type": "~1.0.1", From c398a9903df7e4ce50699d597914e1bd7c7019de Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 17:02:10 -0400 Subject: [PATCH 0894/1265] deps: type-is@~1.6.6 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1f1b091fdf0..2284ffcc978 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ unreleased - perf: enable strict mode * deps: path-to-regexp@0.1.7 - Fix regression with escaped round brackets and matching groups + * deps: type-is@~1.6.6 + - deps: mime-types@~2.1.4 4.13.1 / 2015-07-05 =================== diff --git a/package.json b/package.json index 3bdb417394d..8e8bd20da8e 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "range-parser": "~1.0.2", "send": "0.13.0", "serve-static": "~1.10.0", - "type-is": "~1.6.4", + "type-is": "~1.6.6", "utils-merge": "1.0.0", "vary": "~1.0.1" }, From a559ca2d58b0fcf9248148baf472460fd08e36ac Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 17:02:57 -0400 Subject: [PATCH 0895/1265] build: istanbul@0.3.17 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8e8bd20da8e..323f8084b37 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "devDependencies": { "after": "0.8.1", "ejs": "2.3.3", - "istanbul": "0.3.9", + "istanbul": "0.3.17", "marked": "0.3.5", "mocha": "2.2.5", "should": "7.0.2", From a4fcd91084eaedb36b7c150157236d5d563a4b02 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 17:03:30 -0400 Subject: [PATCH 0896/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 323f8084b37..3bee76bc601 100644 --- a/package.json +++ b/package.json @@ -61,13 +61,13 @@ "mocha": "2.2.5", "should": "7.0.2", "supertest": "1.0.1", - "body-parser": "~1.13.2", + "body-parser": "~1.13.3", "connect-redis": "~2.4.1", "cookie-parser": "~1.3.5", "cookie-session": "~1.2.0", "express-session": "~1.11.3", "jade": "~1.11.0", - "method-override": "~2.3.4", + "method-override": "~2.3.5", "morgan": "~1.6.1", "multiparty": "~4.1.2", "vhost": "~3.0.1" From 97b2d70d8adfb4649fd8ca9adc73c47ffcc4bf5b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 31 Jul 2015 17:09:15 -0400 Subject: [PATCH 0897/1265] 4.13.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 2284ffcc978..dc406139c24 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.13.2 / 2015-07-31 +=================== * deps: accepts@~1.2.12 - deps: mime-types@~2.1.4 diff --git a/package.json b/package.json index 3bee76bc601..3b4389e8bfe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.13.1", + "version": "4.13.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From ee90042d0c4a32a426842e4c1ad5b24b5c0344ac Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 3 Aug 2015 00:50:48 -0400 Subject: [PATCH 0898/1265] Fix infinite loop condition using mergeParams: true --- History.md | 5 +++++ lib/router/index.js | 9 ++++++--- test/app.router.js | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index dc406139c24..3cc3e11d21d 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix infinite loop condition using `mergeParams: true` + 4.13.2 / 2015-07-31 =================== diff --git a/lib/router/index.js b/lib/router/index.js index 1f3ec6d49ce..4b7e4c97eda 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -578,9 +578,12 @@ function mergeParams(params, parent) { var o = 0; // determine numeric gaps - while (i === o || o in parent) { - if (i in params) i++; - if (o in parent) o++; + while (i in params) { + i++; + } + + while (o in parent) { + o++; } // offset numeric indices in params before merge diff --git a/test/app.router.js b/test/app.router.js index f528a4cb21f..aa753e90e76 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -320,6 +320,22 @@ describe('app.router', function(){ .expect(200, '[["0","10"],["1","tj"],["2","profile"]]', done); }) + it('should merge numeric indices req.params when parent has same number', function(done){ + var app = express(); + var router = new express.Router({ mergeParams: true }); + + router.get('/name:(\\w+)', function(req, res){ + var keys = Object.keys(req.params).sort(); + res.send(keys.map(function(k){ return [k, req.params[k]] })); + }); + + app.use('/user/id:(\\d+)', router); + + request(app) + .get('/user/id:10/name:tj') + .expect(200, '[["0","10"],["1","tj"]]', done); + }) + it('should ignore invalid incoming req.params', function(done){ var app = express(); var router = new express.Router({ mergeParams: true }); From 11a77a3fffb0476a460c4e68536ce20f5b3c542f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 3 Aug 2015 01:01:16 -0400 Subject: [PATCH 0899/1265] Fix inner numeric indices incorrectly altering parent req.params --- History.md | 1 + lib/router/index.js | 2 +- test/app.router.js | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 3cc3e11d21d..d4eff1f7345 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Fix infinite loop condition using `mergeParams: true` + * Fix inner numeric indices incorrectly altering parent `req.params` 4.13.2 / 2015-07-31 =================== diff --git a/lib/router/index.js b/lib/router/index.js index 4b7e4c97eda..504ed9ce0ee 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -596,7 +596,7 @@ function mergeParams(params, parent) { } } - return mixin(parent, params); + return mixin(obj, params); } // restore obj props after function diff --git a/test/app.router.js b/test/app.router.js index aa753e90e76..03b43eb081a 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -354,6 +354,26 @@ describe('app.router', function(){ .get('/user/tj') .expect(200, '[["name","tj"]]', done); }) + + it('should restore req.params', function(done){ + var app = express(); + var router = new express.Router({ mergeParams: true }); + + router.get('/user:(\\w+)/*', function (req, res, next) { + next(); + }); + + app.use('/user/id:(\\d+)', function (req, res, next) { + router(req, res, function (err) { + var keys = Object.keys(req.params).sort(); + res.send(keys.map(function(k){ return [k, req.params[k]] })); + }); + }); + + request(app) + .get('/user/id:42/user:tj/profile') + .expect(200, '[["0","42"]]', done); + }) }) describe('trailing slashes', function(){ From ef7ad681b245fba023843ce94f6bcb8e275bbb8e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 3 Aug 2015 01:02:22 -0400 Subject: [PATCH 0900/1265] 4.13.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index d4eff1f7345..be89c8e7230 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.13.3 / 2015-08-02 +=================== * Fix infinite loop condition using `mergeParams: true` * Fix inner numeric indices incorrectly altering parent `req.params` diff --git a/package.json b/package.json index 3b4389e8bfe..3f299bada86 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.13.2", + "version": "4.13.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 2f8ac6726fa20ab5b4a05c112c886752868ac8ce Mon Sep 17 00:00:00 2001 From: Brendan Ashworth Date: Thu, 25 Jun 2015 00:30:19 -0700 Subject: [PATCH 0901/1265] tests: fix redirect tests for change in 302 status message closes #2690 --- test/res.redirect.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/test/res.redirect.js b/test/res.redirect.js index 4044ad49ee5..7ebc1ef01dc 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -1,6 +1,7 @@ -var express = require('../') - , request = require('supertest'); +var http = require('http'); +var express = require('..'); +var request = require('supertest'); describe('res', function(){ describe('.redirect(url)', function(){ @@ -83,11 +84,9 @@ describe('res', function(){ request(app) .get('/') .set('Accept', 'text/html') - .end(function(err, res){ - res.headers.should.have.property('location', 'http://google.com'); - res.text.should.equal('

Moved Temporarily. Redirecting to http://google.com

'); - done(); - }) + .expect('Content-Type', /html/) + .expect('Location', 'http://google.com') + .expect(302, '

' + http.STATUS_CODES[302] + '. Redirecting to http://google.com

', done); }) it('should escape the url', function(done){ @@ -101,10 +100,9 @@ describe('res', function(){ .get('/') .set('Host', 'http://example.com') .set('Accept', 'text/html') - .end(function(err, res){ - res.text.should.equal('

Moved Temporarily. Redirecting to <lame>

'); - done(); - }) + .expect('Content-Type', /html/) + .expect('Location', '') + .expect(302, '

' + http.STATUS_CODES[302] + '. Redirecting to <lame>

', done); }) it('should include the redirect type', function(done){ @@ -134,12 +132,9 @@ describe('res', function(){ request(app) .get('/') .set('Accept', 'text/plain, */*') - .end(function(err, res){ - res.headers.should.have.property('location', 'http://google.com'); - res.headers.should.have.property('content-length', '51'); - res.text.should.equal('Moved Temporarily. Redirecting to http://google.com'); - done(); - }) + .expect('Content-Type', /plain/) + .expect('Location', 'http://google.com') + .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://google.com', done); }) it('should encode the url', function(done){ @@ -153,10 +148,9 @@ describe('res', function(){ .get('/') .set('Host', 'http://example.com') .set('Accept', 'text/plain, */*') - .end(function(err, res){ - res.text.should.equal('Moved Temporarily. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E'); - done(); - }) + .expect('Content-Type', /plain/) + .expect('Location', 'http://example.com/?param=') + .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E', done); }) it('should include the redirect type', function(done){ From 5a4310e9da32bd1dc49977247615be253f56b1f7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Nov 2015 22:09:47 -0500 Subject: [PATCH 0902/1265] build: reduce runtime versions to one per major --- .travis.yml | 2 -- appveyor.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index df087b4a0f7..f1f609b5922 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,7 @@ language: node_js node_js: - "0.10" - "0.12" - - "1.0" - "1.8" - - "2.0" - "2.3" sudo: false before_install: "npm rm --save-dev connect-redis" diff --git a/appveyor.yml b/appveyor.yml index b1f13d167bd..5a8f3080bf1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,9 +2,7 @@ environment: matrix: - nodejs_version: "0.10" - nodejs_version: "0.12" - - nodejs_version: "1.0" - nodejs_version: "1.8" - - nodejs_version: "2.0" - nodejs_version: "2.3" install: - ps: Install-Product node $env:nodejs_version From 2f96412636ef04c5639e38768de0f2b526f02e32 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Nov 2015 22:16:06 -0500 Subject: [PATCH 0903/1265] build: io.js@2.5 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f1f609b5922..7c98d22d8eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "0.10" - "0.12" - "1.8" - - "2.3" + - "2.5" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index 5a8f3080bf1..bce7c64deeb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ environment: - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "1.8" - - nodejs_version: "2.3" + - nodejs_version: "2.5" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From 963d795d24ee951ce5382ccb0554f8a1960641e2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Nov 2015 22:47:15 -0500 Subject: [PATCH 0904/1265] build: support io.js 3.x --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7c98d22d8eb..cc679216af1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - "0.12" - "1.8" - "2.5" + - "3.3" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index bce7c64deeb..40ee0765374 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ environment: - nodejs_version: "0.12" - nodejs_version: "1.8" - nodejs_version: "2.5" + - nodejs_version: "3.3" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From 1a59246746045ff78d31a0cd997d3679010b7f4e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Nov 2015 22:49:44 -0500 Subject: [PATCH 0905/1265] build: mocha@2.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3f299bada86..99b8f85a949 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "ejs": "2.3.3", "istanbul": "0.3.17", "marked": "0.3.5", - "mocha": "2.2.5", + "mocha": "2.3.3", "should": "7.0.2", "supertest": "1.0.1", "body-parser": "~1.13.3", From 2f37f4b28d52c3ae18e5e1930ccc776647f86531 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Nov 2015 22:51:09 -0500 Subject: [PATCH 0906/1265] build: istanbul@0.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99b8f85a949..2a432203aea 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "devDependencies": { "after": "0.8.1", "ejs": "2.3.3", - "istanbul": "0.3.17", + "istanbul": "0.4.0", "marked": "0.3.5", "mocha": "2.3.3", "should": "7.0.2", From 9665aa2153c5eca8b6ccdc22ce43a0934475fae8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Nov 2015 22:57:04 -0500 Subject: [PATCH 0907/1265] build: supertest@1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a432203aea..25186caf064 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "marked": "0.3.5", "mocha": "2.3.3", "should": "7.0.2", - "supertest": "1.0.1", + "supertest": "1.1.0", "body-parser": "~1.13.3", "connect-redis": "~2.4.1", "cookie-parser": "~1.3.5", From 747fccfb44c61f309e1258959c6c3ad61bdc767c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Nov 2015 22:59:46 -0500 Subject: [PATCH 0908/1265] build: should@7.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25186caf064..2b983b810dc 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "istanbul": "0.4.0", "marked": "0.3.5", "mocha": "2.3.3", - "should": "7.0.2", + "should": "7.1.1", "supertest": "1.1.0", "body-parser": "~1.13.3", "connect-redis": "~2.4.1", From 5699d64b99412bb3251d265f272ba25be03fa0d3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 7 Nov 2015 00:15:39 -0500 Subject: [PATCH 0909/1265] build: ejs@2.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b983b810dc..27c165bb6c6 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "devDependencies": { "after": "0.8.1", - "ejs": "2.3.3", + "ejs": "2.3.4", "istanbul": "0.4.0", "marked": "0.3.5", "mocha": "2.3.3", From e5ec966b2f068e935ea1b33374fac133dd06cdc8 Mon Sep 17 00:00:00 2001 From: Alexander Shemetovsky Date: Tue, 25 Aug 2015 21:03:05 +0300 Subject: [PATCH 0910/1265] Fix param definition is jsdoc for app.render fixes #2741 --- lib/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index a9df9103540..0ee4def3890 100644 --- a/lib/application.js +++ b/lib/application.js @@ -522,7 +522,7 @@ app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead'); * }) * * @param {String} name - * @param {String|Function} options or fn + * @param {Object|Function} options or fn * @param {Function} callback * @public */ From 7a3b5aea11abbae6ce4be9094c3acd74e4af95c2 Mon Sep 17 00:00:00 2001 From: Ricardo Bin Date: Tue, 27 Oct 2015 09:50:42 -0200 Subject: [PATCH 0911/1265] tests: add test for res.send() without arguments closes #2778 closes #2783 --- test/res.send.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/res.send.js b/test/res.send.js index 23aa5f7911f..6eafb944966 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -5,6 +5,20 @@ var methods = require('methods'); var request = require('supertest'); describe('res', function(){ + describe('.send()', function(){ + it('should set body to ""', function(done){ + var app = express(); + + app.use(function(req, res){ + res.send(); + }); + + request(app) + .get('/') + .expect(200, '', done); + }) + }) + describe('.send(null)', function(){ it('should set body to ""', function(done){ var app = express(); From 42b944295a12e09426bc220aae0cd5c1b2410ae2 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Fri, 13 Nov 2015 13:35:09 -0800 Subject: [PATCH 0912/1265] Add Security document closes #2733 closes #2804 --- Readme.md | 4 ++++ Security.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Security.md diff --git a/Readme.md b/Readme.md index 8da83a517e1..d0c081ccfed 100644 --- a/Readme.md +++ b/Readme.md @@ -47,6 +47,10 @@ $ npm install express **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x). +###Security Issues + +If you discover a security vulnerability in Express, please see [Security Policies and Procedures](security.md). + ## Quick Start The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below: diff --git a/Security.md b/Security.md new file mode 100644 index 00000000000..0c6d82324f1 --- /dev/null +++ b/Security.md @@ -0,0 +1,53 @@ +# Security Policies and Procedures + +This document outlines security procedures and general policies for the Express +project. + + * [Reporting a Bug](#reporting-a-bug) + * [Disclosure Policy](#disclosure-policy) + * [Receiving Security Updates](#receiving-security-updates) + * [Comments on this Policy](#comments-on-this-policy) + +## Reporting a Bug + +The Express team and community take all security bugs in Express seriously. +Thank you for improving the security of Express. We appreciate your efforts and +responsible disclosure and will make every effort to acknowledge your +contributions. + +Report security bugs by emailing security@expressjs.com. Email to this address +is delivered to a subset of the core team who handle security issues. + +The security team will acknowledge your email within 24 hours, and will send a +more detailed response within 48 hours indicating the next steps in handling +your report. After the initial reply to your report, the security team will +endeavor to keep you informed of the progress towards a fix and full +announcement, and may ask for additional information or guidance. + +Report security bugs in third-party modules to the person or team maintaining +the module. You can also report a vulnerability through the +[Node Security Project](https://nodesecurity.io/report). + +## Disclosure Policy + +When the security team receives a security bug report, they will assign it to a +primary handler. This person will coordinate the fix and release process, +involving the following steps: + + * Confirm the problem and determine the affected versions. + * Audit code to find any potential similar problems. + * Prepare fixes for all releases still under maintenance. These fixes will be + released as fast as possible to npm. + +## Receiving Security Updates + +Security notifications will be distributed via the following methods. + + * https://groups.google.com/forum/#!forum/express-js + * http://blog.strongloop.com + * http://expressjs.com/advanced/security-updates.html + +## Comments on this Policy + +If you have suggestions on how this process could be improved please submit a +pull request or email security@expressjs.com to discuss. From 67116cc5e6fa34b64bc7444c65642c188a6ce0db Mon Sep 17 00:00:00 2001 From: Young Jae Sim Date: Thu, 3 Dec 2015 02:27:25 +0900 Subject: [PATCH 0913/1265] docs: remove link to Korean translation closes #2820 --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index d0c081ccfed..0f3f40ff14e 100644 --- a/Readme.md +++ b/Readme.md @@ -43,7 +43,6 @@ $ npm install express * Visit the [Wiki](https://github.com/strongloop/express/wiki) * [Google Group](https://groups.google.com/group/express-js) for discussion * [Русскоязычная документация](http://jsman.ru/express/) - * [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)] **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x). From 23f021a3e1643d72110de30925228350b4454d2e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 14 Dec 2015 23:10:31 -0500 Subject: [PATCH 0914/1265] build: support Node.js 4.x closes #2751 closes #2754 closes #2757 --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index cc679216af1..90852320663 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ node_js: - "1.8" - "2.5" - "3.3" + - "4.2" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index 40ee0765374..242bb8b0cb5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,7 @@ environment: - nodejs_version: "1.8" - nodejs_version: "2.5" - nodejs_version: "3.3" + - nodejs_version: "4.2" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From 60f8e77d66563757a85e489fd2966d9bac3a84d8 Mon Sep 17 00:00:00 2001 From: ChALkeR Date: Fri, 13 Nov 2015 10:04:40 +0300 Subject: [PATCH 0915/1265] deps: cookie@0.1.5 closes #2799 closes #2800 closes #2801 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index be89c8e7230..1820824c069 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: cookie@0.1.5 + - Throw on invalid values provided to `serialize` + 4.13.3 / 2015-08-02 =================== diff --git a/package.json b/package.json index 27c165bb6c6..90ea2e77790 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "array-flatten": "1.1.1", "content-disposition": "0.5.0", "content-type": "~1.0.1", - "cookie": "0.1.3", + "cookie": "0.1.5", "cookie-signature": "1.0.6", "debug": "~2.2.0", "depd": "~1.0.1", From 4416fb2746f01a76e4a4fc94100cdff1107130be Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Tue, 15 Dec 2015 10:19:19 -0800 Subject: [PATCH 0916/1265] docs: fix link to Security.md in Readme.md closes #2829 --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 0f3f40ff14e..9e2424ce915 100644 --- a/Readme.md +++ b/Readme.md @@ -48,7 +48,7 @@ $ npm install express ###Security Issues -If you discover a security vulnerability in Express, please see [Security Policies and Procedures](security.md). +If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md). ## Quick Start From 2b2a1b28f3cf92a27a87f4f8569e9fa3489b783c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 17 Dec 2015 20:51:32 -0500 Subject: [PATCH 0917/1265] deps: escape-html@~1.0.3 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1820824c069..63b6f72457d 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,10 @@ unreleased * deps: cookie@0.1.5 - Throw on invalid values provided to `serialize` + * deps: escape-html@~1.0.3 + - perf: enable strict mode + - perf: optimize string replacement + - perf: use faster string coercion 4.13.3 / 2015-08-02 =================== diff --git a/package.json b/package.json index 90ea2e77790..3a3007bb53a 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "cookie-signature": "1.0.6", "debug": "~2.2.0", "depd": "~1.0.1", - "escape-html": "1.0.2", + "escape-html": "~1.0.3", "etag": "~1.7.0", "finalhandler": "0.4.0", "fresh": "0.3.0", From 7d9350391413aa6cbacaad93271316e2c758501c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 17 Dec 2015 20:56:04 -0500 Subject: [PATCH 0918/1265] deps: finalhandler@0.4.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 63b6f72457d..4b16fc8714e 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,8 @@ unreleased - perf: enable strict mode - perf: optimize string replacement - perf: use faster string coercion + * deps: finalhandler@0.4.1 + - deps: escape-html@~1.0.3 4.13.3 / 2015-08-02 =================== diff --git a/package.json b/package.json index 3a3007bb53a..8b4f6b93d61 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "depd": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.7.0", - "finalhandler": "0.4.0", + "finalhandler": "0.4.1", "fresh": "0.3.0", "merge-descriptors": "1.0.0", "methods": "~1.1.1", From c95a1077d21e2fd58e24b4435cb9c40dd4495376 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 17 Dec 2015 20:58:41 -0500 Subject: [PATCH 0919/1265] deps: proxy-addr@~1.0.10 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4b16fc8714e..6398655b286 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,9 @@ unreleased - perf: use faster string coercion * deps: finalhandler@0.4.1 - deps: escape-html@~1.0.3 + * deps: proxy-addr@~1.0.10 + - deps: ipaddr.js@1.0.5 + - perf: enable strict mode 4.13.3 / 2015-08-02 =================== diff --git a/package.json b/package.json index 8b4f6b93d61..33ac81687be 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.0", "path-to-regexp": "0.1.7", - "proxy-addr": "~1.0.8", + "proxy-addr": "~1.0.10", "qs": "4.0.0", "range-parser": "~1.0.2", "send": "0.13.0", From 4f8167f23fddc80ecb12cff3a21c610e639fe738 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 17 Dec 2015 20:59:12 -0500 Subject: [PATCH 0920/1265] deps: range-parser@~1.0.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6398655b286..28c4648bfa5 100644 --- a/History.md +++ b/History.md @@ -12,6 +12,8 @@ unreleased * deps: proxy-addr@~1.0.10 - deps: ipaddr.js@1.0.5 - perf: enable strict mode + * deps: range-parser@~1.0.3 + - perf: enable strict mode 4.13.3 / 2015-08-02 =================== diff --git a/package.json b/package.json index 33ac81687be..1d701344fc9 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "path-to-regexp": "0.1.7", "proxy-addr": "~1.0.10", "qs": "4.0.0", - "range-parser": "~1.0.2", + "range-parser": "~1.0.3", "send": "0.13.0", "serve-static": "~1.10.0", "type-is": "~1.6.6", From c73b1bee51f72fd11ca7afa497f2737399decd57 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 17 Dec 2015 21:02:22 -0500 Subject: [PATCH 0921/1265] build: istanbul@0.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d701344fc9..06e53ef9aa0 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "devDependencies": { "after": "0.8.1", "ejs": "2.3.4", - "istanbul": "0.4.0", + "istanbul": "0.4.1", "marked": "0.3.5", "mocha": "2.3.3", "should": "7.1.1", From 249323919211fbb83363da09adaaf7060a123534 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 18 Dec 2015 15:09:34 -0500 Subject: [PATCH 0922/1265] build: mocha@2.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 06e53ef9aa0..bc8c9733b9a 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "ejs": "2.3.4", "istanbul": "0.4.1", "marked": "0.3.5", - "mocha": "2.3.3", + "mocha": "2.3.4", "should": "7.1.1", "supertest": "1.1.0", "body-parser": "~1.13.3", From e44f024dab675fbfa493136aa6305f093d7d2055 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 18 Dec 2015 15:10:33 -0500 Subject: [PATCH 0923/1265] deps: update example dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bc8c9733b9a..960a0578730 100644 --- a/package.json +++ b/package.json @@ -61,11 +61,11 @@ "mocha": "2.3.4", "should": "7.1.1", "supertest": "1.1.0", - "body-parser": "~1.13.3", + "body-parser": "~1.14.2", "connect-redis": "~2.4.1", - "cookie-parser": "~1.3.5", + "cookie-parser": "~1.4.1", "cookie-session": "~1.2.0", - "express-session": "~1.11.3", + "express-session": "~1.13.0", "jade": "~1.11.0", "method-override": "~2.3.5", "morgan": "~1.6.1", From f2cf28c2f3c0a3b5d5ab976a148a83f7e763ae18 Mon Sep 17 00:00:00 2001 From: Jordan Larson Date: Wed, 13 Jan 2016 15:32:08 -0600 Subject: [PATCH 0924/1265] docs: add link to Gitter --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index 9e2424ce915..d2407279fa5 100644 --- a/Readme.md +++ b/Readme.md @@ -42,6 +42,7 @@ $ npm install express * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules * Visit the [Wiki](https://github.com/strongloop/express/wiki) * [Google Group](https://groups.google.com/group/express-js) for discussion + * [Gitter](https://gitter.im/strongloop/express) for support and discussion * [Русскоязычная документация](http://jsman.ru/express/) **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x). From bd118c47dfdbc05a57cc10d4b791cdb91a203a7f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 16 Jan 2016 23:54:41 -0500 Subject: [PATCH 0925/1265] deps: serve-static@~1.10.1 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 28c4648bfa5..ca4f6556c0f 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,9 @@ unreleased - perf: enable strict mode * deps: range-parser@~1.0.3 - perf: enable strict mode + * deps: serve-static@~1.10.1 + - deps: escape-html@~1.0.3 + - deps: send@0.13.1 4.13.3 / 2015-08-02 =================== diff --git a/package.json b/package.json index 960a0578730..eaf0fbd242b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "qs": "4.0.0", "range-parser": "~1.0.3", "send": "0.13.0", - "serve-static": "~1.10.0", + "serve-static": "~1.10.1", "type-is": "~1.6.6", "utils-merge": "1.0.0", "vary": "~1.0.1" From 53ee474c442e268abae9bea5b49f68464bf61f4e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 16 Jan 2016 23:56:09 -0500 Subject: [PATCH 0926/1265] deps: send@0.13.1 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ca4f6556c0f..6f1904567b2 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,11 @@ unreleased - perf: enable strict mode * deps: range-parser@~1.0.3 - perf: enable strict mode + * deps: send@0.13.1 + - deps: depd@~1.1.0 + - deps: destroy@~1.0.4 + - deps: escape-html@~1.0.3 + - deps: range-parser@~1.0.3 * deps: serve-static@~1.10.1 - deps: escape-html@~1.0.3 - deps: send@0.13.1 diff --git a/package.json b/package.json index eaf0fbd242b..1e9fc8a14d7 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "proxy-addr": "~1.0.10", "qs": "4.0.0", "range-parser": "~1.0.3", - "send": "0.13.0", + "send": "0.13.1", "serve-static": "~1.10.1", "type-is": "~1.6.6", "utils-merge": "1.0.0", From 7c8456fcde6006faceab1fca659b088c7a915207 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 16 Jan 2016 23:57:07 -0500 Subject: [PATCH 0927/1265] deps: depd@~1.1.0 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6f1904567b2..1e93e7bdb47 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,9 @@ unreleased * deps: cookie@0.1.5 - Throw on invalid values provided to `serialize` + * deps: depd@~1.1.0 + - Support web browser loading + - perf: enable strict mode * deps: escape-html@~1.0.3 - perf: enable strict mode - perf: optimize string replacement diff --git a/package.json b/package.json index 1e9fc8a14d7..de8b09324a6 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "cookie": "0.1.5", "cookie-signature": "1.0.6", "debug": "~2.2.0", - "depd": "~1.0.1", + "depd": "~1.1.0", "escape-html": "~1.0.3", "etag": "~1.7.0", "finalhandler": "0.4.1", From 8eee818e0b697f85418d5eee9a86ab3a8e45105f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 16 Jan 2016 23:58:27 -0500 Subject: [PATCH 0928/1265] build: istanbul@0.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de8b09324a6..2299579285b 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "devDependencies": { "after": "0.8.1", "ejs": "2.3.4", - "istanbul": "0.4.1", + "istanbul": "0.4.2", "marked": "0.3.5", "mocha": "2.3.4", "should": "7.1.1", From 547ea368c2e1b915ed3ff1d844978d754b11c0ee Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 Jan 2016 18:00:59 -0500 Subject: [PATCH 0929/1265] deps: content-disposition@0.5.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 1e93e7bdb47..f71dac4875b 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ unreleased ========== + * deps: content-disposition@0.5.1 + - perf: enable strict mode * deps: cookie@0.1.5 - Throw on invalid values provided to `serialize` * deps: depd@~1.1.0 diff --git a/package.json b/package.json index 2299579285b..2f08acd9f37 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "dependencies": { "accepts": "~1.2.12", "array-flatten": "1.1.1", - "content-disposition": "0.5.0", + "content-disposition": "0.5.1", "content-type": "~1.0.1", "cookie": "0.1.5", "cookie-signature": "1.0.6", From 1589ce215348197f4c6a19effe7a07feff991c1d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 Jan 2016 18:51:24 -0500 Subject: [PATCH 0930/1265] deps: merge-descriptors@1.0.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f71dac4875b..78fb70063a7 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,8 @@ unreleased - perf: use faster string coercion * deps: finalhandler@0.4.1 - deps: escape-html@~1.0.3 + * deps: merge-descriptors@1.0.1 + - perf: enable strict mode * deps: proxy-addr@~1.0.10 - deps: ipaddr.js@1.0.5 - perf: enable strict mode diff --git a/package.json b/package.json index 2f08acd9f37..941c0a041a6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "etag": "~1.7.0", "finalhandler": "0.4.1", "fresh": "0.3.0", - "merge-descriptors": "1.0.0", + "merge-descriptors": "1.0.1", "methods": "~1.1.1", "on-finished": "~2.3.0", "parseurl": "~1.3.0", From e83eab85e4c97a51088822c1bc4bb8a1faf06f88 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 Jan 2016 22:17:13 -0500 Subject: [PATCH 0931/1265] deps: methods@~1.1.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 78fb70063a7..5b7a1fbb87d 100644 --- a/History.md +++ b/History.md @@ -16,6 +16,8 @@ unreleased - deps: escape-html@~1.0.3 * deps: merge-descriptors@1.0.1 - perf: enable strict mode + * deps: methods@~1.1.2 + - perf: enable strict mode * deps: proxy-addr@~1.0.10 - deps: ipaddr.js@1.0.5 - perf: enable strict mode diff --git a/package.json b/package.json index 941c0a041a6..14c6143664d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "finalhandler": "0.4.1", "fresh": "0.3.0", "merge-descriptors": "1.0.1", - "methods": "~1.1.1", + "methods": "~1.1.2", "on-finished": "~2.3.0", "parseurl": "~1.3.0", "path-to-regexp": "0.1.7", From f627ca8d0b434c8c0b8c66b82a453a49220d8a1f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 20 Jan 2016 00:56:56 -0500 Subject: [PATCH 0932/1265] deps: serve-static@~1.10.2 --- History.md | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 5b7a1fbb87d..897ee5c2459 100644 --- a/History.md +++ b/History.md @@ -28,8 +28,9 @@ unreleased - deps: destroy@~1.0.4 - deps: escape-html@~1.0.3 - deps: range-parser@~1.0.3 - * deps: serve-static@~1.10.1 + * deps: serve-static@~1.10.2 - deps: escape-html@~1.0.3 + - deps: parseurl@~1.3.0 - deps: send@0.13.1 4.13.3 / 2015-08-02 diff --git a/package.json b/package.json index 14c6143664d..9081300a16d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "qs": "4.0.0", "range-parser": "~1.0.3", "send": "0.13.1", - "serve-static": "~1.10.1", + "serve-static": "~1.10.2", "type-is": "~1.6.6", "utils-merge": "1.0.0", "vary": "~1.0.1" From 68474059742afae6bbcf60dafaccfa7a648e1de0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 20 Jan 2016 00:58:09 -0500 Subject: [PATCH 0933/1265] deps: parseurl@~1.3.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 897ee5c2459..45d426aaf6f 100644 --- a/History.md +++ b/History.md @@ -18,6 +18,8 @@ unreleased - perf: enable strict mode * deps: methods@~1.1.2 - perf: enable strict mode + * deps: parseurl@~1.3.1 + - perf: enable strict mode * deps: proxy-addr@~1.0.10 - deps: ipaddr.js@1.0.5 - perf: enable strict mode diff --git a/package.json b/package.json index 9081300a16d..1920a126e32 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "~2.3.0", - "parseurl": "~1.3.0", + "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", "proxy-addr": "~1.0.10", "qs": "4.0.0", From e7a02f6a256a06b670fec65bc1460bc858c9e60e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Jan 2016 20:59:53 -0500 Subject: [PATCH 0934/1265] build: move repository to expressjs --- Contributing.md | 6 +----- Readme.md | 18 +++++++----------- Security.md | 15 +++------------ examples/view-constructor/index.js | 4 ++-- examples/web-service/index.js | 2 +- package.json | 3 +-- test/acceptance/web-service.js | 2 +- 7 files changed, 16 insertions(+), 34 deletions(-) diff --git a/Contributing.md b/Contributing.md index 6dab84f125d..ce33ccd41c9 100644 --- a/Contributing.md +++ b/Contributing.md @@ -1,7 +1,4 @@ - -## Website Issues - -Issues for the expressjs.com website go here https://github.com/strongloop/expressjs.com +# Contributing ## PRs and Code contributions @@ -22,4 +19,3 @@ Things that will help get your question issue looked at: * Steps you have taken to debug it yourself. If you post a question and do not outline the above items or make it easy for us to understand and reproduce your issue, it will be closed. - diff --git a/Readme.md b/Readme.md index d2407279fa5..6e08454b263 100644 --- a/Readme.md +++ b/Readme.md @@ -37,16 +37,12 @@ $ npm install express ## Docs & Community - * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)] * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules - * Visit the [Wiki](https://github.com/strongloop/express/wiki) * [Google Group](https://groups.google.com/group/express-js) for discussion - * [Gitter](https://gitter.im/strongloop/express) for support and discussion + * [Gitter](https://gitter.im/expressjs/express) for support and discussion * [Русскоязычная документация](http://jsman.ru/express/) -**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x). - ###Security Issues If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md). @@ -94,7 +90,7 @@ $ npm start To view the examples, clone the Express repo and install the dependencies: ```bash -$ git clone git://github.com/strongloop/express.git --depth 1 +$ git clone git://github.com/expressjs/express.git --depth 1 $ cd express $ npm install ``` @@ -120,7 +116,7 @@ The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ' The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson] -[List of all contributors](https://github.com/strongloop/express/graphs/contributors) +[List of all contributors](https://github.com/expressjs/express/graphs/contributors) ## License @@ -130,12 +126,12 @@ The current lead maintainer is [Douglas Christopher Wilson](https://github.com/d [npm-url]: https://npmjs.org/package/express [downloads-image]: https://img.shields.io/npm/dm/express.svg [downloads-url]: https://npmjs.org/package/express -[travis-image]: https://img.shields.io/travis/strongloop/express/master.svg?label=linux -[travis-url]: https://travis-ci.org/strongloop/express +[travis-image]: https://img.shields.io/travis/expressjs/express/master.svg?label=linux +[travis-url]: https://travis-ci.org/expressjs/express [appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows [appveyor-url]: https://ci.appveyor.com/project/dougwilson/express -[coveralls-image]: https://img.shields.io/coveralls/strongloop/express/master.svg -[coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master +[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg +[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master [gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg [gratipay-url-visionmedia]: https://gratipay.com/visionmedia/ [gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg diff --git a/Security.md b/Security.md index 0c6d82324f1..d965a87bb0a 100644 --- a/Security.md +++ b/Security.md @@ -15,10 +15,9 @@ Thank you for improving the security of Express. We appreciate your efforts and responsible disclosure and will make every effort to acknowledge your contributions. -Report security bugs by emailing security@expressjs.com. Email to this address -is delivered to a subset of the core team who handle security issues. +Report security bugs by emailing the lead maintainer in the Readme.md file. -The security team will acknowledge your email within 24 hours, and will send a +The lead maintainer will acknowledge your email within 48 hours, and will send a more detailed response within 48 hours indicating the next steps in handling your report. After the initial reply to your report, the security team will endeavor to keep you informed of the progress towards a fix and full @@ -39,15 +38,7 @@ involving the following steps: * Prepare fixes for all releases still under maintenance. These fixes will be released as fast as possible to npm. -## Receiving Security Updates - -Security notifications will be distributed via the following methods. - - * https://groups.google.com/forum/#!forum/express-js - * http://blog.strongloop.com - * http://expressjs.com/advanced/security-updates.html - ## Comments on this Policy If you have suggestions on how this process could be improved please submit a -pull request or email security@expressjs.com to discuss. +pull request. diff --git a/examples/view-constructor/index.js b/examples/view-constructor/index.js index 173663f8095..195d32db0eb 100644 --- a/examples/view-constructor/index.js +++ b/examples/view-constructor/index.js @@ -23,7 +23,7 @@ app.engine('md', function(str, options, fn){ }); // pointing to a particular github repo to load files from it -app.set('views', 'strongloop/express'); +app.set('views', 'expressjs/express'); // register a new view constructor app.set('view', GithubView); @@ -36,7 +36,7 @@ app.get('/', function(req, res){ }); app.get('/Readme.md', function(req, res){ - // rendering a view from https://github.com/strongloop/express/blob/master/Readme.md + // rendering a view from https://github.com/expressjs/express/blob/master/Readme.md res.render('Readme.md'); }); diff --git a/examples/web-service/index.js b/examples/web-service/index.js index 4958c22450c..694e121d91b 100644 --- a/examples/web-service/index.js +++ b/examples/web-service/index.js @@ -49,7 +49,7 @@ var apiKeys = ['foo', 'bar', 'baz']; // these two objects will serve as our faux database var repos = [ - { name: 'express', url: 'http://github.com/strongloop/express' } + { name: 'express', url: 'http://github.com/expressjs/express' } , { name: 'stylus', url: 'http://github.com/learnboost/stylus' } , { name: 'cluster', url: 'http://github.com/learnboost/cluster' } ]; diff --git a/package.json b/package.json index 1920a126e32..798f43c935c 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,7 @@ "Young Jae Sim " ], "license": "MIT", - "repository": "strongloop/express", - "homepage": "http://expressjs.com/", + "repository": "expressjs/express", "keywords": [ "express", "framework", diff --git a/test/acceptance/web-service.js b/test/acceptance/web-service.js index 5868e92df95..521fa9fa28d 100644 --- a/test/acceptance/web-service.js +++ b/test/acceptance/web-service.js @@ -53,7 +53,7 @@ describe('web-service', function(){ .get('/api/repos?api-key=foo') .expect('Content-Type', 'application/json; charset=utf-8') .expect(/"name":"express"/) - .expect(/"url":"http:\/\/github.com\/strongloop\/express"/) + .expect(/"url":"http:\/\/github.com\/expressjs\/express"/) .expect(200, done) }) }) From 193bed2649c55c1fd362e46cd4702c773f3e7434 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Jan 2016 21:10:45 -0500 Subject: [PATCH 0935/1265] 4.13.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 45d426aaf6f..c72241b98d5 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.13.4 / 2016-01-21 +=================== * deps: content-disposition@0.5.1 - perf: enable strict mode diff --git a/package.json b/package.json index 798f43c935c..3165cc44d3d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.13.3", + "version": "4.13.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 05136550c7fa9d7671a03960cc86a717f0964d21 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 10 Feb 2016 18:21:46 -0500 Subject: [PATCH 0936/1265] docs: fix some links messed up from repository move commit closes #2861 closes #2867 --- Contributing.md | 5 ++++- Readme.md | 4 ++++ package.json | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Contributing.md b/Contributing.md index ce33ccd41c9..45bc153823f 100644 --- a/Contributing.md +++ b/Contributing.md @@ -1,4 +1,7 @@ -# Contributing + +## Website Issues + +Issues for the expressjs.com website go here https://github.com/strongloop/expressjs.com ## PRs and Code contributions diff --git a/Readme.md b/Readme.md index 6e08454b263..e9bfaeba20d 100644 --- a/Readme.md +++ b/Readme.md @@ -37,12 +37,16 @@ $ npm install express ## Docs & Community + * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)] * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules + * Visit the [Wiki](https://github.com/expressjs/express/wiki) * [Google Group](https://groups.google.com/group/express-js) for discussion * [Gitter](https://gitter.im/expressjs/express) for support and discussion * [Русскоязычная документация](http://jsman.ru/express/) +**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x). + ###Security Issues If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md). diff --git a/package.json b/package.json index 3165cc44d3d..0b0e791d1f5 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ ], "license": "MIT", "repository": "expressjs/express", + "homepage": "http://expressjs.com/", "keywords": [ "express", "framework", From b5a280111f94728e70aa1a22687e64aaf31abd81 Mon Sep 17 00:00:00 2001 From: Andy Fleming Date: Tue, 9 Feb 2016 14:25:32 -0800 Subject: [PATCH 0937/1265] Fix jsdoc comment for res.get closes #2882 --- lib/response.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/response.js b/lib/response.js index 641704b04ae..e813c52ec1e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -740,7 +740,7 @@ res.get = function(field){ * Clear cookie `name`. * * @param {String} name - * @param {Object} options + * @param {Object} [options] * @return {ServerResponse} for chaining * @public */ From 4bcbf67482471ac096fb39bf076ba5d40c0fe4da Mon Sep 17 00:00:00 2001 From: Sian January Date: Mon, 8 Feb 2016 13:52:23 +0000 Subject: [PATCH 0938/1265] docs: add branch & fork steps to contributing documentation closes #2881 --- Contributing.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Contributing.md b/Contributing.md index 45bc153823f..84c5b9ccef6 100644 --- a/Contributing.md +++ b/Contributing.md @@ -9,6 +9,18 @@ Issues for the expressjs.com website go here https://github.com/strongloop/expre * Follow existing coding style. * If you fix a bug, add a test. +## Branches + +* Use the `master` branch for bug fixes or minor work that is intended for the current release stream +* Use the correspondingly named branch, e.g. `5.0`, for anything intended for a future release of Express + +## Steps for contributing + +* [Create an issue](https://github.com/strongloop/express/issues/new) for the bug you want to fix or the feature that you want to add. +* Create your own [fork](https://github.com/strongloop/express) on github, then checkout your fork. +* Write your code in your local copy. It's good practice to create a branch for each new issue you work on, although not compulsory. +* To run the test suite, first install the dependencies by running `npm install`, then run `npm test`. +* If the tests pass, you can commit your changes to your fork and then create a pull request from there. Make sure to reference your issue from the pull request comments by including the issue number e.g. #123. ## Issues which are questions From dd2b8977747203343b37318a34b221d481e789e8 Mon Sep 17 00:00:00 2001 From: Muhammad Saqib Date: Thu, 25 Feb 2016 07:46:14 +0500 Subject: [PATCH 0939/1265] examples: comment the usage of process.nextTick closes #2903 closes #2908 --- examples/error/index.js | 3 +++ examples/view-locals/user.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/examples/error/index.js b/examples/error/index.js index d7db5015a13..94b3b4a4da3 100644 --- a/examples/error/index.js +++ b/examples/error/index.js @@ -31,6 +31,9 @@ app.get('/', function(req, res){ app.get('/next', function(req, res, next){ // We can also pass exceptions to next() + // The reason for process.nextTick() is to show that + // next() can be called inside an async operation, + // in real life it can be a DB read or HTTP request. process.nextTick(function(){ next(new Error('oh no!')); }); diff --git a/examples/view-locals/user.js b/examples/view-locals/user.js index 0e3373d548c..90ab1f389df 100644 --- a/examples/view-locals/user.js +++ b/examples/view-locals/user.js @@ -9,6 +9,9 @@ function User(name, age, species) { } User.all = function(fn){ + // process.nextTick makes sure this function API + // behaves in an asynchronous manner, like if it + // was a real DB query to read all users. process.nextTick(function(){ fn(null, users); }); From f3d99a4fdbe1531ea609e92c4d4ae6c269d78c7a Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Mon, 29 Feb 2016 11:26:14 -0800 Subject: [PATCH 0940/1265] docs: add base contributing guide closes #2918 --- Collaborator-Guide.md | 36 +++++++++++++++ Contributing.md | 102 ++++++++++++++++++++++++++++++++---------- 2 files changed, 115 insertions(+), 23 deletions(-) create mode 100644 Collaborator-Guide.md diff --git a/Collaborator-Guide.md b/Collaborator-Guide.md new file mode 100644 index 00000000000..84c5b9ccef6 --- /dev/null +++ b/Collaborator-Guide.md @@ -0,0 +1,36 @@ + +## Website Issues + +Issues for the expressjs.com website go here https://github.com/strongloop/expressjs.com + +## PRs and Code contributions + +* Tests must pass. +* Follow existing coding style. +* If you fix a bug, add a test. + +## Branches + +* Use the `master` branch for bug fixes or minor work that is intended for the current release stream +* Use the correspondingly named branch, e.g. `5.0`, for anything intended for a future release of Express + +## Steps for contributing + +* [Create an issue](https://github.com/strongloop/express/issues/new) for the bug you want to fix or the feature that you want to add. +* Create your own [fork](https://github.com/strongloop/express) on github, then checkout your fork. +* Write your code in your local copy. It's good practice to create a branch for each new issue you work on, although not compulsory. +* To run the test suite, first install the dependencies by running `npm install`, then run `npm test`. +* If the tests pass, you can commit your changes to your fork and then create a pull request from there. Make sure to reference your issue from the pull request comments by including the issue number e.g. #123. + +## Issues which are questions + +We will typically close any vague issues or questions that are specific to some app you are writing. Please double check the docs and other references before being trigger happy with posting a question issue. + +Things that will help get your question issue looked at: + +* Full and runnable JS code. +* Clear description of the problem or unexpected behavior. +* Clear description of the expected result. +* Steps you have taken to debug it yourself. + +If you post a question and do not outline the above items or make it easy for us to understand and reproduce your issue, it will be closed. diff --git a/Contributing.md b/Contributing.md index 84c5b9ccef6..3fb2b7c25f1 100644 --- a/Contributing.md +++ b/Contributing.md @@ -1,36 +1,92 @@ +# Node.js Community Contributing Guide 1.0 -## Website Issues +This document describes a very simple process suitable for most projects +in the Node.js ecosystem. Projects are encouraged to adopt this whether they +are hosted in the Node.js Foundation or not. -Issues for the expressjs.com website go here https://github.com/strongloop/expressjs.com +The goal of this document is to create a contribution process that: -## PRs and Code contributions +* Encourages new contributions. +* Encourages contributors to remain involved. +* Avoids unnecessary processes and bureaucracy whenever possible. +* Creates a transparent decision making process which makes it clear how +contributors can be involved in decision making. -* Tests must pass. -* Follow existing coding style. -* If you fix a bug, add a test. +This document is based on much prior art in the Node.js community, io.js, +and the Node.js project. -## Branches +## Vocabulary -* Use the `master` branch for bug fixes or minor work that is intended for the current release stream -* Use the correspondingly named branch, e.g. `5.0`, for anything intended for a future release of Express +* A **Contributor** is any individual creating or commenting on an issue or pull request. +* A **Committer** is a subset of contributors who have been given write access to the repository. +* A **TC (Technical Committee)** is a group of committers representing the required technical +expertise to resolve rare disputes. -## Steps for contributing +# Logging Issues -* [Create an issue](https://github.com/strongloop/express/issues/new) for the bug you want to fix or the feature that you want to add. -* Create your own [fork](https://github.com/strongloop/express) on github, then checkout your fork. -* Write your code in your local copy. It's good practice to create a branch for each new issue you work on, although not compulsory. -* To run the test suite, first install the dependencies by running `npm install`, then run `npm test`. -* If the tests pass, you can commit your changes to your fork and then create a pull request from there. Make sure to reference your issue from the pull request comments by including the issue number e.g. #123. +Log an issue for any question or problem you might have. When in doubt, log an issue, +any additional policies about what to include will be provided in the responses. The only +exception is security dislosures which should be sent privately. -## Issues which are questions +Committers may direct you to another repository, ask for additional clarifications, and +add appropriate metadata before the issue is addressed. -We will typically close any vague issues or questions that are specific to some app you are writing. Please double check the docs and other references before being trigger happy with posting a question issue. +Please be courteous, respectful, and every participant is expected to follow the +project's Code of Conduct. -Things that will help get your question issue looked at: +# Contributions + +Any change to resources in this repository must be through pull requests. This applies to all changes +to documentation, code, binary files, etc. Even long term committers and TC members must use +pull requests. + +No pull request can be merged without being reviewed. + +For non-trivial contributions, pull requests should sit for at least 36 hours to ensure that +contributors in other timezones have time to review. Consideration should also be given to +weekends and other holiday periods to ensure active committers all have reasonable time to +become involved in the discussion and review process if they wish. + +The default for each contribution is that it is accepted once no committer has an objection. +During review committers may also request that a specific contributor who is most versed in a +particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off" +process for contributions to land. Once all issues brought by committers are addressed it can +be landed by any committer. + +In the case of an objection being raised in a pull request by another committer, all involved +committers should seek to arrive at a consensus by way of addressing concerns being expressed +by discussion, compromise on the proposed change, or withdrawal of the proposed change. + +If a contribution is controversial and committers cannot agree about how to get it to land +or if it should land then it should be escalated to the TC. TC members should regularly +discuss pending contributions in order to find a resolution. It is expected that only a +small minority of issues be brought to the TC for resolution and that discussion and +compromise among committers be the default resolution mechanism. + +# Becoming a Committer + +All contributors who land a non-trivial contribution should be on-boarded in a timely manner, +and added as a committer, and be given write access to the repository. + +Committers are expected to follow this policy and continue to send pull requests, go through +proper review, and have other committers merge their pull requests. + +# TC Process + +The TC uses a "consensus seeking" process for issues that are escalated to the TC. +The group tries to find a resolution that has no open objections among TC members. +If a consensus cannot be reached that has no objections then a majority wins vote +is called. It is also expected that the majority of decisions made by the TC are via +a consensus seeking process and that voting is only used as a last-resort. + +Resolution may involve returning the issue to committers with suggestions on how to +move forward towards a consensus. It is not expected that a meeting of the TC +will resolve all issues on its agenda during that meeting and may prefer to continue +the discussion happening among the committers. + +Members can be added to the TC at any time. Any committer can nominate another committer +to the TC and the TC uses its standard consensus seeking process to evaluate whether or +not to add this new member. Members who do not participate consistently at the level of +a majority of the other members are expected to resign. -* Full and runnable JS code. -* Clear description of the problem or unexpected behavior. -* Clear description of the expected result. -* Steps you have taken to debug it yourself. -If you post a question and do not outline the above items or make it easy for us to understand and reproduce your issue, it will be closed. From bb84cf955f5f84edc8938c00ec8590599861abca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Thu, 5 May 2016 10:34:40 +0200 Subject: [PATCH 0941/1265] tests: add test for signed cookie without secret closes #2986 --- test/res.cookie.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/res.cookie.js b/test/res.cookie.js index 8de6c0c6e37..543af99dcdd 100644 --- a/test/res.cookie.js +++ b/test/res.cookie.js @@ -150,6 +150,22 @@ describe('res', function(){ }) }) + describe('signed without secret', function(){ + it('should throw an error', function(done){ + var app = express(); + + app.use(cookieParser()); + + app.use(function(req, res){ + res.cookie('name', 'tobi', { signed: true }).end(); + }); + + request(app) + .get('/') + .expect(500, /secret\S+ required for signed cookies/, done); + }) + }) + describe('.signedCookie(name, string)', function(){ it('should set a signed cookie', function(done){ var app = express(); From 8931b2311a096515a59398702c8898d88d21515c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 10 May 2016 12:42:16 -0400 Subject: [PATCH 0942/1265] build: Node.js@4.4 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90852320663..53b5041a6b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: - "1.8" - "2.5" - "3.3" - - "4.2" + - "4.4" sudo: false before_install: "npm rm --save-dev connect-redis" script: "npm run-script test-ci" diff --git a/appveyor.yml b/appveyor.yml index 242bb8b0cb5..4484e8224c1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ environment: - nodejs_version: "1.8" - nodejs_version: "2.5" - nodejs_version: "3.3" - - nodejs_version: "4.2" + - nodejs_version: "4.4" install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis From 12bc16e72fe34ce7e3658679b694e47dce56ae7a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 10 May 2016 12:34:26 -0400 Subject: [PATCH 0943/1265] tests: use supertest to check response header values closes #2983 closes #2992 --- test/acceptance/cookies.js | 19 +++++------- test/acceptance/downloads.js | 7 ++--- test/middleware.basic.js | 9 ++---- test/res.jsonp.js | 8 ++--- test/res.location.js | 6 ++-- test/res.redirect.js | 29 ++++++------------ test/res.send.js | 59 +++++++++++------------------------- test/res.sendFile.js | 36 +++++++--------------- test/res.vary.js | 11 ++----- test/support/utils.js | 24 +++++++++++++++ 10 files changed, 81 insertions(+), 127 deletions(-) create mode 100644 test/support/utils.js diff --git a/test/acceptance/cookies.js b/test/acceptance/cookies.js index 86add660c73..aa9e1faef44 100644 --- a/test/acceptance/cookies.js +++ b/test/acceptance/cookies.js @@ -1,6 +1,7 @@ var app = require('../../examples/cookies') , request = require('supertest'); +var utils = require('../support/utils'); describe('cookies', function(){ describe('GET /', function(){ @@ -13,10 +14,8 @@ describe('cookies', function(){ it('should respond with no cookies', function(done){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.not.have.property('set-cookie') - done() - }) + .expect(utils.shouldNotHaveHeader('Set-Cookie')) + .expect(200, done) }) it('should respond to cookie', function(done){ @@ -57,20 +56,16 @@ describe('cookies', function(){ .post('/') .type('urlencoded') .send({ remember: 1 }) - .expect(302, function(err, res){ - res.headers.should.have.property('set-cookie') - done() - }) + .expect('Set-Cookie', /remember=1/) + .expect(302, done) }) it('should no set cookie w/o reminder', function(done){ request(app) .post('/') .send({}) - .expect(302, function(err, res){ - res.headers.should.not.have.property('set-cookie') - done() - }) + .expect(utils.shouldNotHaveHeader('Set-Cookie')) + .expect(302, done) }) }) }) diff --git a/test/acceptance/downloads.js b/test/acceptance/downloads.js index ed9a02f9ced..a0aa7b75d9f 100644 --- a/test/acceptance/downloads.js +++ b/test/acceptance/downloads.js @@ -15,11 +15,8 @@ describe('downloads', function(){ it('should have a download header', function(done){ request(app) .get('/files/amazing.txt') - .end(function(err, res){ - res.status.should.equal(200); - res.headers.should.have.property('content-disposition', 'attachment; filename="amazing.txt"') - done() - }) + .expect('Content-Disposition', 'attachment; filename="amazing.txt"') + .expect(200, done) }) }) diff --git a/test/middleware.basic.js b/test/middleware.basic.js index 3e1f1813848..28a4dd18f2e 100644 --- a/test/middleware.basic.js +++ b/test/middleware.basic.js @@ -32,13 +32,8 @@ describe('middleware', function(){ .get('/') .set('Content-Type', 'application/json') .send('{"foo":"bar"}') - .end(function(err, res){ - if (err) return done(err); - res.headers.should.have.property('content-type', 'application/json'); - res.statusCode.should.equal(200); - res.text.should.equal('{"foo":"bar"}'); - done(); - }) + .expect('Content-Type', 'application/json') + .expect(200, '{"foo":"bar"}', done) }) }) }) diff --git a/test/res.jsonp.js b/test/res.jsonp.js index 4892a56ef6f..64b41fb9a6b 100644 --- a/test/res.jsonp.js +++ b/test/res.jsonp.js @@ -2,6 +2,7 @@ var express = require('../') , request = require('supertest') , assert = require('assert'); +var utils = require('./support/utils'); describe('res', function(){ describe('.jsonp(object)', function(){ @@ -136,11 +137,8 @@ describe('res', function(){ request(app) .get('/') .expect('Content-Type', 'application/vnd.example+json; charset=utf-8') - .expect(200, '{"hello":"world"}', function (err, res) { - if (err) return done(err); - res.headers.should.not.have.property('x-content-type-options'); - done(); - }); + .expect(utils.shouldNotHaveHeader('X-Content-Type-Options')) + .expect(200, '{"hello":"world"}', done); }) it('should override previous Content-Types with callback', function(done){ diff --git a/test/res.location.js b/test/res.location.js index 6481160174a..2b42bf358d4 100644 --- a/test/res.location.js +++ b/test/res.location.js @@ -13,10 +13,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.have.property('location', 'http://google.com'); - done(); - }) + .expect('Location', 'http://google.com') + .expect(200, done) }) }) }) diff --git a/test/res.redirect.js b/test/res.redirect.js index 7ebc1ef01dc..8511c40f2ab 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -2,6 +2,7 @@ var http = require('http'); var express = require('..'); var request = require('supertest'); +var utils = require('./support/utils'); describe('res', function(){ describe('.redirect(url)', function(){ @@ -29,11 +30,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.statusCode.should.equal(303); - res.headers.should.have.property('location', 'http://google.com'); - done(); - }) + .expect('Location', 'http://google.com') + .expect(303, done) }) }) @@ -47,11 +45,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.statusCode.should.equal(303); - res.headers.should.have.property('location', 'http://google.com'); - done(); - }) + .expect('Location', 'http://google.com') + .expect(303, done) }) }) @@ -65,11 +60,8 @@ describe('res', function(){ request(app) .head('/') - .end(function(err, res){ - res.headers.should.have.property('location', 'http://google.com'); - res.text.should.equal(''); - done(); - }) + .expect('Location', 'http://google.com') + .expect(302, '', done) }) }) @@ -182,11 +174,8 @@ describe('res', function(){ .set('Accept', 'application/octet-stream') .expect('location', 'http://google.com') .expect('content-length', '0') - .expect(302, '', function(err, res){ - if (err) return done(err) - res.headers.should.not.have.property('content-type'); - done(); - }) + .expect(utils.shouldNotHaveHeader('Content-Type')) + .expect(302, '', done) }) }) }) diff --git a/test/res.send.js b/test/res.send.js index 6eafb944966..719424657c4 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -3,6 +3,7 @@ var assert = require('assert'); var express = require('..'); var methods = require('methods'); var request = require('supertest'); +var utils = require('./support/utils'); describe('res', function(){ describe('.send()', function(){ @@ -118,12 +119,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/html; charset=utf-8'); - res.text.should.equal('

hey

'); - res.statusCode.should.equal(200); - done(); - }) + .expect('Content-Type', 'text/html; charset=utf-8') + .expect(200, '

hey

', done); }) it('should set ETag', function (done) { @@ -190,12 +187,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'application/octet-stream'); - res.text.should.equal('hello'); - res.statusCode.should.equal(200); - done(); - }) + .expect('Content-Type', 'application/octet-stream') + .expect(200, 'hello', done); }) it('should set ETag', function (done) { @@ -221,12 +214,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.have.property('content-type', 'text/plain; charset=utf-8'); - res.text.should.equal('hey'); - res.statusCode.should.equal(200); - done(); - }) + .expect('Content-Type', 'text/plain; charset=utf-8') + .expect(200, 'hey', done); }) }) @@ -269,13 +258,10 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.not.have.property('content-type'); - res.headers.should.not.have.property('content-length'); - res.headers.should.not.have.property('transfer-encoding'); - res.text.should.equal(''); - done(); - }) + .expect(utils.shouldNotHaveHeader('Content-Type')) + .expect(utils.shouldNotHaveHeader('Content-Length')) + .expect(utils.shouldNotHaveHeader('Transfer-Encoding')) + .expect(204, '', done); }) }) @@ -289,13 +275,10 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers.should.not.have.property('content-type'); - res.headers.should.not.have.property('content-length'); - res.headers.should.not.have.property('transfer-encoding'); - res.text.should.equal(''); - done(); - }) + .expect(utils.shouldNotHaveHeader('Content-Type')) + .expect(utils.shouldNotHaveHeader('Content-Length')) + .expect(utils.shouldNotHaveHeader('Transfer-Encoding')) + .expect(304, '', done); }) }) @@ -451,7 +434,7 @@ describe('res', function(){ request(app) .get('/') - .expect(shouldNotHaveHeader('ETag')) + .expect(utils.shouldNotHaveHeader('ETag')) .expect(200, done); }) }); @@ -469,7 +452,7 @@ describe('res', function(){ request(app) .get('/') - .expect(shouldNotHaveHeader('ETag')) + .expect(utils.shouldNotHaveHeader('ETag')) .expect(200, done); }); @@ -559,15 +542,9 @@ describe('res', function(){ request(app) .get('/') - .expect(shouldNotHaveHeader('ETag')) + .expect(utils.shouldNotHaveHeader('ETag')) .expect(200, done); }) }) }) }) - -function shouldNotHaveHeader(header) { - return function (res) { - assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header) - } -} diff --git a/test/res.sendFile.js b/test/res.sendFile.js index f4868b39766..78013a50ebd 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -7,6 +7,7 @@ var onFinished = require('on-finished'); var path = require('path'); var should = require('should'); var fixtures = path.join(__dirname, 'fixtures'); +var utils = require('./support/utils'); describe('res', function(){ describe('.sendFile(path)', function () { @@ -154,11 +155,8 @@ describe('res', function(){ request(app) .get('/') - .expect(404, function (err, res) { - if (err) return done(err); - res.headers.should.not.have.property('x-success'); - done(); - }); + .expect(utils.shouldNotHaveHeader('X-Success')) + .expect(404, done); }); }); @@ -509,11 +507,8 @@ describe('res', function(){ request(app) .get('/') - .expect(404, function (err, res) { - if (err) return done(err); - res.headers.should.not.have.property('x-success'); - done(); - }); + .expect(utils.shouldNotHaveHeader('X-Success')) + .expect(404, done); }) it('should transfer a file', function (done) { @@ -595,11 +590,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.text.should.equal('

{{user.name}}

'); - res.headers.should.have.property('content-type', 'text/html; charset=UTF-8'); - done(); - }); + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect(200, '

{{user.name}}

', done); }) }) @@ -613,11 +605,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.text.should.equal('

{{user.name}}

'); - res.headers.should.have.property('content-type', 'text/html; charset=UTF-8'); - done(); - }); + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect(200, '

{{user.name}}

', done); }) it('should serve relative to "root"', function(done){ @@ -629,11 +618,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.text.should.equal('

{{user.name}}

'); - res.headers.should.have.property('content-type', 'text/html; charset=UTF-8'); - done(); - }); + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect(200, '

{{user.name}}

', done); }) it('should consider ../ malicious when "root" is not set', function(done){ diff --git a/test/res.vary.js b/test/res.vary.js index 13c3af2bb70..9a2edd24c09 100644 --- a/test/res.vary.js +++ b/test/res.vary.js @@ -2,6 +2,7 @@ var assert = require('assert'); var express = require('..'); var request = require('supertest'); +var utils = require('./support/utils'); describe('res.vary()', function(){ describe('with no arguments', function(){ @@ -15,7 +16,7 @@ describe('res.vary()', function(){ request(app) .get('/') - .expect(shouldNotHaveHeader('Vary')) + .expect(utils.shouldNotHaveHeader('Vary')) .expect(200, done); }) }) @@ -31,7 +32,7 @@ describe('res.vary()', function(){ request(app) .get('/') - .expect(shouldNotHaveHeader('Vary')) + .expect(utils.shouldNotHaveHeader('Vary')) .expect(200, done); }) }) @@ -88,9 +89,3 @@ describe('res.vary()', function(){ }) }) }) - -function shouldNotHaveHeader(header) { - return function (res) { - assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header); - }; -} diff --git a/test/support/utils.js b/test/support/utils.js new file mode 100644 index 00000000000..ec6b801bc09 --- /dev/null +++ b/test/support/utils.js @@ -0,0 +1,24 @@ + +/** + * Module dependencies. + * @private + */ +var assert = require('assert'); + +/** + * Module exports. + * @public + */ +exports.shouldNotHaveHeader = shouldNotHaveHeader; + +/** + * Assert that a supertest response does not have a header. + * + * @param {string} header Header name to check + * @returns {function} + */ +function shouldNotHaveHeader(header) { + return function (res) { + assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header); + }; +} From 3d56e7374d7d1e812c7851eacb7593bd41963a23 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Thu, 12 May 2016 14:18:43 -0700 Subject: [PATCH 0944/1265] docs: update location of expressjs.com repo closes #2995 --- Collaborator-Guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Collaborator-Guide.md b/Collaborator-Guide.md index 84c5b9ccef6..abbfc109429 100644 --- a/Collaborator-Guide.md +++ b/Collaborator-Guide.md @@ -1,7 +1,7 @@ ## Website Issues -Issues for the expressjs.com website go here https://github.com/strongloop/expressjs.com +Open issues for the expressjs.com website in https://github.com/expressjs/expressjs.com. ## PRs and Code contributions @@ -16,8 +16,8 @@ Issues for the expressjs.com website go here https://github.com/strongloop/expre ## Steps for contributing -* [Create an issue](https://github.com/strongloop/express/issues/new) for the bug you want to fix or the feature that you want to add. -* Create your own [fork](https://github.com/strongloop/express) on github, then checkout your fork. +* [Create an issue](https://github.com/expressjs/express/issues/new) for the bug you want to fix or the feature that you want to add. +* Create your own [fork](https://github.com/expressjs/express) on github, then checkout your fork. * Write your code in your local copy. It's good practice to create a branch for each new issue you work on, although not compulsory. * To run the test suite, first install the dependencies by running `npm install`, then run `npm test`. * If the tests pass, you can commit your changes to your fork and then create a pull request from there. Make sure to reference your issue from the pull request comments by including the issue number e.g. #123. From 741a5aac9cf287ce4072e3e458c2bbaab0bca355 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 22:12:31 -0400 Subject: [PATCH 0945/1265] build: cache node_modules on CI --- .travis.yml | 11 ++++++++++- appveyor.yml | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 53b5041a6b4..38998527547 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,15 @@ node_js: - "3.3" - "4.4" sudo: false -before_install: "npm rm --save-dev connect-redis" +cache: + directories: + - node_modules +before_install: + # Remove all non-test dependencies + - "npm rm --save-dev connect-redis" + + # Update Node.js modules + - "test ! -d node_modules || npm prune" + - "test ! -d node_modules || npm rebuild" script: "npm run-script test-ci" after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls" diff --git a/appveyor.yml b/appveyor.yml index 4484e8224c1..ce5e52ff1b9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,9 +6,13 @@ environment: - nodejs_version: "2.5" - nodejs_version: "3.3" - nodejs_version: "4.4" +cache: + - node_modules install: - ps: Install-Product node $env:nodejs_version - npm rm --save-dev connect-redis + - if exist node_modules npm prune + - if exist node_modules npm rebuild - npm install build: off test_script: From 20a25489de13f3726d68c606411861a73acfa6b5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 22:39:59 -0400 Subject: [PATCH 0946/1265] build: ejs@2.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0b0e791d1f5..5f90cc4e9f8 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "devDependencies": { "after": "0.8.1", - "ejs": "2.3.4", + "ejs": "2.4.1", "istanbul": "0.4.2", "marked": "0.3.5", "mocha": "2.3.4", From 992cd085fb4af69ec838d42b3f51d44c9d852968 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 22:41:26 -0400 Subject: [PATCH 0947/1265] build: istanbul@0.4.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f90cc4e9f8..6f950674682 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "devDependencies": { "after": "0.8.1", "ejs": "2.4.1", - "istanbul": "0.4.2", + "istanbul": "0.4.3", "marked": "0.3.5", "mocha": "2.3.4", "should": "7.1.1", From d7ae24228dbce8d8e384aa9f9e054fc24d4309eb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 22:44:48 -0400 Subject: [PATCH 0948/1265] build: mocha@2.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f950674682..c9ddea9d261 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "ejs": "2.4.1", "istanbul": "0.4.3", "marked": "0.3.5", - "mocha": "2.3.4", + "mocha": "2.5.1", "should": "7.1.1", "supertest": "1.1.0", "body-parser": "~1.14.2", From fd48bfe8fe0f8d0cfd3c58475bb89deabb9edb36 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 22:47:25 -0400 Subject: [PATCH 0949/1265] build: should@8.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9ddea9d261..404a3dea739 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "istanbul": "0.4.3", "marked": "0.3.5", "mocha": "2.5.1", - "should": "7.1.1", + "should": "8.4.0", "supertest": "1.1.0", "body-parser": "~1.14.2", "connect-redis": "~2.4.1", From e3dd191d54a0a4adfb906af4b12e5fdc4627a2d3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 23:00:43 -0400 Subject: [PATCH 0950/1265] examples: escape HTML in markdown example --- examples/markdown/index.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/examples/markdown/index.js b/examples/markdown/index.js index db2f16fb482..430628701fd 100644 --- a/examples/markdown/index.js +++ b/examples/markdown/index.js @@ -2,9 +2,10 @@ * Module dependencies. */ +var escapeHtml = require('escape-html'); var express = require('../..'); var fs = require('fs'); -var md = require('marked').parse; +var marked = require('marked'); var app = module.exports = express(); @@ -13,15 +14,10 @@ var app = module.exports = express(); app.engine('md', function(path, options, fn){ fs.readFile(path, 'utf8', function(err, str){ if (err) return fn(err); - try { - var html = md(str); - html = html.replace(/\{([^}]+)\}/g, function(_, name){ - return options[name] || ''; - }); - fn(null, html); - } catch(err) { - fn(err); - } + var html = marked.parse(str).replace(/\{([^}]+)\}/g, function(_, name){ + return escapeHtml(options[name] || ''); + }); + fn(null, html); }); }); From 31dd549f350accd7b4e3685c13f745e857557827 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 23:03:13 -0400 Subject: [PATCH 0951/1265] tests: add test for dispatching to empty route --- test/Route.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Route.js b/test/Route.js index c979fb110c6..ada54086bf0 100644 --- a/test/Route.js +++ b/test/Route.js @@ -7,6 +7,11 @@ var express = require('../') , assert = require('assert'); describe('Route', function(){ + it('should work without handlers', function(done) { + var req = { method: 'GET', url: '/' } + var route = new Route('/foo') + route.dispatch(req, {}, done) + }) describe('.all', function(){ it('should add handler', function(done){ From e5502690d2db1b2ca9f78d0025176b29d834c3ba Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 23:15:52 -0400 Subject: [PATCH 0952/1265] deps: accepts@~1.3.3 --- History.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c72241b98d5..562e7214a4b 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,14 @@ +unreleased +========== + + * deps: accepts@~1.3.3 + - Fix including type extensions in parameters in `Accept` parsing + - Fix parsing `Accept` parameters with quoted equals + - Fix parsing `Accept` parameters with quoted semicolons + - Many performance improvments + - deps: mime-types@~2.1.11 + - deps: negotiator@0.6.1 + 4.13.4 / 2016-01-21 =================== diff --git a/package.json b/package.json index 404a3dea739..dc21ce4f673 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.2.12", + "accepts": "~1.3.3", "array-flatten": "1.1.1", "content-disposition": "0.5.1", "content-type": "~1.0.1", From 2cf830b29e7260afe1e414a80850a014556ba429 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 May 2016 23:18:41 -0400 Subject: [PATCH 0953/1265] deps: content-type@~1.0.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 562e7214a4b..a88d5a76e17 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ unreleased - Many performance improvments - deps: mime-types@~2.1.11 - deps: negotiator@0.6.1 + * deps: content-type@~1.0.2 + - perf: enable strict mode 4.13.4 / 2016-01-21 =================== diff --git a/package.json b/package.json index dc21ce4f673..278adfa0f6b 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "accepts": "~1.3.3", "array-flatten": "1.1.1", "content-disposition": "0.5.1", - "content-type": "~1.0.1", + "content-type": "~1.0.2", "cookie": "0.1.5", "cookie-signature": "1.0.6", "debug": "~2.2.0", From 76c56d1ab88dd253e90b39e621dcef20219a7204 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 29 May 2016 14:25:27 -0400 Subject: [PATCH 0954/1265] deps: vary@~1.1.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a88d5a76e17..7e4b0571f53 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,8 @@ unreleased - deps: negotiator@0.6.1 * deps: content-type@~1.0.2 - perf: enable strict mode + * deps: vary@~1.1.0 + - Only accept valid field names in the `field` argument 4.13.4 / 2016-01-21 =================== diff --git a/package.json b/package.json index 278adfa0f6b..4a9101ebc59 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "serve-static": "~1.10.2", "type-is": "~1.6.6", "utils-merge": "1.0.0", - "vary": "~1.0.1" + "vary": "~1.1.0" }, "devDependencies": { "after": "0.8.1", From bdf604a77e8bab6c7f47e85eca77c21b84d5b33e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 31 May 2016 00:08:16 -0400 Subject: [PATCH 0955/1265] deps: cookie@0.3.1 --- History.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7e4b0571f53..347b4d9607c 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,17 @@ unreleased - deps: negotiator@0.6.1 * deps: content-type@~1.0.2 - perf: enable strict mode + * deps: cookie@0.3.1 + - Add `sameSite` option + - Fix cookie `Max-Age` to never be a floating point number + - Improve error message when `encode` is not a function + - Improve error message when `expires` is not a `Date` + - Throw better error for invalid argument to parse + - Throw on invalid values provided to `serialize` + - perf: enable strict mode + - perf: hoist regular expression + - perf: use for loop in parse + - perf: use string concatination for serialization * deps: vary@~1.1.0 - Only accept valid field names in the `field` argument diff --git a/package.json b/package.json index 4a9101ebc59..0202c782265 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "array-flatten": "1.1.1", "content-disposition": "0.5.1", "content-type": "~1.0.2", - "cookie": "0.1.5", + "cookie": "0.3.1", "cookie-signature": "1.0.6", "debug": "~2.2.0", "depd": "~1.1.0", From c6039af39d6bc50edfbdd7c822c79e97ba86fc4f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 31 May 2016 00:12:54 -0400 Subject: [PATCH 0956/1265] deps: proxy-addr@~1.1.2 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 347b4d9607c..9aa6b0acc03 100644 --- a/History.md +++ b/History.md @@ -21,6 +21,12 @@ unreleased - perf: hoist regular expression - perf: use for loop in parse - perf: use string concatination for serialization + * deps: proxy-addr@~1.1.2 + - Fix accepting various invalid netmasks + - Fix IPv6-mapped IPv4 validation edge cases + - IPv4 netmasks must be contingous + - IPv6 addresses cannot be used as a netmask + - deps: ipaddr.js@1.1.1 * deps: vary@~1.1.0 - Only accept valid field names in the `field` argument diff --git a/package.json b/package.json index 0202c782265..1206e08e991 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", - "proxy-addr": "~1.0.10", + "proxy-addr": "~1.1.2", "qs": "4.0.0", "range-parser": "~1.0.3", "send": "0.13.1", From b69b7605b07b41273acc931d25ab585377bcd107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Sanz?= Date: Mon, 3 Aug 2015 23:21:38 +0200 Subject: [PATCH 0957/1265] perf: use strict equality when possible closes #2722 --- History.md | 1 + lib/request.js | 6 +++--- lib/response.js | 2 +- lib/router/index.js | 2 +- lib/utils.js | 8 ++++---- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/History.md b/History.md index 9aa6b0acc03..764974d0788 100644 --- a/History.md +++ b/History.md @@ -29,6 +29,7 @@ unreleased - deps: ipaddr.js@1.1.1 * deps: vary@~1.1.0 - Only accept valid field names in the `field` argument + * perf: use strict equality when possible 4.13.4 / 2016-01-21 =================== diff --git a/lib/request.js b/lib/request.js index 33cac180ed7..4fdc279ebcb 100644 --- a/lib/request.js +++ b/lib/request.js @@ -303,7 +303,7 @@ defineGetter(req, 'protocol', function protocol(){ /** * Short-hand for: * - * req.protocol == 'https' + * req.protocol === 'https' * * @return {Boolean} * @public @@ -437,10 +437,10 @@ defineGetter(req, 'fresh', function(){ var s = this.res.statusCode; // GET or HEAD for weak freshness validation only - if ('GET' != method && 'HEAD' != method) return false; + if ('GET' !== method && 'HEAD' !== method) return false; // 2xx or 304 as per rfc2616 14.26 - if ((s >= 200 && s < 300) || 304 == s) { + if ((s >= 200 && s < 300) || 304 === s) { return fresh(this.headers, (this.res._headers || {})); } diff --git a/lib/response.js b/lib/response.js index e813c52ec1e..b93459cff56 100644 --- a/lib/response.js +++ b/lib/response.js @@ -189,7 +189,7 @@ res.send = function send(body) { if (req.fresh) this.statusCode = 304; // strip irrelevant headers - if (204 == this.statusCode || 304 == this.statusCode) { + if (204 === this.statusCode || 304 === this.statusCode) { this.removeHeader('Content-Type'); this.removeHeader('Content-Length'); this.removeHeader('Transfer-Encoding'); diff --git a/lib/router/index.js b/lib/router/index.js index 504ed9ce0ee..dac2514815b 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -119,7 +119,7 @@ proto.param = function param(name, fn) { // ensure we end up with a // middleware function - if ('function' != typeof fn) { + if ('function' !== typeof fn) { throw new Error('invalid param() call for ' + name + ', got ' + fn); } diff --git a/lib/utils.js b/lib/utils.js index 3d54247ad28..465b31f5367 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -66,9 +66,9 @@ exports.wetag = function wetag(body, encoding){ */ exports.isAbsolute = function(path){ - if ('/' == path[0]) return true; - if (':' == path[1] && '\\' == path[2]) return true; - if ('\\\\' == path.substring(0, 2)) return true; // Microsoft Azure absolute path + if ('/' === path[0]) return true; + if (':' === path[1] && '\\' === path[2]) return true; + if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path }; /** @@ -142,7 +142,7 @@ function acceptParams(str, index) { for (var i = 1; i < parts.length; ++i) { var pms = parts[i].split(/ *= */); - if ('q' == pms[0]) { + if ('q' === pms[0]) { ret.quality = parseFloat(pms[1]); } else { ret.params[pms[0]] = pms[1]; From f90f9dde3fe02cd9f4b081c16441415817b297b0 Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Mon, 22 Feb 2016 06:22:35 +0800 Subject: [PATCH 0958/1265] Improve performance for res.json/res.jsonp in most cases closes #2900 --- History.md | 1 + lib/response.js | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 764974d0788..6d1eb43643b 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Improve performance for `res.json`/`res.jsonp` in most cases * deps: accepts@~1.3.3 - Fix including type extensions in parameters in `Accept` parsing - Fix parsing `Accept` parameters with quoted equals diff --git a/lib/response.js b/lib/response.js index b93459cff56..ad502ad8b58 100644 --- a/lib/response.js +++ b/lib/response.js @@ -239,7 +239,7 @@ res.json = function json(obj) { var app = this.app; var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = JSON.stringify(val, replacer, spaces); + var body = stringify(val, replacer, spaces); // content-type if (!this.get('Content-Type')) { @@ -281,7 +281,7 @@ res.jsonp = function jsonp(obj) { var app = this.app; var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = JSON.stringify(val, replacer, spaces); + var body = stringify(val, replacer, spaces); var callback = this.req.query[app.get('jsonp callback name')]; // content-type @@ -1051,3 +1051,16 @@ function sendfile(res, file, options, callback) { // pipe file.pipe(res); } + +/** + * Stringify JSON, like JSON.stringify, but v8 optimized. + * @private + */ + +function stringify(value, replacer, spaces) { + // v8 checks arguments.length for optimizing simple call + // https://bugs.chromium.org/p/v8/issues/detail?id=4730 + return replacer || spaces + ? JSON.stringify(value, replacer, spaces) + : JSON.stringify(value); +} From cc25a04d10aace04addb1f4a4a53611f364b86c5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 31 May 2016 14:25:41 -0400 Subject: [PATCH 0959/1265] deps: type-is@~1.6.13 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6d1eb43643b..5fd9623b6c8 100644 --- a/History.md +++ b/History.md @@ -28,6 +28,9 @@ unreleased - IPv4 netmasks must be contingous - IPv6 addresses cannot be used as a netmask - deps: ipaddr.js@1.1.1 + * deps: type-is@~1.6.13 + - Fix type error when given invalid type to match against + - deps: mime-types@~2.1.11 * deps: vary@~1.1.0 - Only accept valid field names in the `field` argument * perf: use strict equality when possible diff --git a/package.json b/package.json index 1206e08e991..8a35cdece25 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "range-parser": "~1.0.3", "send": "0.13.1", "serve-static": "~1.10.2", - "type-is": "~1.6.6", + "type-is": "~1.6.13", "utils-merge": "1.0.0", "vary": "~1.1.0" }, From 999546dfdeb874c20b360ad58346ed07917f3ac0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 31 May 2016 14:28:20 -0400 Subject: [PATCH 0960/1265] deps: qs@6.2.0 --- History.md | 2 ++ lib/middleware/query.js | 11 +++-------- lib/utils.js | 1 - package.json | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/History.md b/History.md index 5fd9623b6c8..ddb0c9a7e8a 100644 --- a/History.md +++ b/History.md @@ -28,6 +28,8 @@ unreleased - IPv4 netmasks must be contingous - IPv6 addresses cannot be used as a netmask - deps: ipaddr.js@1.1.1 + * deps: qs@6.2.0 + - Add `decoder` option in `parse` function * deps: type-is@~1.6.13 - Fix type error when given invalid type to match against - deps: mime-types@~2.1.11 diff --git a/lib/middleware/query.js b/lib/middleware/query.js index a665f3f1431..5f76f8458f0 100644 --- a/lib/middleware/query.js +++ b/lib/middleware/query.js @@ -30,14 +30,9 @@ module.exports = function query(options) { opts = undefined; } - if (opts !== undefined) { - if (opts.allowDots === undefined) { - opts.allowDots = false; - } - - if (opts.allowPrototypes === undefined) { - opts.allowPrototypes = true; - } + if (opts !== undefined && opts.allowPrototypes === undefined) { + // back-compat for qs module + opts.allowPrototypes = true; } return function query(req, res, next){ diff --git a/lib/utils.js b/lib/utils.js index 465b31f5367..c2d3af1d620 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -283,7 +283,6 @@ exports.setCharset = function setCharset(type, charset) { function parseExtendedQueryString(str) { return qs.parse(str, { - allowDots: false, allowPrototypes: true }); } diff --git a/package.json b/package.json index 8a35cdece25..2478c634926 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", "proxy-addr": "~1.1.2", - "qs": "4.0.0", + "qs": "6.2.0", "range-parser": "~1.0.3", "send": "0.13.1", "serve-static": "~1.10.2", From 2e1284beb6210444932d050b9d31d3908afb7591 Mon Sep 17 00:00:00 2001 From: huaoguo Date: Wed, 1 Jun 2016 12:56:27 +0800 Subject: [PATCH 0961/1265] Fix Windows absolute path check using forward slashes closes #3017 --- History.md | 1 + lib/utils.js | 2 +- test/utils.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ddb0c9a7e8a..d1a248ec18e 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix Windows absolute path check using forward slashes * Improve performance for `res.json`/`res.jsonp` in most cases * deps: accepts@~1.3.3 - Fix including type extensions in parameters in `Accept` parsing diff --git a/lib/utils.js b/lib/utils.js index c2d3af1d620..f418c5807c7 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -67,7 +67,7 @@ exports.wetag = function wetag(body, encoding){ exports.isAbsolute = function(path){ if ('/' === path[0]) return true; - if (':' === path[1] && '\\' === path[2]) return true; + if (':' === path[1] && ('\\' === path[2] || '/' === path[2])) return true; // Windows device path if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path }; diff --git a/test/utils.js b/test/utils.js index b7e8b520091..b6731962601 100644 --- a/test/utils.js +++ b/test/utils.js @@ -73,6 +73,7 @@ describe('utils.wetag(body, encoding)', function(){ describe('utils.isAbsolute()', function(){ it('should support windows', function(){ assert(utils.isAbsolute('c:\\')); + assert(utils.isAbsolute('c:/')); assert(!utils.isAbsolute(':\\')); }) From 98224d2c4f60708dcd6cb43bc50654ab804665d2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Jun 2016 17:22:15 -0400 Subject: [PATCH 0962/1265] build: ejs@2.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2478c634926..ba3e9c8cb68 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "devDependencies": { "after": "0.8.1", - "ejs": "2.4.1", + "ejs": "2.4.2", "istanbul": "0.4.3", "marked": "0.3.5", "mocha": "2.5.1", From c9531ac1f19a2bab4af819bfab6cb6dfab49e101 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Jun 2016 17:24:08 -0400 Subject: [PATCH 0963/1265] build: mocha@2.5.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba3e9c8cb68..1c6d1ae0d7c 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "ejs": "2.4.2", "istanbul": "0.4.3", "marked": "0.3.5", - "mocha": "2.5.1", + "mocha": "2.5.3", "should": "8.4.0", "supertest": "1.1.0", "body-parser": "~1.14.2", From d03868965858af94a712fbd4ad68827023199462 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Jun 2016 17:27:06 -0400 Subject: [PATCH 0964/1265] build: should@9.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1c6d1ae0d7c..141f12c76f1 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "istanbul": "0.4.3", "marked": "0.3.5", "mocha": "2.5.3", - "should": "8.4.0", + "should": "9.0.0", "supertest": "1.1.0", "body-parser": "~1.14.2", "connect-redis": "~2.4.1", From 8ddab697cc1d7b4c3d6d24b8e265be116ddccc0b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Jun 2016 17:31:10 -0400 Subject: [PATCH 0965/1265] build: supertest@1.2.0 --- package.json | 2 +- test/req.query.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 141f12c76f1..1af28db9801 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "marked": "0.3.5", "mocha": "2.5.3", "should": "9.0.0", - "supertest": "1.1.0", + "supertest": "1.2.0", "body-parser": "~1.14.2", "connect-redis": "~2.4.1", "cookie-parser": "~1.4.1", diff --git a/test/req.query.js b/test/req.query.js index 19151411995..d3d29abd16d 100644 --- a/test/req.query.js +++ b/test/req.query.js @@ -43,7 +43,7 @@ describe('req', function(){ var app = createApp('simple'); request(app) - .get('/?user[name]=tj') + .get('/?user%5Bname%5D=tj') .expect(200, '{"user[name]":"tj"}', done); }); }); @@ -55,7 +55,7 @@ describe('req', function(){ }); request(app) - .get('/?user[name]=tj') + .get('/?user%5Bname%5D=tj') .expect(200, '{"length":17}', done); }); }); @@ -65,7 +65,7 @@ describe('req', function(){ var app = createApp(false); request(app) - .get('/?user[name]=tj') + .get('/?user%5Bname%5D=tj') .expect(200, '{}', done); }); }); @@ -75,7 +75,7 @@ describe('req', function(){ var app = createApp(true); request(app) - .get('/?user[name]=tj') + .get('/?user%5Bname%5D=tj') .expect(200, '{"user[name]":"tj"}', done); }); }); From 7ee41cc23f2f7237ad8e3b1cfbad03900f14314d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Jun 2016 18:54:11 -0400 Subject: [PATCH 0966/1265] deps: range-parser@~1.2.0 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d1a248ec18e..77552f8411f 100644 --- a/History.md +++ b/History.md @@ -31,6 +31,10 @@ unreleased - deps: ipaddr.js@1.1.1 * deps: qs@6.2.0 - Add `decoder` option in `parse` function + * deps: range-parser@~1.2.0 + - Add `combine` option to combine overlapping ranges + - Fix incorrectly returning -1 when there is at least one valid range + - perf: remove internal function * deps: type-is@~1.6.13 - Fix type error when given invalid type to match against - deps: mime-types@~2.1.11 diff --git a/package.json b/package.json index 1af28db9801..303524a3e5c 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "path-to-regexp": "0.1.7", "proxy-addr": "~1.1.2", "qs": "6.2.0", - "range-parser": "~1.0.3", + "range-parser": "~1.2.0", "send": "0.13.1", "serve-static": "~1.10.2", "type-is": "~1.6.13", From 7fcf1d7d5b021d4c285f377d99e0d40dbf26a9b1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Jun 2016 19:04:02 -0400 Subject: [PATCH 0967/1265] docs: update the req.range jsdoc comment --- lib/request.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/request.js b/lib/request.js index 4fdc279ebcb..17eb47c33c7 100644 --- a/lib/request.js +++ b/lib/request.js @@ -171,26 +171,26 @@ req.acceptsLanguage = deprecate.function(req.acceptsLanguages, 'req.acceptsLanguage: Use acceptsLanguages instead'); /** - * Parse Range header field, - * capping to the given `size`. + * Parse Range header field, capping to the given `size`. * - * Unspecified ranges such as "0-" require - * knowledge of your resource length. In - * the case of a byte range this is of course - * the total number of bytes. If the Range - * header field is not given `null` is returned, - * `-1` when unsatisfiable, `-2` when syntactically invalid. + * Unspecified ranges such as "0-" require knowledge of your resource length. In + * the case of a byte range this is of course the total number of bytes. If the + * Range header field is not given `undefined` is returned, `-1` when unsatisfiable, + * and `-2` when syntactically invalid. * - * NOTE: remember that ranges are inclusive, so - * for example "Range: users=0-3" should respond - * with 4 users when available, not 3. + * When ranges are returned, the array has a "type" property which is the type of + * range that is required (most commonly, "bytes"). Each array element is an object + * with a "start" and "end" property for the portion of the range. * - * @param {Number} size - * @return {Array} + * NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" + * should respond with 4 users when available, not 3. + * + * @param {number} size + * @return {number|array} * @public */ -req.range = function(size){ +req.range = function range(size) { var range = this.get('Range'); if (!range) return; return parseRange(size, range); From 5d642af8c34c49b54b1ea2f9a300440ec5656fef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Jun 2016 19:13:36 -0400 Subject: [PATCH 0968/1265] Add "options" argument to req.range --- History.md | 2 ++ lib/request.js | 9 +++++++-- test/req.range.js | 16 +++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index 77552f8411f..a184efbf8a9 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,8 @@ unreleased ========== + * Add `options` argument to `req.range` + - Includes the `combine` option * Fix Windows absolute path check using forward slashes * Improve performance for `res.json`/`res.jsonp` in most cases * deps: accepts@~1.3.3 diff --git a/lib/request.js b/lib/request.js index 17eb47c33c7..ef0e101a001 100644 --- a/lib/request.js +++ b/lib/request.js @@ -182,18 +182,23 @@ req.acceptsLanguage = deprecate.function(req.acceptsLanguages, * range that is required (most commonly, "bytes"). Each array element is an object * with a "start" and "end" property for the portion of the range. * + * The "combine" option can be set to `true` and overlapping & adjacent ranges + * will be combined into a single range. + * * NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" * should respond with 4 users when available, not 3. * * @param {number} size + * @param {object} [options] + * @param {boolean} [options.combine=false] * @return {number|array} * @public */ -req.range = function range(size) { +req.range = function range(size, options) { var range = this.get('Range'); if (!range) return; - return parseRange(size, range); + return parseRange(size, range, options); }; /** diff --git a/test/req.range.js b/test/req.range.js index 08cf8f91e92..d530d85a645 100644 --- a/test/req.range.js +++ b/test/req.range.js @@ -12,9 +12,9 @@ function req(ret) { describe('req', function(){ describe('.range(size)', function(){ it('should return parsed ranges', function(){ - var ret = [{ start: 0, end: 50 }, { start: 60, end: 100 }]; - ret.type = 'bytes'; - req('bytes=0-50,60-100').range(120).should.eql(ret); + var ranges = [{ start: 0, end: 50 }, { start: 51, end: 100 }] + ranges.type = 'bytes' + assert.deepEqual(req('bytes=0-50,51-100').range(120), ranges) }) it('should cap to the given size', function(){ @@ -35,4 +35,14 @@ describe('req', function(){ assert(req('').range(120) === undefined); }) }) + + describe('.range(size, options)', function(){ + describe('with "combine: true" option', function(){ + it('should return combined ranges', function(){ + var ranges = [{ start: 0, end: 100 }] + ranges.type = 'bytes' + assert.deepEqual(req('bytes=0-50,51-100').range(120, { combine: true }), ranges) + }) + }) + }) }) From c762b16f62e2c9f5de33481c250ef6f94a99eb7f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 3 Jun 2016 00:07:34 -0400 Subject: [PATCH 0969/1265] Improve error with invalid arguments to req.get() fixes #2993 --- History.md | 1 + lib/request.js | 8 ++++++++ test/req.get.js | 26 +++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a184efbf8a9..46e99a265eb 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * Add `options` argument to `req.range` - Includes the `combine` option * Fix Windows absolute path check using forward slashes + * Improve error with invalid arguments to `req.get()` * Improve performance for `res.json`/`res.jsonp` in most cases * deps: accepts@~1.3.3 - Fix including type extensions in parameters in `Accept` parsing diff --git a/lib/request.js b/lib/request.js index ef0e101a001..557d050ffb5 100644 --- a/lib/request.js +++ b/lib/request.js @@ -57,6 +57,14 @@ var req = exports = module.exports = { req.get = req.header = function header(name) { + if (!name) { + throw new TypeError('name argument is required to req.get'); + } + + if (typeof name !== 'string') { + throw new TypeError('name must be a string to req.get'); + } + var lc = name.toLowerCase(); switch (lc) { diff --git a/test/req.get.js b/test/req.get.js index 144a256848d..109a2d90ce7 100644 --- a/test/req.get.js +++ b/test/req.get.js @@ -31,5 +31,29 @@ describe('req', function(){ .set('Referrer', 'http://foobar.com') .expect('http://foobar.com', done); }) + + it('should throw missing header name', function (done) { + var app = express() + + app.use(function (req, res) { + res.end(req.get()) + }) + + request(app) + .get('/') + .expect(500, /TypeError: name argument is required to req.get/, done) + }) + + it('should throw for non-string header name', function (done) { + var app = express() + + app.use(function (req, res) { + res.end(req.get(42)) + }) + + request(app) + .get('/') + .expect(500, /TypeError: name must be a string to req.get/, done) + }) }) -}) \ No newline at end of file +}) From fc40702cb70e39565263d64d962d3b8164fb3621 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 12 Jun 2016 22:33:44 -0400 Subject: [PATCH 0970/1265] deps: send@0.14.1 --- History.md | 18 ++++++++++++++++++ package.json | 2 +- test/res.sendFile.js | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 46e99a265eb..12bafeff42d 100644 --- a/History.md +++ b/History.md @@ -1,11 +1,15 @@ unreleased ========== + * Add `acceptRanges` option to `res.sendFile`/`res.sendfile` + * Add `cacheControl` option to `res.sendFile`/`res.sendfile` * Add `options` argument to `req.range` - Includes the `combine` option + * Fix some redirect handling in `res.sendFile`/`res.sendfile` * Fix Windows absolute path check using forward slashes * Improve error with invalid arguments to `req.get()` * Improve performance for `res.json`/`res.jsonp` in most cases + * Improve `Range` header handling in `res.sendFile`/`res.sendfile` * deps: accepts@~1.3.3 - Fix including type extensions in parameters in `Accept` parsing - Fix parsing `Accept` parameters with quoted equals @@ -38,6 +42,20 @@ unreleased - Add `combine` option to combine overlapping ranges - Fix incorrectly returning -1 when there is at least one valid range - perf: remove internal function + * deps: send@0.14.1 + - Add `acceptRanges` option + - Add `cacheControl` option + - Attempt to combine multiple ranges into single range + - Correctly inherit from `Stream` class + - Fix `Content-Range` header in 416 responses when using `start`/`end` options + - Fix `Content-Range` header missing from default 416 responses + - Fix redirect error when `path` contains raw non-URL characters + - Fix redirect when `path` starts with multiple forward slashes + - Ignore non-byte `Range` headers + - deps: http-errors@~1.5.0 + - deps: range-parser@~1.2.0 + - deps: statuses@~1.3.0 + - perf: remove argument reassignment * deps: type-is@~1.6.13 - Fix type error when given invalid type to match against - deps: mime-types@~2.1.11 diff --git a/package.json b/package.json index 303524a3e5c..6d9a9f39c37 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "proxy-addr": "~1.1.2", "qs": "6.2.0", "range-parser": "~1.2.0", - "send": "0.13.1", + "send": "0.14.1", "serve-static": "~1.10.2", "type-is": "~1.6.13", "utils-merge": "1.0.0", diff --git a/test/res.sendFile.js b/test/res.sendFile.js index 78013a50ebd..705c15a8b7e 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -286,6 +286,14 @@ describe('res', function(){ }) }) + describe('.sendFile(path, options)', function () { + it('should pass options to send module', function (done) { + request(createApp(path.resolve(fixtures, 'name.txt'), { start: 0, end: 1 })) + .get('/') + .expect(200, 'to', done) + }) + }) + describe('.sendfile(path, fn)', function(){ it('should invoke the callback when complete', function(done){ var app = express(); @@ -702,6 +710,20 @@ describe('res', function(){ }) }) + describe('.sendfile(path, options)', function () { + it('should pass options to send module', function (done) { + var app = express() + + app.use(function (req, res) { + res.sendfile(path.resolve(fixtures, 'name.txt'), { start: 0, end: 1 }) + }) + + request(app) + .get('/') + .expect(200, 'to', done) + }) + }) + function createApp(path, options, fn) { var app = express(); From 791cabf9390a029c5ad9b63eae8145c3c73f204e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 12 Jun 2016 22:38:20 -0400 Subject: [PATCH 0971/1265] deps: serve-static@~1.11.1 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 12bafeff42d..0c2a99873db 100644 --- a/History.md +++ b/History.md @@ -56,6 +56,14 @@ unreleased - deps: range-parser@~1.2.0 - deps: statuses@~1.3.0 - perf: remove argument reassignment + * deps: serve-static@~1.11.1 + - Add `acceptRanges` option + - Add `cacheControl` option + - Attempt to combine multiple ranges into single range + - Fix redirect error when `req.url` contains raw non-URL characters + - Ignore non-byte `Range` headers + - Use status code 301 for redirects + - deps: send@0.14.1 * deps: type-is@~1.6.13 - Fix type error when given invalid type to match against - deps: mime-types@~2.1.11 diff --git a/package.json b/package.json index 6d9a9f39c37..ede72a7eb16 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "qs": "6.2.0", "range-parser": "~1.2.0", "send": "0.14.1", - "serve-static": "~1.10.2", + "serve-static": "~1.11.1", "type-is": "~1.6.13", "utils-merge": "1.0.0", "vary": "~1.1.0" From 23c22ce3fe2c298add7c06ac881ce0f17f73a6be Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 13 Jun 2016 22:50:18 -0400 Subject: [PATCH 0972/1265] build: support Node.js 5.x --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 38998527547..79f4360e9ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ node_js: - "2.5" - "3.3" - "4.4" + - "5.11" sudo: false cache: directories: diff --git a/appveyor.yml b/appveyor.yml index ce5e52ff1b9..8ed246ec5cc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ environment: - nodejs_version: "2.5" - nodejs_version: "3.3" - nodejs_version: "4.4" + - nodejs_version: "5.11" cache: - node_modules install: From c12cc8839277dcb3956558865f0cd241e8d08883 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 13 Jun 2016 22:51:07 -0400 Subject: [PATCH 0973/1265] build: support Node.js 6.x --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 79f4360e9ee..95034721e75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ node_js: - "3.3" - "4.4" - "5.11" + - "6.2" sudo: false cache: directories: diff --git a/appveyor.yml b/appveyor.yml index 8ed246ec5cc..f1061373510 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,7 @@ environment: - nodejs_version: "3.3" - nodejs_version: "4.4" - nodejs_version: "5.11" + - nodejs_version: "6.2" cache: - node_modules install: From 76eaa326ee8c4dda05568c6452286a16adb84c0b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 13 Jun 2016 23:23:29 -0400 Subject: [PATCH 0974/1265] Encode URL in res.location/res.redirect if not already encoded fixes #2897 fixes #3003 --- History.md | 1 + lib/response.js | 9 ++++----- package.json | 1 + test/res.location.js | 26 ++++++++++++++++++++++++++ test/res.redirect.js | 36 +++++++++++++++++++++++++++++++----- 5 files changed, 63 insertions(+), 10 deletions(-) diff --git a/History.md b/History.md index 0c2a99873db..5fc6dd253a6 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased * Add `cacheControl` option to `res.sendFile`/`res.sendfile` * Add `options` argument to `req.range` - Includes the `combine` option + * Encode URL in `res.location`/`res.redirect` if not already encoded * Fix some redirect handling in `res.sendFile`/`res.sendfile` * Fix Windows absolute path check using forward slashes * Improve error with invalid arguments to `req.get()` diff --git a/lib/response.js b/lib/response.js index ad502ad8b58..6128f450a94 100644 --- a/lib/response.js +++ b/lib/response.js @@ -14,6 +14,7 @@ var contentDisposition = require('content-disposition'); var deprecate = require('depd')('express'); +var encodeUrl = require('encodeurl'); var escapeHtml = require('escape-html'); var http = require('http'); var isAbsolute = require('./utils').isAbsolute; @@ -832,8 +833,7 @@ res.location = function location(url) { } // set location - this.set('Location', loc); - return this; + return this.set('Location', encodeUrl(loc)); }; /** @@ -871,13 +871,12 @@ res.redirect = function redirect(url) { } // Set location header - this.location(address); - address = this.get('Location'); + address = this.location(address).get('Location'); // Support text/{plain,html} by default this.format({ text: function(){ - body = statusCodes[status] + '. Redirecting to ' + encodeURI(address); + body = statusCodes[status] + '. Redirecting to ' + address; }, html: function(){ diff --git a/package.json b/package.json index ede72a7eb16..8ed7783ab0a 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "cookie-signature": "1.0.6", "debug": "~2.2.0", "depd": "~1.1.0", + "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.7.0", "finalhandler": "0.4.1", diff --git a/test/res.location.js b/test/res.location.js index 2b42bf358d4..bb9eb6f92e3 100644 --- a/test/res.location.js +++ b/test/res.location.js @@ -16,5 +16,31 @@ describe('res', function(){ .expect('Location', 'http://google.com') .expect(200, done) }) + + it('should encode "url"', function (done) { + var app = express() + + app.use(function (req, res) { + res.location('https://google.com?q=\u2603 §10').end() + }) + + request(app) + .get('/') + .expect('Location', 'https://google.com?q=%E2%98%83%20%C2%A710') + .expect(200, done) + }) + + it('should not touch already-encoded sequences in "url"', function (done) { + var app = express() + + app.use(function (req, res) { + res.location('https://google.com?q=%A710').end() + }) + + request(app) + .get('/') + .expect('Location', 'https://google.com?q=%A710') + .expect(200, done) + }) }) }) diff --git a/test/res.redirect.js b/test/res.redirect.js index 8511c40f2ab..9f3bd436763 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -18,6 +18,32 @@ describe('res', function(){ .expect('location', 'http://google.com') .expect(302, done) }) + + it('should encode "url"', function (done) { + var app = express() + + app.use(function (req, res) { + res.redirect('https://google.com?q=\u2603 §10') + }) + + request(app) + .get('/') + .expect('Location', 'https://google.com?q=%E2%98%83%20%C2%A710') + .expect(302, done) + }) + + it('should not touch already-encoded sequences in "url"', function (done) { + var app = express() + + app.use(function (req, res) { + res.redirect('https://google.com?q=%A710') + }) + + request(app) + .get('/') + .expect('Location', 'https://google.com?q=%A710') + .expect(302, done) + }) }) describe('.redirect(status, url)', function(){ @@ -85,7 +111,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - res.redirect(''); + res.redirect(''); }); request(app) @@ -93,8 +119,8 @@ describe('res', function(){ .set('Host', 'http://example.com') .set('Accept', 'text/html') .expect('Content-Type', /html/) - .expect('Location', '') - .expect(302, '

' + http.STATUS_CODES[302] + '. Redirecting to <lame>

', done); + .expect('Location', '%3Cla\'me%3E') + .expect(302, '

' + http.STATUS_CODES[302] + '. Redirecting to %3Cla'me%3E

', done) }) it('should include the redirect type', function(done){ @@ -141,8 +167,8 @@ describe('res', function(){ .set('Host', 'http://example.com') .set('Accept', 'text/plain, */*') .expect('Content-Type', /plain/) - .expect('Location', 'http://example.com/?param=') - .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E', done); + .expect('Location', 'http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E') + .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E', done) }) it('should include the redirect type', function(done){ From e06766c573ba3784798fc9b8775cea1304e34427 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 15 Jun 2016 18:12:19 -0400 Subject: [PATCH 0975/1265] deps: finalhandler@0.5.0 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5fc6dd253a6..6c3811a4577 100644 --- a/History.md +++ b/History.md @@ -31,6 +31,12 @@ unreleased - perf: hoist regular expression - perf: use for loop in parse - perf: use string concatination for serialization + * deps: finalhandler@0.5.0 + - Change invalid or non-numeric status code to 500 + - Overwrite status message to match set status code + - Prefer `err.statusCode` if `err.status` is invalid + - Set response headers from `err.headers` object + - Use `statuses` instead of `http` module for status messages * deps: proxy-addr@~1.1.2 - Fix accepting various invalid netmasks - Fix IPv6-mapped IPv4 validation edge cases diff --git a/package.json b/package.json index 8ed7783ab0a..2c8e5cb9741 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.7.0", - "finalhandler": "0.4.1", + "finalhandler": "0.5.0", "fresh": "0.3.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", From 605983fd0e838f9ddb9d85f4e1950f0ce5bed83d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 15 Jun 2016 18:13:30 -0400 Subject: [PATCH 0976/1265] build: should@9.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c8e5cb9741..3e491e78126 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "istanbul": "0.4.3", "marked": "0.3.5", "mocha": "2.5.3", - "should": "9.0.0", + "should": "9.0.2", "supertest": "1.2.0", "body-parser": "~1.14.2", "connect-redis": "~2.4.1", From 14cf9c563679566bef9a396bfa9702776bfc1b48 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 15 Jun 2016 18:16:08 -0400 Subject: [PATCH 0977/1265] deps: update example dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3e491e78126..6b3b11b1e60 100644 --- a/package.json +++ b/package.json @@ -56,22 +56,22 @@ }, "devDependencies": { "after": "0.8.1", + "body-parser": "~1.15.1", + "cookie-parser": "~1.4.3", "ejs": "2.4.2", "istanbul": "0.4.3", "marked": "0.3.5", + "method-override": "~2.3.6", "mocha": "2.5.3", + "morgan": "~1.7.0", "should": "9.0.2", "supertest": "1.2.0", - "body-parser": "~1.14.2", "connect-redis": "~2.4.1", - "cookie-parser": "~1.4.1", "cookie-session": "~1.2.0", "express-session": "~1.13.0", "jade": "~1.11.0", - "method-override": "~2.3.5", - "morgan": "~1.6.1", "multiparty": "~4.1.2", - "vhost": "~3.0.1" + "vhost": "~3.0.2" }, "engines": { "node": ">= 0.10.0" From 9375a9afa9d7baa814b454c7a6818a7471aaef00 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Jun 2016 11:03:44 -0400 Subject: [PATCH 0978/1265] 4.14.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 6c3811a4577..40a5ed7e4be 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.14.0 / 2016-06-16 +=================== * Add `acceptRanges` option to `res.sendFile`/`res.sendfile` * Add `cacheControl` option to `res.sendFile`/`res.sendfile` diff --git a/package.json b/package.json index 6b3b11b1e60..57dd1602884 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.13.4", + "version": "4.14.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 305f982bd734da5ee74abba9c270905a8f4aa484 Mon Sep 17 00:00:00 2001 From: Hamza Date: Sun, 31 Jul 2016 13:14:05 +0100 Subject: [PATCH 0979/1265] exapmples: use path.join to concat paths closes #3046 --- examples/static-files/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/static-files/index.js b/examples/static-files/index.js index c3b1659d861..0e44313d15d 100644 --- a/examples/static-files/index.js +++ b/examples/static-files/index.js @@ -4,6 +4,7 @@ var express = require('../..'); var logger = require('morgan'); +var path = require('path'); var app = express(); // log requests @@ -16,7 +17,7 @@ app.use(logger('dev')); // that you pass it. In this case "GET /js/app.js" // will look for "./public/js/app.js". -app.use(express.static(__dirname + '/public')); +app.use(express.static(path.join(__dirname, 'public'))); // if you wanted to "prefix" you may use // the mounting feature of Connect, for example @@ -24,13 +25,13 @@ app.use(express.static(__dirname + '/public')); // The mount-path "/static" is simply removed before // passing control to the express.static() middleware, // thus it serves the file correctly by ignoring "/static" -app.use('/static', express.static(__dirname + '/public')); +app.use('/static', express.static(path.join(__dirname, 'public'))); // if for some reason you want to serve files from // several directories, you can use express.static() // multiple times! Here we're passing "./public/css", // this will allow "GET /style.css" instead of "GET /css/style.css": -app.use(express.static(__dirname + '/public/css')); +app.use(express.static(path.join(__dirname, 'public', 'css'))); app.listen(3000); console.log('listening on port 3000'); From bd47aeb88d28c6cff6e2d8e5378ec73c262e039f Mon Sep 17 00:00:00 2001 From: Vishvajit Pathak Date: Thu, 17 Nov 2016 12:43:14 +0530 Subject: [PATCH 0980/1265] tests: fix typos in test descriptions closes #3129 closes #3130 --- test/app.options.js | 2 +- test/app.router.js | 2 +- test/req.acceptsEncoding.js | 4 ++-- test/req.acceptsEncodings.js | 4 ++-- test/req.acceptsLanguage.js | 4 ++-- test/req.acceptsLanguages.js | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/app.options.js b/test/app.options.js index 20234723a57..9c88abafe5e 100644 --- a/test/app.options.js +++ b/test/app.options.js @@ -72,7 +72,7 @@ describe('OPTIONS', function(){ .expect(200, 'GET,HEAD', done); }) - describe('when error occurs in respone handler', function () { + describe('when error occurs in response handler', function () { it('should pass error to callback', function (done) { var app = express(); var router = express.Router(); diff --git a/test/app.router.js b/test/app.router.js index 03b43eb081a..11e492cbfae 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -757,7 +757,7 @@ describe('app.router', function(){ .expect('editing tj (old)', cb); }) - it('should work inside literal paranthesis', function(done){ + it('should work inside literal parenthesis', function(done){ var app = express(); app.get('/:user\\(:op\\)', function(req, res){ diff --git a/test/req.acceptsEncoding.js b/test/req.acceptsEncoding.js index 930b4ea76c1..12708fc0144 100644 --- a/test/req.acceptsEncoding.js +++ b/test/req.acceptsEncoding.js @@ -4,7 +4,7 @@ var express = require('../') describe('req', function(){ describe('.acceptsEncoding', function(){ - it('should be true if encoding accpeted', function(done){ + it('should be true if encoding accepted', function(done){ var app = express(); app.use(function(req, res){ @@ -19,7 +19,7 @@ describe('req', function(){ .expect(200, done); }) - it('should be false if encoding not accpeted', function(done){ + it('should be false if encoding not accepted', function(done){ var app = express(); app.use(function(req, res){ diff --git a/test/req.acceptsEncodings.js b/test/req.acceptsEncodings.js index c4c68e1e8ed..c036c297691 100644 --- a/test/req.acceptsEncodings.js +++ b/test/req.acceptsEncodings.js @@ -4,7 +4,7 @@ var express = require('../') describe('req', function(){ describe('.acceptsEncodingss', function(){ - it('should be true if encoding accpeted', function(done){ + it('should be true if encoding accepted', function(done){ var app = express(); app.use(function(req, res){ @@ -19,7 +19,7 @@ describe('req', function(){ .expect(200, done); }) - it('should be false if encoding not accpeted', function(done){ + it('should be false if encoding not accepted', function(done){ var app = express(); app.use(function(req, res){ diff --git a/test/req.acceptsLanguage.js b/test/req.acceptsLanguage.js index 36afc47f929..b14d920bd69 100644 --- a/test/req.acceptsLanguage.js +++ b/test/req.acceptsLanguage.js @@ -4,7 +4,7 @@ var express = require('../') describe('req', function(){ describe('.acceptsLanguage', function(){ - it('should be true if language accpeted', function(done){ + it('should be true if language accepted', function(done){ var app = express(); app.use(function(req, res){ @@ -19,7 +19,7 @@ describe('req', function(){ .expect(200, done); }) - it('should be false if language not accpeted', function(done){ + it('should be false if language not accepted', function(done){ var app = express(); app.use(function(req, res){ diff --git a/test/req.acceptsLanguages.js b/test/req.acceptsLanguages.js index 8d11eb81e83..6a9cb3366bc 100644 --- a/test/req.acceptsLanguages.js +++ b/test/req.acceptsLanguages.js @@ -4,7 +4,7 @@ var express = require('../') describe('req', function(){ describe('.acceptsLanguages', function(){ - it('should be true if language accpeted', function(done){ + it('should be true if language accepted', function(done){ var app = express(); app.use(function(req, res){ @@ -19,7 +19,7 @@ describe('req', function(){ .expect(200, done); }) - it('should be false if language not accpeted', function(done){ + it('should be false if language not accepted', function(done){ var app = express(); app.use(function(req, res){ From 505f8482f2a2d41be856662db41265a7b190ca65 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 2 Dec 2016 22:09:46 -0500 Subject: [PATCH 0981/1265] build: Node.js@4.6 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95034721e75..f147c8a6f5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: - "1.8" - "2.5" - "3.3" - - "4.4" + - "4.6" - "5.11" - "6.2" sudo: false diff --git a/appveyor.yml b/appveyor.yml index f1061373510..7f53b61c289 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ environment: - nodejs_version: "1.8" - nodejs_version: "2.5" - nodejs_version: "3.3" - - nodejs_version: "4.4" + - nodejs_version: "4.6" - nodejs_version: "5.11" - nodejs_version: "6.2" cache: From 421ad5aaaa46ca5b2654bd75d9ec2bd62eed68b5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 2 Dec 2016 22:12:33 -0500 Subject: [PATCH 0982/1265] build: Node.js@5.12 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f147c8a6f5d..15fea9926e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ node_js: - "2.5" - "3.3" - "4.6" - - "5.11" + - "5.12" - "6.2" sudo: false cache: diff --git a/appveyor.yml b/appveyor.yml index 7f53b61c289..62a82ef709a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: - nodejs_version: "2.5" - nodejs_version: "3.3" - nodejs_version: "4.6" - - nodejs_version: "5.11" + - nodejs_version: "5.12" - nodejs_version: "6.2" cache: - node_modules From 1bcc9b1236197ac78f64e6cc1a7baf2c97d36395 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 2 Dec 2016 22:19:04 -0500 Subject: [PATCH 0983/1265] build: Node.js@6.9 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 15fea9926e4..3bd122f5d81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ node_js: - "3.3" - "4.6" - "5.12" - - "6.2" + - "6.9" sudo: false cache: directories: diff --git a/appveyor.yml b/appveyor.yml index 62a82ef709a..18d5c4abe02 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ environment: - nodejs_version: "3.3" - nodejs_version: "4.6" - nodejs_version: "5.12" - - nodejs_version: "6.2" + - nodejs_version: "6.9" cache: - node_modules install: From 6210e47cb664714efac017b9e1987f867ae5f804 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 3 Dec 2016 00:04:47 -0500 Subject: [PATCH 0984/1265] build: after@0.8.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57dd1602884..76e93218b9e 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "vary": "~1.1.0" }, "devDependencies": { - "after": "0.8.1", + "after": "0.8.2", "body-parser": "~1.15.1", "cookie-parser": "~1.4.3", "ejs": "2.4.2", From f6dca56e72bc8df794bb98fec14a0875323c0569 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 3 Dec 2016 00:08:46 -0500 Subject: [PATCH 0985/1265] build: istanbul@0.4.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76e93218b9e..bb0a0e67d22 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "body-parser": "~1.15.1", "cookie-parser": "~1.4.3", "ejs": "2.4.2", - "istanbul": "0.4.3", + "istanbul": "0.4.5", "marked": "0.3.5", "method-override": "~2.3.6", "mocha": "2.5.3", From 1a17888073790f5567fdb9f9e270fab6904abf97 Mon Sep 17 00:00:00 2001 From: Deniz Tetik Date: Wed, 18 Jan 2017 01:32:25 -0500 Subject: [PATCH 0986/1265] docs: fix minor grammatical error closes #3178 --- Contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contributing.md b/Contributing.md index 3fb2b7c25f1..2ddfa7a62a4 100644 --- a/Contributing.md +++ b/Contributing.md @@ -31,7 +31,7 @@ exception is security dislosures which should be sent privately. Committers may direct you to another repository, ask for additional clarifications, and add appropriate metadata before the issue is addressed. -Please be courteous, respectful, and every participant is expected to follow the +Please be courteous and respectful. Every participant is expected to follow the project's Code of Conduct. # Contributions From d1d9631b97b64c7f98f4ad2d0ba61014865b1d49 Mon Sep 17 00:00:00 2001 From: SeongHeon Kim Date: Fri, 20 Jan 2017 23:05:53 +0900 Subject: [PATCH 0987/1265] docs: remove link to missing section closes #3179 --- Security.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Security.md b/Security.md index d965a87bb0a..cbc5f16cde5 100644 --- a/Security.md +++ b/Security.md @@ -5,7 +5,6 @@ project. * [Reporting a Bug](#reporting-a-bug) * [Disclosure Policy](#disclosure-policy) - * [Receiving Security Updates](#receiving-security-updates) * [Comments on this Policy](#comments-on-this-policy) ## Reporting a Bug From 6723b4419abacba00b73c466edb338e331e9ffe8 Mon Sep 17 00:00:00 2001 From: Zachary Lester Date: Tue, 23 Aug 2016 13:36:52 -0700 Subject: [PATCH 0988/1265] tests: add test for res.sendFile "cacheContol" option closes #3061 --- test/res.sendFile.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/res.sendFile.js b/test/res.sendFile.js index 705c15a8b7e..ece09ee0731 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -116,6 +116,26 @@ describe('res', function(){ test.expect(200, cb); }) + describe('with "cacheControl" option', function () { + it('should enable cacheControl by default', function (done) { + var app = createApp(path.resolve(__dirname, 'fixtures/name.txt')) + + request(app) + .get('/') + .expect('Cache-Control', 'public, max-age=0') + .expect(200, done) + }) + + it('should accept cacheControl option', function (done) { + var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), { cacheControl: false }) + + request(app) + .get('/') + .expect(utils.shouldNotHaveHeader('Cache-Control')) + .expect(200, done) + }) + }) + describe('with "dotfiles" option', function () { it('should not serve dotfiles by default', function (done) { var app = createApp(path.resolve(__dirname, 'fixtures/.name')); From ddc93aa0e20e1a802dccc80dd4a84c5763306531 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jan 2017 00:39:46 -0500 Subject: [PATCH 0989/1265] deps: content-disposition@0.5.2 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 40a5ed7e4be..ac5203ca815 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * deps: content-disposition@0.5.2 + 4.14.0 / 2016-06-16 =================== diff --git a/package.json b/package.json index bb0a0e67d22..3a56a3de785 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "dependencies": { "accepts": "~1.3.3", "array-flatten": "1.1.1", - "content-disposition": "0.5.1", + "content-disposition": "0.5.2", "content-type": "~1.0.2", "cookie": "0.3.1", "cookie-signature": "1.0.6", From e73913b5837f615eaedde6a7005ffae5d09a3bff Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jan 2017 00:46:28 -0500 Subject: [PATCH 0990/1265] build: mocha@3.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3a56a3de785..b4ec8b0d559 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "istanbul": "0.4.5", "marked": "0.3.5", "method-override": "~2.3.6", - "mocha": "2.5.3", + "mocha": "3.2.0", "morgan": "~1.7.0", "should": "9.0.2", "supertest": "1.2.0", From a2e323a012de8415df58bd23ccb235bb0e0094c2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jan 2017 00:59:29 -0500 Subject: [PATCH 0991/1265] build: should@11.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4ec8b0d559..9a9b6ce63b1 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "method-override": "~2.3.6", "mocha": "3.2.0", "morgan": "~1.7.0", - "should": "9.0.2", + "should": "11.1.2", "supertest": "1.2.0", "connect-redis": "~2.4.1", "cookie-session": "~1.2.0", From a3d635309cab51fc04730be06efcb31f83d0c444 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jan 2017 01:00:52 -0500 Subject: [PATCH 0992/1265] deps: proxy-addr@~1.1.3 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ac5203ca815..63b5a6c2df3 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * deps: content-disposition@0.5.2 + * deps: proxy-addr@~1.1.3 + - deps: ipaddr.js@1.2.0 4.14.0 / 2016-06-16 =================== diff --git a/package.json b/package.json index 9a9b6ce63b1..eaea535b0a7 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", - "proxy-addr": "~1.1.2", + "proxy-addr": "~1.1.3", "qs": "6.2.0", "range-parser": "~1.2.0", "send": "0.14.1", From cfae537d3b37c73090634dd1dec7b10d6e9b920d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jan 2017 01:05:17 -0500 Subject: [PATCH 0993/1265] deps: finalhandler@0.5.1 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 63b5a6c2df3..39e64c441a6 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,11 @@ unreleased ========== * deps: content-disposition@0.5.2 + * deps: finalhandler@0.5.1 + - Fix exception when `err.headers` is not an object + - deps: statuses@~1.3.1 + - perf: hoist regular expressions + - perf: remove duplicate validation path * deps: proxy-addr@~1.1.3 - deps: ipaddr.js@1.2.0 diff --git a/package.json b/package.json index eaea535b0a7..6b334fd59fd 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.7.0", - "finalhandler": "0.5.0", + "finalhandler": "0.5.1", "fresh": "0.3.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", From 572657ee4a63b95d7522232dcc74a5012eb4239e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 23 Jan 2017 10:43:11 -0500 Subject: [PATCH 0994/1265] deps: send@0.14.2 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 39e64c441a6..922bee8576c 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,10 @@ unreleased - perf: remove duplicate validation path * deps: proxy-addr@~1.1.3 - deps: ipaddr.js@1.2.0 + * deps: send@0.14.2 + - deps: http-errors@~1.5.1 + - deps: ms@0.7.2 + - deps: statuses@~1.3.1 4.14.0 / 2016-06-16 =================== diff --git a/package.json b/package.json index 6b334fd59fd..ebe7757b39a 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "proxy-addr": "~1.1.3", "qs": "6.2.0", "range-parser": "~1.2.0", - "send": "0.14.1", + "send": "0.14.2", "serve-static": "~1.11.1", "type-is": "~1.6.13", "utils-merge": "1.0.0", From 8e14e06ebf45bd88b92ce9e84d4ffed3634c5097 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 24 Jan 2017 07:40:20 -0800 Subject: [PATCH 0995/1265] deps: serve-static@~1.11.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 922bee8576c..ec0568ddf20 100644 --- a/History.md +++ b/History.md @@ -13,6 +13,8 @@ unreleased - deps: http-errors@~1.5.1 - deps: ms@0.7.2 - deps: statuses@~1.3.1 + * deps: serve-static@~1.11.2 + - deps: send@0.14.2 4.14.0 / 2016-06-16 =================== diff --git a/package.json b/package.json index ebe7757b39a..550bda78cec 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "qs": "6.2.0", "range-parser": "~1.2.0", "send": "0.14.2", - "serve-static": "~1.11.1", + "serve-static": "~1.11.2", "type-is": "~1.6.13", "utils-merge": "1.0.0", "vary": "~1.1.0" From dc48f27f607f59b187bd21ab3a84a82d2638f1eb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jan 2017 22:25:39 -0500 Subject: [PATCH 0996/1265] deps: update example dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 550bda78cec..017ef91ac6e 100644 --- a/package.json +++ b/package.json @@ -56,21 +56,21 @@ }, "devDependencies": { "after": "0.8.2", - "body-parser": "~1.15.1", + "body-parser": "1.16.0", "cookie-parser": "~1.4.3", - "ejs": "2.4.2", + "ejs": "2.5.5", + "express-session": "1.15.0", "istanbul": "0.4.5", - "marked": "0.3.5", + "marked": "0.3.6", "method-override": "~2.3.6", "mocha": "3.2.0", "morgan": "~1.7.0", + "multiparty": "4.1.3", "should": "11.1.2", "supertest": "1.2.0", "connect-redis": "~2.4.1", "cookie-session": "~1.2.0", - "express-session": "~1.13.0", "jade": "~1.11.0", - "multiparty": "~4.1.2", "vhost": "~3.0.2" }, "engines": { From 6b506d801a731eb079fc0f442d25a7398b5f1a5b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jan 2017 22:33:52 -0500 Subject: [PATCH 0997/1265] examples: fix mvc example to ignore files in controllers dir fixes #3182 --- examples/mvc/lib/boot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/mvc/lib/boot.js b/examples/mvc/lib/boot.js index 78e82db1bfb..a0ca6ec37b1 100644 --- a/examples/mvc/lib/boot.js +++ b/examples/mvc/lib/boot.js @@ -8,6 +8,7 @@ var fs = require('fs'); module.exports = function(parent, options){ var verbose = options.verbose; fs.readdirSync(__dirname + '/../controllers').forEach(function(name){ + if (!fs.statSync(__dirname + '/../controllers/' + name).isDirectory()) return; verbose && console.log('\n %s:', name); var obj = require('./../controllers/' + name); var name = obj.name || name; From c238aca43875fe804df1e7e076dd3f63211f2e02 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jan 2017 22:48:08 -0500 Subject: [PATCH 0998/1265] examples: remove big-view example --- examples/big-view/index.js | 31 ------------------------------- examples/big-view/pets.jade | 12 ------------ 2 files changed, 43 deletions(-) delete mode 100644 examples/big-view/index.js delete mode 100644 examples/big-view/pets.jade diff --git a/examples/big-view/index.js b/examples/big-view/index.js deleted file mode 100644 index 0814cbb6e01..00000000000 --- a/examples/big-view/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Module dependencies. - */ - -var express = require('../..'); -var logger = require('morgan'); -var app = express(); - -app.set('views', __dirname); -app.set('view engine', 'jade'); - -var pets = []; - -var n = 1000; -while (n--) { - pets.push({ name: 'Tobi', age: 2, species: 'ferret' }); - pets.push({ name: 'Loki', age: 1, species: 'ferret' }); - pets.push({ name: 'Jane', age: 6, species: 'ferret' }); -} - -app.use(logger('dev')); - -app.get('/', function(req, res){ - res.render('pets', { pets: pets }); -}); - -/* istanbul ignore next */ -if (!module.parent) { - app.listen(3000); - console.log('Express started on port 3000'); -} diff --git a/examples/big-view/pets.jade b/examples/big-view/pets.jade deleted file mode 100644 index afb086819c2..00000000000 --- a/examples/big-view/pets.jade +++ /dev/null @@ -1,12 +0,0 @@ -style. - body { - padding: 50px; - font: 16px "Helvetica Neue", Helvetica; - } - -table - for pet in pets - tr - td= pet.name - td= pet.age - td= pet.species \ No newline at end of file From 0d6c64fdfd0bd6031dc23df2c5f9abdf6e4bbb11 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 26 Jan 2017 22:54:05 -0500 Subject: [PATCH 0999/1265] deps: type-is@~1.6.14 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ec0568ddf20..5d69820a80f 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,8 @@ unreleased - deps: statuses@~1.3.1 * deps: serve-static@~1.11.2 - deps: send@0.14.2 + * deps: type-is@~1.6.14 + - deps: mime-types@~2.1.13 4.14.0 / 2016-06-16 =================== diff --git a/package.json b/package.json index 017ef91ac6e..c8ff63519e1 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "range-parser": "~1.2.0", "send": "0.14.2", "serve-static": "~1.11.2", - "type-is": "~1.6.13", + "type-is": "~1.6.14", "utils-merge": "1.0.0", "vary": "~1.1.0" }, From 0b39fa2f7c5a68c956019eff01c002968e8966db Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Jan 2017 16:40:40 -0500 Subject: [PATCH 1000/1265] build: should@11.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8ff63519e1..d39ac73503b 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "mocha": "3.2.0", "morgan": "~1.7.0", "multiparty": "4.1.3", - "should": "11.1.2", + "should": "11.2.0", "supertest": "1.2.0", "connect-redis": "~2.4.1", "cookie-session": "~1.2.0", From 1f70b76c453e9550545e9a5a91a97d5d0dba3e32 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Jan 2017 16:56:34 -0500 Subject: [PATCH 1001/1265] build: Node.js@4.7 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3bd122f5d81..924fd00a2aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: - "1.8" - "2.5" - "3.3" - - "4.6" + - "4.7" - "5.12" - "6.9" sudo: false diff --git a/appveyor.yml b/appveyor.yml index 18d5c4abe02..72f86987907 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ environment: - nodejs_version: "1.8" - nodejs_version: "2.5" - nodejs_version: "3.3" - - nodejs_version: "4.6" + - nodejs_version: "4.7" - nodejs_version: "5.12" - nodejs_version: "6.9" cache: From 0437c513f2dbc8d1dfc5a3e35fe35182bd3a671e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Jan 2017 17:21:24 -0500 Subject: [PATCH 1002/1265] 4.14.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 5d69820a80f..4a706a4d104 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.14.1 / 2017-01-28 +=================== * deps: content-disposition@0.5.2 * deps: finalhandler@0.5.1 diff --git a/package.json b/package.json index d39ac73503b..d499a6df13e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.14.0", + "version": "4.14.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 94377f681d66efff100aa2a9086398b0df5688f8 Mon Sep 17 00:00:00 2001 From: Takuma Hanatani Date: Wed, 1 Feb 2017 18:26:16 +0900 Subject: [PATCH 1003/1265] lint: remove unnecessary semicolon closes #3191 --- lib/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/request.js b/lib/request.js index 557d050ffb5..513c9bf3d46 100644 --- a/lib/request.js +++ b/lib/request.js @@ -499,4 +499,4 @@ function defineGetter(obj, name, getter) { enumerable: true, get: getter }); -}; +} From 4f291e7d55d6093ecc4a99d88c785dee22d6d125 Mon Sep 17 00:00:00 2001 From: Tom Hosford Date: Wed, 1 Feb 2017 18:28:26 -0500 Subject: [PATCH 1004/1265] examples: use res.format in error-pages closes #3195 --- examples/error-pages/index.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/examples/error-pages/index.js b/examples/error-pages/index.js index aff985bd674..d1219689f2c 100644 --- a/examples/error-pages/index.js +++ b/examples/error-pages/index.js @@ -60,20 +60,17 @@ app.get('/500', function(req, res, next){ app.use(function(req, res, next){ res.status(404); - // respond with html page - if (req.accepts('html')) { - res.render('404', { url: req.url }); - return; - } - - // respond with json - if (req.accepts('json')) { - res.send({ error: 'Not found' }); - return; - } - - // default to plain-text. send() - res.type('txt').send('Not found'); + res.format({ + html: function () { + res.render('404', { url: req.url }) + }, + json: function () { + res.json({ error: 'Not found' }) + }, + default: function () { + res.type('txt').send('Not found') + } + }) }); // error-handling middleware, take the same form From fb3946f4549395b2f0d3a166ef74eb407d11549b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 4 Feb 2017 20:54:47 -0500 Subject: [PATCH 1005/1265] lint: fix broken indentation in tests --- test/req.ip.js | 4 ++-- test/res.sendFile.js | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/req.ip.js b/test/req.ip.js index 3ca575e11bd..1cd255216b9 100644 --- a/test/req.ip.js +++ b/test/req.ip.js @@ -79,8 +79,8 @@ describe('req', function(){ res.send(req.ip); }); - var test = request(app).get('/') - test.expect(200, getExpectedClientAddress(test._server), done); + var test = request(app).get('/') + test.expect(200, getExpectedClientAddress(test._server), done) }) }) }) diff --git a/test/res.sendFile.js b/test/res.sendFile.js index ece09ee0731..927d31991f0 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -157,8 +157,8 @@ describe('res', function(){ describe('with "headers" option', function () { it('should accept headers option', function (done) { var headers = { - 'x-success': 'sent', - 'x-other': 'done' + 'x-success': 'sent', + 'x-other': 'done' }; var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), { headers: headers }); @@ -510,8 +510,8 @@ describe('res', function(){ it('should accept headers option', function(done){ var app = express(); var headers = { - 'x-success': 'sent', - 'x-other': 'done' + 'x-success': 'sent', + 'x-other': 'done' }; app.use(function(req, res){ @@ -730,19 +730,19 @@ describe('res', function(){ }) }) - describe('.sendfile(path, options)', function () { - it('should pass options to send module', function (done) { - var app = express() +describe('.sendfile(path, options)', function () { + it('should pass options to send module', function (done) { + var app = express() - app.use(function (req, res) { - res.sendfile(path.resolve(fixtures, 'name.txt'), { start: 0, end: 1 }) - }) + app.use(function (req, res) { + res.sendfile(path.resolve(fixtures, 'name.txt'), { start: 0, end: 1 }) + }) - request(app) + request(app) .get('/') .expect(200, 'to', done) - }) }) +}) function createApp(path, options, fn) { var app = express(); From abd1de73c14985c884d11fb35aff5f4b17381e23 Mon Sep 17 00:00:00 2001 From: Sebastian Van Sande Date: Mon, 6 Feb 2017 13:09:59 +0100 Subject: [PATCH 1006/1265] tests: fix misnamed app.router test section fixes #3194 closes #3199 --- test/app.router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/app.router.js b/test/app.router.js index 11e492cbfae..6d41778c038 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -90,7 +90,7 @@ describe('app.router', function(){ }); }) - describe('decode querystring', function(){ + describe('decode params', function () { it('should decode correct params', function(done){ var app = express(); From 034f261fea1eed22d79706ef3c29666acc5fce4a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 15 Feb 2017 23:36:17 -0500 Subject: [PATCH 1007/1265] examples: use pbkdf2-password module in auth example closes #3207 --- examples/auth/index.js | 6 +++--- examples/auth/pass.js | 48 ------------------------------------------ package.json | 1 + 3 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 examples/auth/pass.js diff --git a/examples/auth/index.js b/examples/auth/index.js index d110fe28d42..1c3ca217512 100644 --- a/examples/auth/index.js +++ b/examples/auth/index.js @@ -3,8 +3,8 @@ */ var express = require('../..'); -var hash = require('./pass').hash; var bodyParser = require('body-parser'); +var hash = require('pbkdf2-password')() var session = require('express-session'); var app = module.exports = express(); @@ -45,7 +45,7 @@ var users = { // when you create a user, generate a salt // and hash the password ('foobar' is the pass here) -hash('foobar', function(err, salt, hash){ +hash({ password: 'foobar' }, function (err, pass, salt, hash) { if (err) throw err; // store the salt & hash in the "db" users.tj.salt = salt; @@ -63,7 +63,7 @@ function authenticate(name, pass, fn) { // apply the same algorithm to the POSTed password, applying // the hash against the pass / salt, if there is a match we // found the user - hash(pass, user.salt, function(err, hash){ + hash({ password: pass, salt: user.salt }, function (err, pass, salt, hash) { if (err) return fn(err); if (hash == user.hash) return fn(null, user); fn(new Error('invalid password')); diff --git a/examples/auth/pass.js b/examples/auth/pass.js deleted file mode 100644 index fefb25b66a5..00000000000 --- a/examples/auth/pass.js +++ /dev/null @@ -1,48 +0,0 @@ - -// check out https://github.com/tj/node-pwd - -/** - * Module dependencies. - */ - -var crypto = require('crypto'); - -/** - * Bytesize. - */ - -var len = 128; - -/** - * Iterations. ~300ms - */ - -var iterations = 12000; - -/** - * Hashes a password with optional `salt`, otherwise - * generate a salt for `pass` and invoke `fn(err, salt, hash)`. - * - * @param {String} password to hash - * @param {String} optional salt - * @param {Function} callback - * @api public - */ - -exports.hash = function (pwd, salt, fn) { - if (3 == arguments.length) { - crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){ - fn(err, hash.toString('base64')); - }); - } else { - fn = salt; - crypto.randomBytes(len, function(err, salt){ - if (err) return fn(err); - salt = salt.toString('base64'); - crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){ - if (err) return fn(err); - fn(null, salt, hash.toString('base64')); - }); - }); - } -}; diff --git a/package.json b/package.json index d499a6df13e..72b266a3afb 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "mocha": "3.2.0", "morgan": "~1.7.0", "multiparty": "4.1.3", + "pbkdf2-password": "1.2.1", "should": "11.2.0", "supertest": "1.2.0", "connect-redis": "~2.4.1", From c48014fde8682f59c2fff8f0ae4655daf8de3b0d Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Wed, 15 Feb 2017 17:14:06 -0800 Subject: [PATCH 1008/1265] docs: minor fixes to contributing guide --- Contributing.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Contributing.md b/Contributing.md index 2ddfa7a62a4..214e9070126 100644 --- a/Contributing.md +++ b/Contributing.md @@ -1,20 +1,13 @@ -# Node.js Community Contributing Guide 1.0 - -This document describes a very simple process suitable for most projects -in the Node.js ecosystem. Projects are encouraged to adopt this whether they -are hosted in the Node.js Foundation or not. +# Express.js Community Contributing Guide 1.0 The goal of this document is to create a contribution process that: * Encourages new contributions. * Encourages contributors to remain involved. * Avoids unnecessary processes and bureaucracy whenever possible. -* Creates a transparent decision making process which makes it clear how +* Creates a transparent decision making process that makes it clear how contributors can be involved in decision making. -This document is based on much prior art in the Node.js community, io.js, -and the Node.js project. - ## Vocabulary * A **Contributor** is any individual creating or commenting on an issue or pull request. @@ -24,7 +17,7 @@ expertise to resolve rare disputes. # Logging Issues -Log an issue for any question or problem you might have. When in doubt, log an issue, +Log an issue for any question or problem you might have. When in doubt, log an issue, and any additional policies about what to include will be provided in the responses. The only exception is security dislosures which should be sent privately. From 7ef92f8a171aeb7c90260a0ba92015862da1a0eb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Feb 2017 00:42:57 -0500 Subject: [PATCH 1009/1265] examples: remove semi-broken expose-data-to-client example --- examples/expose-data-to-client/index.js | 64 ------------------- .../expose-data-to-client/views/page.jade | 14 ---- 2 files changed, 78 deletions(-) delete mode 100644 examples/expose-data-to-client/index.js delete mode 100644 examples/expose-data-to-client/views/page.jade diff --git a/examples/expose-data-to-client/index.js b/examples/expose-data-to-client/index.js deleted file mode 100644 index 5dd99df682a..00000000000 --- a/examples/expose-data-to-client/index.js +++ /dev/null @@ -1,64 +0,0 @@ - -var express = require('../..'); -var logger = require('morgan'); -var app = express(); - -app.set('view engine', 'jade'); -app.set('views', __dirname + '/views'); - -function User(name) { - this.private = 'heyyyy'; - this.secret = 'something'; - this.name = name; - this.id = 123; -} - -// You'll probably want to do -// something like this so you -// dont expose "secret" data. - -User.prototype.toJSON = function(){ - return { - id: this.id, - name: this.name - }; -}; - -app.use(logger('dev')); - -// earlier on expose an object -// that we can tack properties on. -// all res.locals props are exposed -// to the templates, so "expose" will -// be present. - -app.use(function(req, res, next){ - res.locals.expose = {}; - // you could alias this as req or res.expose - // to make it shorter and less annoying - next(); -}); - -// pretend we loaded a user - -app.use(function(req, res, next){ - req.user = new User('Tobi'); - next(); -}); - -app.get('/', function(req, res){ - res.redirect('/user'); -}); - -app.get('/user', function(req, res){ - // we only want to expose the user - // to the client for this route: - res.locals.expose.user = req.user; - res.render('page'); -}); - -/* istanbul ignore next */ -if (!module.parent) { - app.listen(3000); - console.log('Express started on port 3000'); -} diff --git a/examples/expose-data-to-client/views/page.jade b/examples/expose-data-to-client/views/page.jade deleted file mode 100644 index 6e58a18afbc..00000000000 --- a/examples/expose-data-to-client/views/page.jade +++ /dev/null @@ -1,14 +0,0 @@ -html - head - title Express - script. - // call this whatever you like, - // or dump them into individual - // props like "var user =" - var data = !{JSON.stringify(expose)} - body - h1 Expose client data - p The following was exposed to the client: - pre - script. - document.write(JSON.stringify(data, null, 2)) \ No newline at end of file From eb326d7ecb52a555f08aba4ebf8744512db1240b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 20 Feb 2017 16:55:15 -0500 Subject: [PATCH 1010/1265] tests: update req.is tests to run through express --- test/req.is.js | 213 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 139 insertions(+), 74 deletions(-) diff --git a/test/req.is.js b/test/req.is.js index e5adb19de90..a2fce178673 100644 --- a/test/req.is.js +++ b/test/req.is.js @@ -1,103 +1,168 @@ -var express = require('../') - , request = require('supertest'); - -function req(ct) { - var req = { - headers: { - 'content-type': ct, - 'transfer-encoding': 'chunked' - }, - __proto__: express.request - }; - - return req; -} - -describe('req.is()', function(){ - it('should ignore charset', function(){ - req('application/json') - .is('json') - .should.equal('json'); +var express = require('..') +var request = require('supertest') + +describe('req.is()', function () { + describe('when given a mime type', function () { + it('should return the type when matching', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('application/json')) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, '"application/json"', done) + }) + + it('should return false when not matching', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('image/jpeg')) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, 'false', done) + }) + + it('should ignore charset', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('application/json')) + }) + + request(app) + .post('/') + .type('application/json; charset=UTF-8') + .send('{}') + .expect(200, '"application/json"', done) + }) }) describe('when content-type is not present', function(){ - it('should return false', function(){ - req('') - .is('json') - .should.be.false; + it('should return false', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('application/json')) + }) + + request(app) + .post('/') + .send('{}') + .expect(200, 'false', done) }) }) describe('when given an extension', function(){ - it('should lookup the mime type', function(){ - req('application/json') - .is('json') - .should.equal('json'); - - req('text/html') - .is('json') - .should.be.false; - }) - }) + it('should lookup the mime type', function (done) { + var app = express() - describe('when given a mime type', function(){ - it('should match', function(){ - req('application/json') - .is('application/json') - .should.equal('application/json'); + app.use(function (req, res) { + res.json(req.is('json')) + }) - req('image/jpeg') - .is('application/json') - .should.be.false; + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, '"json"', done) }) }) describe('when given */subtype', function(){ - it('should match', function(){ - req('application/json') - .is('*/json') - .should.equal('application/json'); - - req('image/jpeg') - .is('*/json') - .should.be.false; + it('should return the full type when matching', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('*/json')) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, '"application/json"', done) + }) + + it('should return false when not matching', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('*/html')) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, 'false', done) }) - describe('with a charset', function(){ - it('should match', function(){ - req('text/html; charset=utf-8') - .is('*/html') - .should.equal('text/html'); + it('should ignore charset', function (done) { + var app = express() - req('text/plain; charset=utf-8') - .is('*/html') - .should.be.false; + app.use(function (req, res) { + res.json(req.is('*/json')) }) + + request(app) + .post('/') + .type('application/json; charset=UTF-8') + .send('{}') + .expect(200, '"application/json"', done) }) }) describe('when given type/*', function(){ - it('should match', function(){ - req('image/png') - .is('image/*') - .should.equal('image/png'); - - req('text/html') - .is('image/*') - .should.be.false; + it('should return the full type when matching', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('application/*')) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, '"application/json"', done) }) - describe('with a charset', function(){ - it('should match', function(){ - req('text/html; charset=utf-8') - .is('text/*') - .should.equal('text/html'); + it('should return false when not matching', function (done) { + var app = express() - req('something/html; charset=utf-8') - .is('text/*') - .should.be.false; + app.use(function (req, res) { + res.json(req.is('text/*')) }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, 'false', done) + }) + + it('should ignore charset', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is('application/*')) + }) + + request(app) + .post('/') + .type('application/json; charset=UTF-8') + .send('{}') + .expect(200, '"application/json"', done) }) }) }) From 3e3d35777d3e3081b33ce7d50c8a5c855b450534 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 20 Feb 2017 17:09:21 -0500 Subject: [PATCH 1011/1265] tests: update req.range tests to run through express --- test/req.range.js | 110 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 83 insertions(+), 27 deletions(-) diff --git a/test/req.range.js b/test/req.range.js index d530d85a645..09459d1e127 100644 --- a/test/req.range.js +++ b/test/req.range.js @@ -1,47 +1,103 @@ var assert = require('assert'); var express = require('..'); - -function req(ret) { - return { - get: function(){ return ret } - , __proto__: express.request - }; -} +var request = require('supertest') describe('req', function(){ describe('.range(size)', function(){ - it('should return parsed ranges', function(){ - var ranges = [{ start: 0, end: 50 }, { start: 51, end: 100 }] - ranges.type = 'bytes' - assert.deepEqual(req('bytes=0-50,51-100').range(120), ranges) + it('should return parsed ranges', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.range(120)) + }) + + request(app) + .get('/') + .set('Range', 'bytes=0-50,51-100') + .expect(200, '[{"start":0,"end":50},{"start":51,"end":100}]', done) }) - it('should cap to the given size', function(){ - var ret = [{ start: 0, end: 74 }]; - ret.type = 'bytes'; - req('bytes=0-100').range(75).should.eql(ret); + it('should cap to the given size', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.range(75)) + }) + + request(app) + .get('/') + .set('Range', 'bytes=0-100') + .expect(200, '[{"start":0,"end":74}]', done) }) - it('should have a .type', function(){ - var ret = [{ start: 0, end: Infinity }]; - ret.type = 'users'; - req('users=0-').range(Infinity).should.eql(ret); + it('should cap to the given size when open-ended', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.range(75)) + }) + + request(app) + .get('/') + .set('Range', 'bytes=0-') + .expect(200, '[{"start":0,"end":74}]', done) }) - it('should return undefined if no range', function(){ - var ret = [{ start: 0, end: 50 }, { start: 60, end: 100 }]; - ret.type = 'bytes'; - assert(req('').range(120) === undefined); + it('should have a .type', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.range(120).type) + }) + + request(app) + .get('/') + .set('Range', 'bytes=0-100') + .expect(200, '"bytes"', done) + }) + + it('should accept any type', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.range(120).type) + }) + + request(app) + .get('/') + .set('Range', 'users=0-2') + .expect(200, '"users"', done) + }) + + it('should return undefined if no range', function (done) { + var app = express() + + app.use(function (req, res) { + res.send(String(req.range(120))) + }) + + request(app) + .get('/') + .expect(200, 'undefined', done) }) }) describe('.range(size, options)', function(){ describe('with "combine: true" option', function(){ - it('should return combined ranges', function(){ - var ranges = [{ start: 0, end: 100 }] - ranges.type = 'bytes' - assert.deepEqual(req('bytes=0-50,51-100').range(120, { combine: true }), ranges) + it('should return combined ranges', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.range(120, { + combine: true + })) + }) + + request(app) + .get('/') + .set('Range', 'bytes=0-50,51-100') + .expect(200, '[{"start":0,"end":100}]', done) }) }) }) From f3a47e39a4aeaba36c4881ccafbe12262278e9f4 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Wed, 15 Feb 2017 17:18:57 -0800 Subject: [PATCH 1012/1265] docs: update collaborator guide --- Collaborator-Guide.md | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Collaborator-Guide.md b/Collaborator-Guide.md index abbfc109429..7c0d265dd0a 100644 --- a/Collaborator-Guide.md +++ b/Collaborator-Guide.md @@ -6,25 +6,36 @@ Open issues for the expressjs.com website in https://github.com/expressjs/expres ## PRs and Code contributions * Tests must pass. -* Follow existing coding style. +* Follow the [JavaScript Standard Style](http://standardjs.com/). * If you fix a bug, add a test. ## Branches -* Use the `master` branch for bug fixes or minor work that is intended for the current release stream -* Use the correspondingly named branch, e.g. `5.0`, for anything intended for a future release of Express +Use the `master` branch for bug fixes or minor work that is intended for the +current release stream. + +Use the correspondingly named branch, e.g. `5.0`, for anything intended for +a future release of Express. ## Steps for contributing -* [Create an issue](https://github.com/expressjs/express/issues/new) for the bug you want to fix or the feature that you want to add. -* Create your own [fork](https://github.com/expressjs/express) on github, then checkout your fork. -* Write your code in your local copy. It's good practice to create a branch for each new issue you work on, although not compulsory. -* To run the test suite, first install the dependencies by running `npm install`, then run `npm test`. -* If the tests pass, you can commit your changes to your fork and then create a pull request from there. Make sure to reference your issue from the pull request comments by including the issue number e.g. #123. +1. [Create an issue](https://github.com/expressjs/express/issues/new) for the + bug you want to fix or the feature that you want to add. +2. Create your own [fork](https://github.com/expressjs/express) on github, then + checkout your fork. +3. Write your code in your local copy. It's good practice to create a branch for + each new issue you work on, although not compulsory. +4. To run the test suite, first install the dependencies by running `npm install`, + then run `npm test`. +5. If the tests pass, you can commit your changes to your fork and then create + a pull request from there. Make sure to reference your issue from the pull + request comments by including the issue number e.g. `#123`. ## Issues which are questions -We will typically close any vague issues or questions that are specific to some app you are writing. Please double check the docs and other references before being trigger happy with posting a question issue. +We will typically close any vague issues or questions that are specific to some +app you are writing. Please double check the docs and other references before +being trigger happy with posting a question issue. Things that will help get your question issue looked at: @@ -33,4 +44,5 @@ Things that will help get your question issue looked at: * Clear description of the expected result. * Steps you have taken to debug it yourself. -If you post a question and do not outline the above items or make it easy for us to understand and reproduce your issue, it will be closed. +If you post a question and do not outline the above items or make it easy for +us to understand and reproduce your issue, it will be closed. From 1678613db165126306bd79ca6bda310c5cf9bb62 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Wed, 15 Feb 2017 17:02:13 -0800 Subject: [PATCH 1013/1265] docs: add guide for writing readmes closes #3209 --- Readme-Guide.md | 125 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 Readme-Guide.md diff --git a/Readme-Guide.md b/Readme-Guide.md new file mode 100644 index 00000000000..34d4648b9c2 --- /dev/null +++ b/Readme-Guide.md @@ -0,0 +1,125 @@ +# README guidelines + +Every module in the expressjs, pillarjs, and jshttp organizations should have +a README file named `README.md`. The purpose of the README is to: + +- Explain the purpose of the module and how to use it. +- Act as a landing page (both on GitHub and npmjs.com) for the module to help + people find it via search. Middleware module READMEs are also incorporated + into https://expressjs.com/en/resources/middleware.html. +- Encourage community contributions and participation. + +Use the [README template](https://github.com/expressjs/express/wiki/README-template) +to quickly create a new README file. + +## Top-level items + +**Badges** (optional): At the very top (with no subheading), include any +applicable badges, such as npm version/downloads, build status, test coverage, +and so on. Badges should resolve properly (not display a broken image). + +Possible badges include: +- npm version: `[![NPM Version][npm-image]][npm-url]` +- npm downloads: `[![NPM Downloads][downloads-image]][downloads-url]` +- Build status: `[![Build Status][travis-image]][travis-url]` +- Test coverage: `[![Test Coverage][coveralls-image]][coveralls-url]` +- Tips: `[![Gratipay][gratipay-image]][gratipay-url]` + +**Summary**: Following badges, provide a one- or two-sentence description of +what the module does. This should be the same as the npmjs.org blurb (which +comes from the description property of `package.json`). Since npm doesn't +handle markdown for the blurb, avoid using markdown in the summary sentence. + +**TOC** (Optional): For longer READMEs, provide a table of contents that has +a relative link to each section. A tool such as +[doctoc](https://www.npmjs.com/package/doctoc) makes it very easy to generate +a TOC. + +## Overview + +Optionally, include a section of one or two paragraphs with more high-level +information on what the module does, what problems it solves, why one would +use it and how. Don't just repeat what's in the summary. + +## Installation + +Required. This section is typically just: + +```sh +$ npm install module-name +``` + +But include any other steps or requirements. + +NOTE: Use the `sh` code block to make the shell command display properly on +the website. + +## Basic use + +- Provide a general description of how to use the module with code sample. + Include any important caveats or restrictions. +- Explain the most common use cases. +- Optional: a simple "hello world" type example (where applicable). This + example is in addition to the more comprehensive [example section](#examples) + later. + +## API + +Provide complete API documentation. + +Formatting conventions: Each function is listed in a 3rd-level heading (`###`), +like this: + +``` +### Function_name(arg, options [, optional_arg] ... ) +``` + +**Options objects** + +For arguments that are objects (for example, options object), describe the +properties in a table, as follows. This matches the formatting used in the +[Express API docs](https://expressjs.com/en/4x/api.html). + +|Property | Description | Type | Default| +|----------|-----------|------------|-------------| +|Name of the property in `monospace`. | Brief description | String, Number, Boolean, etc. | If applicable.| + +If all the properties are required (i.e. there are no defaults), then you +can omit the default column. + +Instead of very lengthy descriptions, link out to subsequent paragraphs for +more detailed explanation of specific cases (e.g. "When this property is set +to 'foobar', xyz happens; see <link to following section >.) + +If there are options properties that are themselves options, use additional +tables. See [`trust proxy` and `etag` properties](https://expressjs.com/en/4x/api.html#app.settings.table). + +## Examples + +Every README should have at least one example; ideally more. For code samples, +be sure to use the `js` code block, for proper display in the website, e.g.: + +```js +var csurf = require('csurf') +... +``` + +## Tests + +What tests are included. + +How to run them. + +The convention for running tests is `npm test`. All our projects should follow +this convention. + +## Contributors + +Names of module "owners" (lead developers) and other developers who have +contributed. + +## License + +Link to the license, with a short description of what it is, e.g. "MIT" or +whatever. Ideally, avoid putting the license text directly in the README; link +to it instead. From 4420a7bd94f811e4e40caa5fcf5b67ecae779d2f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 20 Feb 2017 18:25:42 -0500 Subject: [PATCH 1014/1265] docs: update link to expressjs.com website repo --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index e9bfaeba20d..0ddc68fdc9a 100644 --- a/Readme.md +++ b/Readme.md @@ -37,7 +37,7 @@ $ npm install express ## Docs & Community - * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)] + * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)] * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules * Visit the [Wiki](https://github.com/expressjs/express/wiki) From 1a99bb051947fbf06b6b415bba06f8c83247c0d1 Mon Sep 17 00:00:00 2001 From: Mike Tunnicliffe Date: Mon, 15 Feb 2016 17:25:35 +0000 Subject: [PATCH 1015/1265] docs: add release guide closes #2857 closes #2890 --- Release-Process.md | 186 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 Release-Process.md diff --git a/Release-Process.md b/Release-Process.md new file mode 100644 index 00000000000..ae740972f77 --- /dev/null +++ b/Release-Process.md @@ -0,0 +1,186 @@ +# Express Release Process + +This document contains the technical aspects of the Express release process. The +intended audience is those who have been authorized by the Express Technical +Committee (TC) to create, promote and sign official release builds for Express, +as npm packages hosted on https://npmjs.com/package/express. + +## Who can make releases? + +Release authorization is given by the Express TC. Once authorized, an individual +must have the following access permissions: + +### 1. Github release access + +The individual making the release will need to be a member of the +expressjs/express team with Write permission level so they are able to tag the +release commit and push changes to the expressjs/express repository +(see Steps 4 and 5). + +### 2. npmjs.com release access + +The individual making the release will need to be made an owner on the +`express` package on npmjs.com so they are able to publish the release +(see Step 6). + +## How to publish a release + +Before publishing, the following preconditions should be met: + +- A release proposal issue or tracking pull request (see "Proposal branch" + below) will exist documenting: + - the proposed changes + - the type of release: patch, minor or major + - the version number (according to semantic versioning - http://semver.org) +- The proposed changes should be complete. + +There are two main release flows: patch and non-patch. + +The patch flow is for making **patch releases**. As per semantic versioning, +patch releases are for simple changes, eg: typo fixes, patch dependency updates, +and simple/low-risk bug fixes. Every other type of change is made via the +non-patch flow. + +### Branch terminology + +"Master branch" + +- There is a branch in git used for the current major version of Express, named + `master`. +- This branch contains the completed commits for the next patch release of the + current major version. +- Releases for the current major version are published from this branch. + +"Version branch" + +- For any given major version of Express (current, previous or next) there is + a branch in git for that release named `.x` (eg: `4.x`). +- This branch points to the commit of the latest tag for the given major version. + +"Release branch" + +- For any given major version of Express, there is a branch used for publishing + releases. +- For the current major version of Express, the release branch is the + "Master branch" named `master`. +- For all other major versions of Express, the release branch is the + "Version branch" named `.x`. + +"Proposal branch" + +- A branch in git representing a proposed new release of Express. This can be a + minor or major release, named `.0` for a major release, + `.` for a minor release. +- A tracking pull request should exist to document the proposed release, + targeted at the appropriate release branch. Prior to opening the tracking + pull request the content of the release may have be discussed in an issue. +- This branch contains the commits accepted so far that implement the proposal + in the tracking pull request. + +### Patch flow + +In the patch flow, simple changes are committed to the release branch which +acts as an ever-present branch for the next patch release of the associated +major version of Express. + +The release branch is usually kept in a state where it is ready to release. +Releases are made when sufficient time or change has been made to warrant it. +This is usually proposed and decided using a github issue. + +### Non-patch flow + +In the non-patch flow, changes are committed to a temporary proposal branch +created specifically for that release proposal. The branch is based on the +most recent release of the major version of Express that the release targets. + +Releases are made when all the changes on a proposal branch are complete and +approved. This is done by merging the proposal branch into the release branch +(using a fast-forward merge), tagging it with the new version number and +publishing the release package to npmjs.com. + +### Flow + +Below is a detailed description of the steps to publish a release. + +#### Step 1. Check the release is ready to publish + +Check any relevant information to ensure the release is ready, eg: any +milestone, label, issue or tracking pull request for the release. The release +is ready when all proposed code, tests and documentation updates are complete +(either merged, closed or re-targeted to another release). + +#### Step 2. (Non-patch flow only) Merge the proposal branch into the release branch + +In the patch flow: skip this step. + +In the non-patch flow: +```sh +$ git checkout +$ git merge --ff-only +``` + + - see "Release branch" of "Branches" above. + - see "Proposal branch" of "Non-patch flow" above. + +**NOTE:** You may need to rebase the proposal branch to allow a fast-forward + merge. Using a fast-forward merge keeps the history clean as it does + not introduce merge commits. + +### Step 3. Update the History.md and package.json to the new version number + +The changes so far for the release should already be documented under the +"unreleased" section at the top of the History.md file, as per the usual +development practice. Change "unreleased" to the new release version / date. +Example diff fragment: + +```diff +-unreleased +-========== ++4.13.3 / 2015-08-02 ++=================== +``` + +The version property in the package.json should already contain the version of +the previous release. Change it to the new release version. + +Commit these changes together under a single commit with the message set to +the new release version (eg: `4.13.3`): + +```sh +$ git checkout +<..edit files..> +$ git add History.md package.json +$ git commit -m '' +``` + +### Step 4. Identify and tag the release commit with the new release version + +Create a lightweight tag (rather than an annotated tag) named after the new +release version (eg: `4.13.3`). + +```sh +$ git tag +``` + +### Step 5. Push the release branch changes and tag to github + +The branch and tag should be pushed directly to the main repository +(https://github.com/expressjs/express). + +```sh +$ git push origin +$ git push origin +``` + +### Step 6. Publish to npmjs.com + +Ensure your local working copy is completely clean (no extra or changed files). +You can use `git status` for this purpose. + +```sh +$ npm login +$ npm publish +``` + +**NOTE:** The version number to publish will be picked up automatically from + package.json. From fefd7290376ca865e348d747592543a119a2ff98 Mon Sep 17 00:00:00 2001 From: Pravdomil Date: Sun, 25 Dec 2016 19:28:15 +0100 Subject: [PATCH 1016/1265] Add debug message when loading view engine closes #3158 --- History.md | 5 +++++ lib/view.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 4a706a4d104..e78bd75083d 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Add debug message when loading view engine + 4.14.1 / 2017-01-28 =================== diff --git a/lib/view.js b/lib/view.js index 52415d4c28b..1728725d291 100644 --- a/lib/view.js +++ b/lib/view.js @@ -75,7 +75,9 @@ function View(name, options) { if (!opts.engines[this.ext]) { // load engine - opts.engines[this.ext] = require(this.ext.substr(1)).__express; + var mod = this.ext.substr(1) + debug('require "%s"', mod) + opts.engines[this.ext] = require(mod).__express } // store loaded engine From bbed8021c6f634b5eeec52f0f70666f76c78e918 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Feb 2017 00:58:46 -0500 Subject: [PATCH 1017/1265] build: support Node.js 7.x --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 924fd00a2aa..c8220d9b83a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ node_js: - "4.7" - "5.12" - "6.9" + - "7.5" sudo: false cache: directories: diff --git a/appveyor.yml b/appveyor.yml index 72f86987907..4717f2735a8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,6 +8,7 @@ environment: - nodejs_version: "4.7" - nodejs_version: "5.12" - nodejs_version: "6.9" + - nodejs_version: "7.5" cache: - node_modules install: From c63424a0a11a29c067dd0e6ae284d6d821917f32 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Feb 2017 01:22:17 -0500 Subject: [PATCH 1018/1265] deps: debug@2.6.1 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e78bd75083d..17a6027733e 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,12 @@ unreleased ========== * Add debug message when loading view engine + * deps: debug@2.6.1 + - Allow colors in workers + - Deprecated `DEBUG_FD` environment variable set to `3` or higher + - Fix error when running under React Native + - Use same color for same namespace + - deps: ms@0.7.2 4.14.1 / 2017-01-28 =================== diff --git a/package.json b/package.json index 72b266a3afb..28a07ea618b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "content-type": "~1.0.2", "cookie": "0.3.1", "cookie-signature": "1.0.6", - "debug": "~2.2.0", + "debug": "2.6.1", "depd": "~1.1.0", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", From 906164b204efa1e27af16468ad2cd2b1532212b0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Feb 2017 01:23:51 -0500 Subject: [PATCH 1019/1265] deps: qs@6.3.1 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 17a6027733e..c46cda0d152 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,9 @@ unreleased - Fix error when running under React Native - Use same color for same namespace - deps: ms@0.7.2 + * deps: qs@6.3.1 + - Fix array parsing from skipping empty values + - Fix compacting nested arrays 4.14.1 / 2017-01-28 =================== diff --git a/package.json b/package.json index 28a07ea618b..dfe12046f7f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", "proxy-addr": "~1.1.3", - "qs": "6.2.0", + "qs": "6.3.1", "range-parser": "~1.2.0", "send": "0.14.2", "serve-static": "~1.11.2", From 485b6f86ac43814c2b596f14648f8b6e1a373a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Sanz?= Date: Tue, 4 Aug 2015 00:28:54 +0200 Subject: [PATCH 1020/1265] perf: improve req.ips performance closes #2723 --- History.md | 1 + lib/request.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c46cda0d152..c7410703e72 100644 --- a/History.md +++ b/History.md @@ -11,6 +11,7 @@ unreleased * deps: qs@6.3.1 - Fix array parsing from skipping empty values - Fix compacting nested arrays + * perf: improve `req.ips` performance 4.14.1 / 2017-01-28 =================== diff --git a/lib/request.js b/lib/request.js index 513c9bf3d46..78945e5da7a 100644 --- a/lib/request.js +++ b/lib/request.js @@ -356,7 +356,12 @@ defineGetter(req, 'ip', function ip(){ defineGetter(req, 'ips', function ips() { var trust = this.app.get('trust proxy fn'); var addrs = proxyaddr.all(this, trust); - return addrs.slice(1).reverse(); + + // reverse the order (to farthest -> closest) + // and remove socket address + addrs.reverse().pop() + + return addrs }); /** From 92c859dd055646077607619a2df79243bc8a431f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 18 Feb 2017 22:14:58 -0500 Subject: [PATCH 1021/1265] deps: finalhandler@~1.0.0 --- History.md | 7 +++++++ package.json | 2 +- test/app.router.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index c7410703e72..acad7d288e0 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,13 @@ unreleased - Fix error when running under React Native - Use same color for same namespace - deps: ms@0.7.2 + * deps: finalhandler@~1.0.0 + - Fix exception when `err` cannot be converted to a string + - Fully URL-encode the pathname in the 404 + - Only include the pathname in the 404 message + - Send complete HTML document + - Set `Content-Security-Policy: default-src 'self'` header + - deps: debug@2.6.1 * deps: qs@6.3.1 - Fix array parsing from skipping empty values - Fix compacting nested arrays diff --git a/package.json b/package.json index dfe12046f7f..08aea3e25fb 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.7.0", - "finalhandler": "0.5.1", + "finalhandler": "~1.0.0", "fresh": "0.3.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", diff --git a/test/app.router.js b/test/app.router.js index 6d41778c038..301f9b86af0 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -77,7 +77,7 @@ describe('app.router', function(){ request(app) .get('/') - .expect(404, 'Cannot GET /\n', cb); + .expect(404, cb) request(app) .delete('/') From f2bbd10ae7abadae174b3cf9beb5d944dea4a90b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 18 Feb 2017 22:17:52 -0500 Subject: [PATCH 1022/1265] deps: update example dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 08aea3e25fb..10cabda8ceb 100644 --- a/package.json +++ b/package.json @@ -56,15 +56,15 @@ }, "devDependencies": { "after": "0.8.2", - "body-parser": "1.16.0", + "body-parser": "1.16.1", "cookie-parser": "~1.4.3", - "ejs": "2.5.5", - "express-session": "1.15.0", + "ejs": "2.5.6", + "express-session": "1.15.1", "istanbul": "0.4.5", "marked": "0.3.6", - "method-override": "~2.3.6", + "method-override": "2.3.7", "mocha": "3.2.0", - "morgan": "~1.7.0", + "morgan": "1.8.1", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", "should": "11.2.0", From 9f4dbae083264898a65ee2d187b1ae0302814148 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 18 Feb 2017 22:49:04 -0500 Subject: [PATCH 1023/1265] deps: etag@~1.8.0 --- History.md | 3 +++ package.json | 2 +- test/res.send.js | 16 ++++++++-------- test/utils.js | 16 ++++++++-------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/History.md b/History.md index acad7d288e0..c63b9a45b60 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,9 @@ unreleased - Fix error when running under React Native - Use same color for same namespace - deps: ms@0.7.2 + * deps: etag@~1.8.0 + - Use SHA1 instead of MD5 for ETag hashing + - Works with FIPS 140-2 OpenSSL configuration * deps: finalhandler@~1.0.0 - Fix exception when `err` cannot be converted to a string - Fully URL-encode the pathname in the 404 diff --git a/package.json b/package.json index 10cabda8ceb..b313d14d67d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "depd": "~1.1.0", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", - "etag": "~1.7.0", + "etag": "~1.8.0", "finalhandler": "~1.0.0", "fresh": "0.3.0", "merge-descriptors": "1.0.1", diff --git a/test/res.send.js b/test/res.send.js index 719424657c4..f2e7d759c15 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -133,7 +133,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"3e7-VYgCBglFKiDVAcpzPNt4Sg"') + .expect('ETag', 'W/"3e7-qPnkJ3CVdVhFJQvUBfF10TmVA7g"') .expect(200, done); }) @@ -201,7 +201,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"3e7-VYgCBglFKiDVAcpzPNt4Sg"') + .expect('ETag', 'W/"3e7-qPnkJ3CVdVhFJQvUBfF10TmVA7g"') .expect(200, done); }) @@ -355,7 +355,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"c-ZUfd0NJ26qwjlKF4r8qb2g"') + .expect('ETag', 'W/"c-IgR/L5SF7CJQff4wxKGF/vfPuZ0"') .expect(200, done); }); @@ -371,7 +371,7 @@ describe('res', function(){ request(app) [method]('/') - .expect('ETag', 'W/"c-ZUfd0NJ26qwjlKF4r8qb2g"') + .expect('ETag', 'W/"c-IgR/L5SF7CJQff4wxKGF/vfPuZ0"') .expect(200, done); }) }); @@ -387,7 +387,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"0-1B2M2Y8AsgTpgAmY7PhCfg"') + .expect('ETag', 'W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"') .expect(200, done); }) @@ -403,7 +403,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"3e7-VYgCBglFKiDVAcpzPNt4Sg"') + .expect('ETag', 'W/"3e7-qPnkJ3CVdVhFJQvUBfF10TmVA7g"') .expect(200, done); }); @@ -485,7 +485,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', '"d-Otu60XkfuuPskIiUxJY4cA"') + .expect('ETag', '"d-HwnTDHB9U/PRbFMN1z1wps51lqk"') .expect(200, done); }) }) @@ -502,7 +502,7 @@ describe('res', function(){ request(app) .get('/') - .expect('ETag', 'W/"d-Otu60XkfuuPskIiUxJY4cA"') + .expect('ETag', 'W/"d-HwnTDHB9U/PRbFMN1z1wps51lqk"') .expect(200, done) }) }) diff --git a/test/utils.js b/test/utils.js index b6731962601..c49019fe126 100644 --- a/test/utils.js +++ b/test/utils.js @@ -5,23 +5,23 @@ var utils = require('../lib/utils'); describe('utils.etag(body, encoding)', function(){ it('should support strings', function(){ utils.etag('express!') - .should.eql('"8-zZdv4imtWD49AHEviejT6A"') + .should.eql('"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"') }) it('should support utf8 strings', function(){ utils.etag('express❤', 'utf8') - .should.eql('"a-fsFba4IxwQS6h6Umb+FNxw"') + .should.eql('"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"') }) it('should support buffer', function(){ var buf = new Buffer('express!') utils.etag(buf) - .should.eql('"8-zZdv4imtWD49AHEviejT6A"'); + .should.eql('"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"') }) it('should support empty string', function(){ utils.etag('') - .should.eql('"0-1B2M2Y8AsgTpgAmY7PhCfg"'); + .should.eql('"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"') }) }) @@ -50,23 +50,23 @@ describe('utils.setCharset(type, charset)', function () { describe('utils.wetag(body, encoding)', function(){ it('should support strings', function(){ utils.wetag('express!') - .should.eql('W/"8-zZdv4imtWD49AHEviejT6A"') + .should.eql('W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"') }) it('should support utf8 strings', function(){ utils.wetag('express❤', 'utf8') - .should.eql('W/"a-fsFba4IxwQS6h6Umb+FNxw"') + .should.eql('W/"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"') }) it('should support buffer', function(){ var buf = new Buffer('express!') utils.wetag(buf) - .should.eql('W/"8-zZdv4imtWD49AHEviejT6A"'); + .should.eql('W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"') }) it('should support empty string', function(){ utils.wetag('') - .should.eql('W/"0-1B2M2Y8AsgTpgAmY7PhCfg"'); + .should.eql('W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"') }) }) From cd7d241a5d07eb8fa3df025e96759ee15800e661 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 20 Feb 2017 21:29:19 -0500 Subject: [PATCH 1024/1265] build: test against Node.js 8.x nightly --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index c8220d9b83a..e6139739cc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,13 @@ node_js: - "5.12" - "6.9" - "7.5" +matrix: + include: + - node_js: "8.0" + env: "NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly" + allow_failures: + # Allow the nightly installs to fail + - env: "NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly" sudo: false cache: directories: From f87abb34934c21926f0315162159e4acf7d7dae8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 20 Feb 2017 21:39:22 -0500 Subject: [PATCH 1025/1265] Remove usage of res._headers private field closes #3174 --- History.md | 2 ++ lib/request.js | 10 +++++++--- test/req.fresh.js | 2 +- test/req.stale.js | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index c63b9a45b60..755ba7456c4 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * Add debug message when loading view engine + * Remove usage of `res._headers` private field + - Improves compatibility with Node.js 8 nightly * deps: debug@2.6.1 - Allow colors in workers - Deprecated `DEBUG_FD` environment variable set to `3` or higher diff --git a/lib/request.js b/lib/request.js index 78945e5da7a..fdebbcdbe18 100644 --- a/lib/request.js +++ b/lib/request.js @@ -452,14 +452,18 @@ defineGetter(req, 'host', deprecate.function(function host(){ defineGetter(req, 'fresh', function(){ var method = this.method; - var s = this.res.statusCode; + var res = this.res + var status = res.statusCode // GET or HEAD for weak freshness validation only if ('GET' !== method && 'HEAD' !== method) return false; // 2xx or 304 as per rfc2616 14.26 - if ((s >= 200 && s < 300) || 304 === s) { - return fresh(this.headers, (this.res._headers || {})); + if ((status >= 200 && status < 300) || 304 === status) { + return fresh(this.headers, { + 'etag': res.get('ETag'), + 'last-modified': res.get('Last-Modified') + }) } return false; diff --git a/test/req.fresh.js b/test/req.fresh.js index 0f1aa982ad2..1aa8fa5b217 100644 --- a/test/req.fresh.js +++ b/test/req.fresh.js @@ -36,8 +36,8 @@ describe('req', function(){ it('should return false without response headers', function(done){ var app = express(); + app.disable('x-powered-by') app.use(function(req, res){ - res._headers = null; res.send(req.fresh); }); diff --git a/test/req.stale.js b/test/req.stale.js index c92c5a9fb8d..30c9d05d51c 100644 --- a/test/req.stale.js +++ b/test/req.stale.js @@ -36,8 +36,8 @@ describe('req', function(){ it('should return true without response headers', function(done){ var app = express(); + app.disable('x-powered-by') app.use(function(req, res){ - res._headers = null; res.send(req.stale); }); From a9f15aaefc396b487f18d583b1a3c39ee53e1db6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Feb 2017 02:11:06 -0500 Subject: [PATCH 1026/1265] deps: fresh@0.5.0 --- History.md | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 755ba7456c4..7e90ca96f93 100644 --- a/History.md +++ b/History.md @@ -20,6 +20,18 @@ unreleased - Send complete HTML document - Set `Content-Security-Policy: default-src 'self'` header - deps: debug@2.6.1 + * deps: fresh@0.5.0 + - Fix false detection of `no-cache` request directive + - Fix incorrect result when `If-None-Match` has both `*` and ETags + - Fix weak `ETag` matching to match spec + - perf: delay reading header values until needed + - perf: enable strict mode + - perf: hoist regular expressions + - perf: remove duplicate conditional + - perf: remove unnecessary boolean coercions + - perf: skip checking modified time if ETag check failed + - perf: skip parsing `If-None-Match` when no `ETag` header + - perf: use `Date.parse` instead of `new Date` * deps: qs@6.3.1 - Fix array parsing from skipping empty values - Fix compacting nested arrays diff --git a/package.json b/package.json index b313d14d67d..417df65d53a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "escape-html": "~1.0.3", "etag": "~1.8.0", "finalhandler": "~1.0.0", - "fresh": "0.3.0", + "fresh": "0.5.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "~2.3.0", From 034165caeb558560c19a0b3105d913c11999cdd0 Mon Sep 17 00:00:00 2001 From: Wes Date: Mon, 20 Feb 2017 15:32:33 -0600 Subject: [PATCH 1027/1265] Use statuses instead of http module for status messages closes #3215 --- History.md | 1 + lib/response.js | 10 +++++----- package.json | 1 + test/res.redirect.js | 9 ++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/History.md b/History.md index 7e90ca96f93..a74b4c058b7 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * Add debug message when loading view engine * Remove usage of `res._headers` private field - Improves compatibility with Node.js 8 nightly + * Use `statuses` instead of `http` module for status messages * deps: debug@2.6.1 - Allow colors in workers - Deprecated `DEBUG_FD` environment variable set to `3` or higher diff --git a/lib/response.js b/lib/response.js index 6128f450a94..42bc196dfae 100644 --- a/lib/response.js +++ b/lib/response.js @@ -20,12 +20,12 @@ var http = require('http'); var isAbsolute = require('./utils').isAbsolute; var onFinished = require('on-finished'); var path = require('path'); +var statuses = require('statuses') var merge = require('utils-merge'); var sign = require('cookie-signature').sign; var normalizeType = require('./utils').normalizeType; var normalizeTypes = require('./utils').normalizeTypes; var setCharset = require('./utils').setCharset; -var statusCodes = http.STATUS_CODES; var cookie = require('cookie'); var send = require('send'); var extname = path.extname; @@ -129,7 +129,7 @@ res.send = function send(body) { deprecate('res.send(status): Use res.sendStatus(status) instead'); this.statusCode = chunk; - chunk = statusCodes[chunk]; + chunk = statuses[chunk] } switch (typeof chunk) { @@ -334,7 +334,7 @@ res.jsonp = function jsonp(obj) { */ res.sendStatus = function sendStatus(statusCode) { - var body = statusCodes[statusCode] || String(statusCode); + var body = statuses[statusCode] || String(statusCode) this.statusCode = statusCode; this.type('txt'); @@ -876,12 +876,12 @@ res.redirect = function redirect(url) { // Support text/{plain,html} by default this.format({ text: function(){ - body = statusCodes[status] + '. Redirecting to ' + address; + body = statuses[status] + '. Redirecting to ' + address }, html: function(){ var u = escapeHtml(address); - body = '

' + statusCodes[status] + '. Redirecting to ' + u + '

'; + body = '

' + statuses[status] + '. Redirecting to ' + u + '

' }, default: function(){ diff --git a/package.json b/package.json index 417df65d53a..36d83cb9660 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "range-parser": "~1.2.0", "send": "0.14.2", "serve-static": "~1.11.2", + "statuses": "~1.3.1", "type-is": "~1.6.14", "utils-merge": "1.0.0", "vary": "~1.1.0" diff --git a/test/res.redirect.js b/test/res.redirect.js index 9f3bd436763..755bb1c1c6c 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -1,5 +1,4 @@ -var http = require('http'); var express = require('..'); var request = require('supertest'); var utils = require('./support/utils'); @@ -104,7 +103,7 @@ describe('res', function(){ .set('Accept', 'text/html') .expect('Content-Type', /html/) .expect('Location', 'http://google.com') - .expect(302, '

' + http.STATUS_CODES[302] + '. Redirecting to http://google.com

', done); + .expect(302, '

Found. Redirecting to http://google.com

', done) }) it('should escape the url', function(done){ @@ -120,7 +119,7 @@ describe('res', function(){ .set('Accept', 'text/html') .expect('Content-Type', /html/) .expect('Location', '%3Cla\'me%3E') - .expect(302, '

' + http.STATUS_CODES[302] + '. Redirecting to %3Cla'me%3E

', done) + .expect(302, '

Found. Redirecting to %3Cla'me%3E

', done) }) it('should include the redirect type', function(done){ @@ -152,7 +151,7 @@ describe('res', function(){ .set('Accept', 'text/plain, */*') .expect('Content-Type', /plain/) .expect('Location', 'http://google.com') - .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://google.com', done); + .expect(302, 'Found. Redirecting to http://google.com', done) }) it('should encode the url', function(done){ @@ -168,7 +167,7 @@ describe('res', function(){ .set('Accept', 'text/plain, */*') .expect('Content-Type', /plain/) .expect('Location', 'http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E') - .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E', done) + .expect(302, 'Found. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E', done) }) it('should include the redirect type', function(done){ From 8de1230d039f4391a8c7227e8ce702f280b72e33 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Feb 2017 23:03:20 -0500 Subject: [PATCH 1028/1265] lint: remove unreachable code --- lib/router/index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/router/index.js b/lib/router/index.js index dac2514815b..29183d561e1 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -351,11 +351,6 @@ proto.process_params = function process_params(layer, called, req, res, done) { paramIndex = 0; key = keys[i++]; - - if (!key) { - return done(); - } - name = key.name; paramVal = req.params[name]; paramCallbacks = params[name]; From 7bc5f1af968175ddb492cc436a37fc53a8026175 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Feb 2017 23:09:36 -0500 Subject: [PATCH 1029/1265] lint: consolidate layer match failure path --- lib/router/layer.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/router/layer.js b/lib/router/layer.js index fe9210cb9de..e2afb9723db 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -108,23 +108,21 @@ Layer.prototype.handle_request = function handle(req, res, next) { */ Layer.prototype.match = function match(path) { - if (path == null) { - // no path, nothing matches - this.params = undefined; - this.path = undefined; - return false; - } + var match + + if (path != null) { + if (this.regexp.fast_slash) { + // fast path non-ending match for / (everything matches) + this.params = {} + this.path = '' + return true + } - if (this.regexp.fast_slash) { - // fast path non-ending match for / (everything matches) - this.params = {}; - this.path = ''; - return true; + // match the path + match = this.regexp.exec(path) } - var m = this.regexp.exec(path); - - if (!m) { + if (!match) { this.params = undefined; this.path = undefined; return false; @@ -132,15 +130,15 @@ Layer.prototype.match = function match(path) { // store values this.params = {}; - this.path = m[0]; + this.path = match[0] var keys = this.keys; var params = this.params; - for (var i = 1; i < m.length; i++) { + for (var i = 1; i < match.length; i++) { var key = keys[i - 1]; var prop = key.name; - var val = decode_param(m[i]); + var val = decode_param(match[i]) if (val !== undefined || !(hasOwnProperty.call(params, prop))) { params[prop] = val; From 668f545fd4f69cb27dccc6c2d7a21c1637e84933 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Feb 2017 23:42:57 -0500 Subject: [PATCH 1030/1265] Skip routing when req.url is not set --- History.md | 1 + lib/router/index.js | 24 +++++++++++++++++++----- test/Router.js | 10 ++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index a74b4c058b7..f218fb578b3 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ unreleased * Add debug message when loading view engine * Remove usage of `res._headers` private field - Improves compatibility with Node.js 8 nightly + * Skip routing when `req.url` is not set * Use `statuses` instead of `http` module for status messages * deps: debug@2.6.1 - Allow colors in workers diff --git a/lib/router/index.js b/lib/router/index.js index 29183d561e1..83ad8b500f4 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -137,11 +137,8 @@ proto.handle = function handle(req, res, out) { debug('dispatching %s %s', req.method, req.url); - var search = 1 + req.url.indexOf('?'); - var pathlength = search ? search - 1 : req.url.length; - var fqdn = req.url[0] !== '/' && 1 + req.url.substr(0, pathlength).indexOf('://'); - var protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : ''; var idx = 0; + var protohost = getProtohost(req.url) || '' var removed = ''; var slashAdded = false; var paramcalled = {}; @@ -293,7 +290,7 @@ proto.handle = function handle(req, res, out) { req.url = protohost + req.url.substr(protohost.length + removed.length); // Ensure leading slash - if (!fqdn && req.url[0] !== '/') { + if (!protohost && req.url[0] !== '/') { req.url = '/' + req.url; slashAdded = true; } @@ -526,6 +523,23 @@ function getPathname(req) { } } +// Get get protocol + host for a URL +function getProtohost(url) { + if (typeof url !== 'string' || url.length === 0 || url[0] === '/') { + return undefined + } + + var searchIndex = url.indexOf('?') + var pathLength = searchIndex !== -1 + ? searchIndex + : url.length + var fqdnIndex = url.substr(0, pathLength).indexOf('://') + + return fqdnIndex !== -1 + ? url.substr(0, url.indexOf('/', 3 + fqdnIndex)) + : undefined +} + // get type for error message function gettype(obj) { var type = typeof obj; diff --git a/test/Router.js b/test/Router.js index 21cdff2c6c0..41cd149e8eb 100644 --- a/test/Router.js +++ b/test/Router.js @@ -53,6 +53,16 @@ describe('Router', function(){ router.handle({ url: '', method: 'GET' }, {}, done); }); + it('should handle missing URL', function (done) { + var router = new Router() + + router.use(function (req, res) { + throw new Error('should not be called') + }) + + router.handle({ method: 'GET' }, {}, done) + }) + it('should not stack overflow with many registered routes', function(done){ var handler = function(req, res){ res.end(new Error('wrong handler')) }; var router = new Router(); From 12ff56e1e44eb0126d777205b53c31c247ee9293 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Feb 2017 01:52:49 -0500 Subject: [PATCH 1031/1265] Use Object.create to setup request & response prototypes --- History.md | 1 + lib/express.js | 12 ++++++++++-- lib/request.js | 12 +++++++++--- lib/response.js | 12 +++++++++--- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/History.md b/History.md index f218fb578b3..be606575bef 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased * Remove usage of `res._headers` private field - Improves compatibility with Node.js 8 nightly * Skip routing when `req.url` is not set + * Use `Object.create` to setup request & response prototypes * Use `statuses` instead of `http` module for status messages * deps: debug@2.6.1 - Allow colors in workers diff --git a/lib/express.js b/lib/express.js index 540c8be6f41..187e4e2d7ca 100644 --- a/lib/express.js +++ b/lib/express.js @@ -41,8 +41,16 @@ function createApplication() { mixin(app, EventEmitter.prototype, false); mixin(app, proto, false); - app.request = { __proto__: req, app: app }; - app.response = { __proto__: res, app: app }; + // expose the prototype that will get set on requests + app.request = Object.create(req, { + app: { configurable: true, enumerable: true, writable: true, value: app } + }) + + // expose the prototype that will get set on responses + app.response = Object.create(res, { + app: { configurable: true, enumerable: true, writable: true, value: app } + }) + app.init(); return app; } diff --git a/lib/request.js b/lib/request.js index fdebbcdbe18..3432e6776fe 100644 --- a/lib/request.js +++ b/lib/request.js @@ -25,11 +25,17 @@ var proxyaddr = require('proxy-addr'); /** * Request prototype. + * @public */ -var req = exports = module.exports = { - __proto__: http.IncomingMessage.prototype -}; +var req = Object.create(http.IncomingMessage.prototype) + +/** + * Module exports. + * @public + */ + +module.exports = req /** * Return request header. diff --git a/lib/response.js b/lib/response.js index 42bc196dfae..6aefe1b1782 100644 --- a/lib/response.js +++ b/lib/response.js @@ -35,11 +35,17 @@ var vary = require('vary'); /** * Response prototype. + * @public */ -var res = module.exports = { - __proto__: http.ServerResponse.prototype -}; +var res = Object.create(http.ServerResponse.prototype) + +/** + * Module exports. + * @public + */ + +module.exports = res /** * Module variables. From 6022567c754a8f1d0b117168b67324da7200fa3c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 23 Feb 2017 01:56:58 -0500 Subject: [PATCH 1032/1265] Use setprototypeof module to replace __proto__ setting closes #1967 closes #2613 closes #3103 closes #3164 --- History.md | 1 + lib/application.js | 13 +++++++------ lib/middleware/init.js | 11 +++++++++-- lib/router/index.js | 3 ++- package.json | 1 + 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/History.md b/History.md index be606575bef..5e12afa9957 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,7 @@ unreleased - Improves compatibility with Node.js 8 nightly * Skip routing when `req.url` is not set * Use `Object.create` to setup request & response prototypes + * Use `setprototypeof` module to replace `__proto__` setting * Use `statuses` instead of `http` module for status messages * deps: debug@2.6.1 - Allow colors in workers diff --git a/lib/application.js b/lib/application.js index 0ee4def3890..0fe0eb44023 100644 --- a/lib/application.js +++ b/lib/application.js @@ -28,6 +28,7 @@ var deprecate = require('depd')('express'); var flatten = require('array-flatten'); var merge = require('utils-merge'); var resolve = require('path').resolve; +var setPrototyeOf = require('setprototypeof') var slice = Array.prototype.slice; /** @@ -94,10 +95,10 @@ app.defaultConfiguration = function defaultConfiguration() { } // inherit protos - this.request.__proto__ = parent.request; - this.response.__proto__ = parent.response; - this.engines.__proto__ = parent.engines; - this.settings.__proto__ = parent.settings; + setPrototyeOf(this.request, parent.request) + setPrototyeOf(this.response, parent.response) + setPrototyeOf(this.engines, parent.engines) + setPrototyeOf(this.settings, parent.settings) }); // setup locals @@ -227,8 +228,8 @@ app.use = function use(fn) { router.use(path, function mounted_app(req, res, next) { var orig = req.app; fn.handle(req, res, function (err) { - req.__proto__ = orig.request; - res.__proto__ = orig.response; + setPrototyeOf(req, orig.request) + setPrototyeOf(res, orig.response) next(err); }); }); diff --git a/lib/middleware/init.js b/lib/middleware/init.js index f3119ed3a15..328c4a863d9 100644 --- a/lib/middleware/init.js +++ b/lib/middleware/init.js @@ -8,6 +8,13 @@ 'use strict'; +/** + * Module dependencies. + * @private + */ + +var setPrototyeOf = require('setprototypeof') + /** * Initialization middleware, exposing the * request and response to each other, as well @@ -25,8 +32,8 @@ exports.init = function(app){ res.req = req; req.next = next; - req.__proto__ = app.request; - res.__proto__ = app.response; + setPrototyeOf(req, app.request) + setPrototyeOf(res, app.response) res.locals = res.locals || Object.create(null); diff --git a/lib/router/index.js b/lib/router/index.js index 83ad8b500f4..2c4239eba18 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -21,6 +21,7 @@ var debug = require('debug')('express:router'); var deprecate = require('depd')('express'); var flatten = require('array-flatten'); var parseUrl = require('parseurl'); +var setPrototypeOf = require('setprototypeof') /** * Module variables. @@ -47,7 +48,7 @@ var proto = module.exports = function(options) { } // mixin Router class functions - router.__proto__ = proto; + setPrototypeOf(router, proto) router.params = {}; router._params = []; diff --git a/package.json b/package.json index 36d83cb9660..daa1580b2ff 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "range-parser": "~1.2.0", "send": "0.14.2", "serve-static": "~1.11.2", + "setprototypeof": "1.0.3", "statuses": "~1.3.1", "type-is": "~1.6.14", "utils-merge": "1.0.0", From 1b43166fcafceedf50d588abf09224d33cc93507 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 25 Feb 2017 17:53:34 -0500 Subject: [PATCH 1033/1265] deps: send@0.15.0 --- History.md | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5e12afa9957..67f353843f2 100644 --- a/History.md +++ b/History.md @@ -39,6 +39,18 @@ unreleased * deps: qs@6.3.1 - Fix array parsing from skipping empty values - Fix compacting nested arrays + * deps: send@0.15.0 + - Fix false detection of `no-cache` request directive + - Fix incorrect result when `If-None-Match` has both `*` and ETags + - Fix weak `ETag` matching to match spec + - Remove usage of `res._headers` private field + - Support `If-Match` and `If-Unmodified-Since` headers + - Use `res.getHeaderNames()` when available + - Use `res.headersSent` when available + - deps: debug@2.6.1 + - deps: etag@~1.8.0 + - deps: fresh@0.5.0 + - deps: http-errors@~1.6.1 * perf: improve `req.ips` performance 4.14.1 / 2017-01-28 diff --git a/package.json b/package.json index daa1580b2ff..9bc995e3205 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "proxy-addr": "~1.1.3", "qs": "6.3.1", "range-parser": "~1.2.0", - "send": "0.14.2", + "send": "0.15.0", "serve-static": "~1.11.2", "setprototypeof": "1.0.3", "statuses": "~1.3.1", From acc4a619d93c86b526af9d850407464f8e404b8f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 25 Feb 2017 19:31:39 -0500 Subject: [PATCH 1034/1265] deps: serve-static@1.12.0 --- History.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 67f353843f2..14103f267f8 100644 --- a/History.md +++ b/History.md @@ -51,6 +51,17 @@ unreleased - deps: etag@~1.8.0 - deps: fresh@0.5.0 - deps: http-errors@~1.6.1 + * deps: serve-static@1.12.0 + - Fix false detection of `no-cache` request directive + - Fix incorrect result when `If-None-Match` has both `*` and ETags + - Fix weak `ETag` matching to match spec + - Remove usage of `res._headers` private field + - Send complete HTML document in redirect response + - Set default CSP header in redirect response + - Support `If-Match` and `If-Unmodified-Since` headers + - Use `res.getHeaderNames()` when available + - Use `res.headersSent` when available + - deps: send@0.15.0 * perf: improve `req.ips` performance 4.14.1 / 2017-01-28 diff --git a/package.json b/package.json index 9bc995e3205..79b3b0e31c5 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "qs": "6.3.1", "range-parser": "~1.2.0", "send": "0.15.0", - "serve-static": "~1.11.2", + "serve-static": "1.12.0", "setprototypeof": "1.0.3", "statuses": "~1.3.1", "type-is": "~1.6.14", From 1f71fae23be00f44bdfef212cc16868dd8cd5954 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 26 Feb 2017 13:21:18 -0500 Subject: [PATCH 1035/1265] tests: add lone "*" route tests --- test/app.router.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/app.router.js b/test/app.router.js index 301f9b86af0..1bba62e270f 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -563,6 +563,30 @@ describe('app.router', function(){ }) describe('*', function(){ + it('should capture everything', function (done) { + var app = express() + + app.get('*', function (req, res) { + res.end(req.params[0]) + }) + + request(app) + .get('/user/tobi.json') + .expect('/user/tobi.json', done) + }) + + it('should decore the capture', function (done) { + var app = express() + + app.get('*', function (req, res) { + res.end(req.params[0]) + }) + + request(app) + .get('/user/tobi%20and%20loki.json') + .expect('/user/tobi and loki.json', done) + }) + it('should denote a greedy capture group', function(done){ var app = express(); From 081b811b100a54e26e46aec64e0effd12cdd5053 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 26 Feb 2017 13:32:21 -0500 Subject: [PATCH 1036/1265] perf: add fast match path for "*" route --- History.md | 1 + lib/router/layer.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 14103f267f8..2b20beb7177 100644 --- a/History.md +++ b/History.md @@ -62,6 +62,7 @@ unreleased - Use `res.getHeaderNames()` when available - Use `res.headersSent` when available - deps: send@0.15.0 + * perf: add fast match path for `*` route * perf: improve `req.ips` performance 4.14.1 / 2017-01-28 diff --git a/lib/router/layer.js b/lib/router/layer.js index e2afb9723db..6325df8aff9 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -44,9 +44,9 @@ function Layer(path, options, fn) { this.path = undefined; this.regexp = pathRegexp(path, this.keys = [], opts); - if (path === '/' && opts.end === false) { - this.regexp.fast_slash = true; - } + // set fast path flags + this.regexp.fast_star = path === '*' + this.regexp.fast_slash = path === '/' && opts.end === false } /** @@ -111,13 +111,20 @@ Layer.prototype.match = function match(path) { var match if (path != null) { + // fast path non-ending match for / (any path matches) if (this.regexp.fast_slash) { - // fast path non-ending match for / (everything matches) this.params = {} this.path = '' return true } + // fast path for * (everything matched in a param) + if (this.regexp.fast_star) { + this.params = {'0': decode_param(path)} + this.path = path + return true + } + // match the path match = this.regexp.exec(path) } From 8b6dc6ceec1b36e74ee9c6d362aa04e46237c227 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 26 Feb 2017 13:45:35 -0500 Subject: [PATCH 1037/1265] Use "%o" in path debug to tell types apart --- History.md | 1 + lib/router/index.js | 2 +- lib/router/layer.js | 2 +- lib/router/route.js | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 2b20beb7177..ed51a7e5b0a 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased * Remove usage of `res._headers` private field - Improves compatibility with Node.js 8 nightly * Skip routing when `req.url` is not set + * Use `%o` in path debug to tell types apart * Use `Object.create` to setup request & response prototypes * Use `setprototypeof` module to replace `__proto__` setting * Use `statuses` instead of `http` module for status messages diff --git a/lib/router/index.js b/lib/router/index.js index 2c4239eba18..d2ed86e0bc8 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -452,7 +452,7 @@ proto.use = function use(fn) { } // add the middleware - debug('use %s %s', path, fn.name || ''); + debug('use %o %s', path, fn.name || '') var layer = new Layer(path, { sensitive: this.caseSensitive, diff --git a/lib/router/layer.js b/lib/router/layer.js index 6325df8aff9..4dc8e86d4f7 100644 --- a/lib/router/layer.js +++ b/lib/router/layer.js @@ -35,7 +35,7 @@ function Layer(path, options, fn) { return new Layer(path, options, fn); } - debug('new %s', path); + debug('new %o', path) var opts = options || {}; this.handle = fn; diff --git a/lib/router/route.js b/lib/router/route.js index 2788d7b7353..1ec9d50ea0e 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -44,7 +44,7 @@ function Route(path) { this.path = path; this.stack = []; - debug('new %s', path); + debug('new %o', path) // route handlers for various http methods this.methods = {}; @@ -196,7 +196,7 @@ methods.forEach(function(method){ throw new Error(msg); } - debug('%s %s', method, this.path); + debug('%s %o', method, this.path) var layer = Layer('/', {}, handle); layer.method = method; From 51f52901eb1f00571e18d404e10b27310215234c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 26 Feb 2017 13:59:47 -0500 Subject: [PATCH 1038/1265] Fix case where router.use skipped requests routes did not fixes #3037 --- History.md | 1 + lib/router/index.js | 11 ++++++----- test/Router.js | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index ed51a7e5b0a..bf7764011ba 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Add debug message when loading view engine + * Fix case where `router.use` skipped requests routes did not * Remove usage of `res._headers` private field - Improves compatibility with Node.js 8 nightly * Skip routing when `req.url` is not set diff --git a/lib/router/index.js b/lib/router/index.js index d2ed86e0bc8..917c6002c8b 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -280,12 +280,13 @@ proto.handle = function handle(req, res, out) { } function trim_prefix(layer, layerError, layerPath, path) { - var c = path[layerPath.length]; - if (c && '/' !== c && '.' !== c) return next(layerError); - - // Trim off the part of the url that matches the route - // middleware (.use stuff) needs to have the path stripped if (layerPath.length !== 0) { + // Validate path breaks on a path separator + var c = path[layerPath.length] + if (c && c !== '/' && c !== '.') return next(layerError) + + // Trim off the part of the url that matches the route + // middleware (.use stuff) needs to have the path stripped debug('trim prefix (%s) from url %s', layerPath, req.url); removed = layerPath; req.url = protohost + req.url.substr(protohost.length + removed.length); diff --git a/test/Router.js b/test/Router.js index 41cd149e8eb..01a6e2c472b 100644 --- a/test/Router.js +++ b/test/Router.js @@ -347,6 +347,24 @@ describe('Router', function(){ assert.equal(count, methods.length); done(); }) + + it('should be called for any URL when "*"', function (done) { + var cb = after(4, done) + var router = new Router() + + function no () { + throw new Error('should not be called') + } + + router.all('*', function (req, res) { + res.end() + }) + + router.handle({ url: '/', method: 'GET' }, { end: cb }, no) + router.handle({ url: '/foo', method: 'GET' }, { end: cb }, no) + router.handle({ url: 'foo', method: 'GET' }, { end: cb }, no) + router.handle({ url: '*', method: 'GET' }, { end: cb }, no) + }) }) describe('.use', function() { @@ -363,6 +381,24 @@ describe('Router', function(){ router.use.bind(router, '/', new Date()).should.throw(/requires middleware function.*Date/) }) + it('should be called for any URL', function (done) { + var cb = after(4, done) + var router = new Router() + + function no () { + throw new Error('should not be called') + } + + router.use(function (req, res) { + res.end() + }) + + router.handle({ url: '/', method: 'GET' }, { end: cb }, no) + router.handle({ url: '/foo', method: 'GET' }, { end: cb }, no) + router.handle({ url: 'foo', method: 'GET' }, { end: cb }, no) + router.handle({ url: '*', method: 'GET' }, { end: cb }, no) + }) + it('should accept array of middleware', function(done){ var count = 0; var router = new Router(); From 9722202df964bfbfc0f579e4baeb5a4e1b43b344 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Thu, 12 Nov 2015 16:17:47 -0800 Subject: [PATCH 1039/1265] Add next("router") to exit from router closes #2241 closes #2371 --- History.md | 1 + lib/router/index.js | 6 ++++++ lib/router/route.js | 6 ++++++ test/app.router.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/History.md b/History.md index bf7764011ba..824f2443d3e 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Add debug message when loading view engine + * Add `next("router")` to exit from router * Fix case where `router.use` skipped requests routes did not * Remove usage of `res._headers` private field - Improves compatibility with Node.js 8 nightly diff --git a/lib/router/index.js b/lib/router/index.js index 917c6002c8b..1f426068d7e 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -191,6 +191,12 @@ proto.handle = function handle(req, res, out) { removed = ''; } + // signal to exit router + if (layerError === 'router') { + setImmediate(done, null) + return + } + // no more matching layers if (idx >= stack.length) { setImmediate(done, layerError); diff --git a/lib/router/route.js b/lib/router/route.js index 1ec9d50ea0e..ea82ed29df5 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -112,10 +112,16 @@ Route.prototype.dispatch = function dispatch(req, res, done) { next(); function next(err) { + // signal to exit route if (err && err === 'route') { return done(); } + // signal to exit router + if (err && err === 'router') { + return done(err) + } + var layer = stack[idx++]; if (!layer) { return done(err); diff --git a/test/app.router.js b/test/app.router.js index 1bba62e270f..e838b2e33fc 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -932,6 +932,37 @@ describe('app.router', function(){ }) }) + describe('when next("router") is called', function () { + it('should jump out of router', function (done) { + var app = express() + var router = express.Router() + + function fn (req, res, next) { + res.set('X-Hit', '1') + next('router') + } + + router.get('/foo', fn, function (req, res, next) { + res.end('failure') + }) + + router.get('/foo', function (req, res, next) { + res.end('failure') + }) + + app.use(router) + + app.get('/foo', function (req, res) { + res.end('success') + }) + + request(app) + .get('/foo') + .expect('X-Hit', '1') + .expect(200, 'success', done) + }) + }) + describe('when next(err) is called', function(){ it('should break out of app.router', function(done){ var app = express() From 146a13ede7c81d0131468e99b29d06940727bfea Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2017 17:15:57 -0500 Subject: [PATCH 1040/1265] build: Node.js@4.8 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e6139739cc4..bb466557163 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: - "1.8" - "2.5" - "3.3" - - "4.7" + - "4.8" - "5.12" - "6.9" - "7.5" diff --git a/appveyor.yml b/appveyor.yml index 4717f2735a8..659dbd1d3f7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ environment: - nodejs_version: "1.8" - nodejs_version: "2.5" - nodejs_version: "3.3" - - nodejs_version: "4.7" + - nodejs_version: "4.8" - nodejs_version: "5.12" - nodejs_version: "6.9" - nodejs_version: "7.5" From 72475543bcf61868e32ba2f4053cf42707a4b55d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2017 17:16:09 -0500 Subject: [PATCH 1041/1265] build: Node.js@6.10 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb466557163..0c4df4972da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ node_js: - "3.3" - "4.8" - "5.12" - - "6.9" + - "6.10" - "7.5" matrix: include: diff --git a/appveyor.yml b/appveyor.yml index 659dbd1d3f7..4645573fcd7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ environment: - nodejs_version: "3.3" - nodejs_version: "4.8" - nodejs_version: "5.12" - - nodejs_version: "6.9" + - nodejs_version: "6.10" - nodejs_version: "7.5" cache: - node_modules From f59de6ae3d0c142a95e4f47dedf9770efe198ae6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2017 17:16:21 -0500 Subject: [PATCH 1042/1265] build: Node.js@7.7 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c4df4972da..824e6b2a17a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ node_js: - "4.8" - "5.12" - "6.10" - - "7.5" + - "7.7" matrix: include: - node_js: "8.0" diff --git a/appveyor.yml b/appveyor.yml index 4645573fcd7..1b399ce4ab0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ environment: - nodejs_version: "4.8" - nodejs_version: "5.12" - nodejs_version: "6.10" - - nodejs_version: "7.5" + - nodejs_version: "7.7" cache: - node_modules install: From 7f96896f67ba14e5a2f5be4fc5496584ce682b24 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2017 17:17:50 -0500 Subject: [PATCH 1043/1265] deps: update example dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79b3b0e31c5..cca0f7f4533 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ }, "devDependencies": { "after": "0.8.2", - "body-parser": "1.16.1", + "body-parser": "1.17.0", "cookie-parser": "~1.4.3", "ejs": "2.5.6", "express-session": "1.15.1", From 504a51c040f22c80c7e52377c0ef00b1c8b2a76b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2017 17:22:18 -0500 Subject: [PATCH 1044/1265] 4.15.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 824f2443d3e..24f0c2e41f7 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.15.0 / 2017-03-01 +=================== * Add debug message when loading view engine * Add `next("router")` to exit from router diff --git a/package.json b/package.json index cca0f7f4533..cc6f36633fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.14.1", + "version": "4.15.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 6d9b1279899cbc1fbaa2b98a2ab118a2c3081778 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2017 17:44:13 -0500 Subject: [PATCH 1045/1265] build: Node.js@7.6 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 824e6b2a17a..1230c7e2f95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ node_js: - "4.8" - "5.12" - "6.10" - - "7.7" + - "7.6" matrix: include: - node_js: "8.0" diff --git a/appveyor.yml b/appveyor.yml index 1b399ce4ab0..b4bb184dd8f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ environment: - nodejs_version: "4.8" - nodejs_version: "5.12" - nodejs_version: "6.10" - - nodejs_version: "7.7" + - nodejs_version: "7.6" cache: - node_modules install: From 4012846d2534addd8de0b0c237cd63ada104109a Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Sun, 26 Feb 2017 13:38:26 +0000 Subject: [PATCH 1046/1265] examples: use static assets in search example closes #3224 --- examples/search/index.js | 11 +---------- examples/search/{ => public}/client.js | 0 examples/search/public/index.html | 20 ++++++++++++++++++++ examples/search/search.jade | 15 --------------- 4 files changed, 21 insertions(+), 25 deletions(-) rename examples/search/{ => public}/client.js (100%) create mode 100644 examples/search/public/index.html delete mode 100644 examples/search/search.jade diff --git a/examples/search/index.js b/examples/search/index.js index d614ac24076..8027635f19e 100644 --- a/examples/search/index.js +++ b/examples/search/index.js @@ -15,8 +15,7 @@ var db = redis.createClient(); var app = express(); -app.set('view engine', 'jade'); -app.set('views', __dirname); +app.use(express.static(__dirname + '/public')); // populate search @@ -26,14 +25,6 @@ db.sadd('ferret', 'jane'); db.sadd('cat', 'manny'); db.sadd('cat', 'luna'); -/** - * GET the search page. - */ - -app.get('/', function(req, res){ - res.render('search'); -}); - /** * GET search for :query. */ diff --git a/examples/search/client.js b/examples/search/public/client.js similarity index 100% rename from examples/search/client.js rename to examples/search/public/client.js diff --git a/examples/search/public/index.html b/examples/search/public/index.html new file mode 100644 index 00000000000..4a5540fdf3a --- /dev/null +++ b/examples/search/public/index.html @@ -0,0 +1,20 @@ + + + + + Search example + + + +

Search

+

Try searching for "ferret" or "cat".

+ +
+  
+
+
diff --git a/examples/search/search.jade b/examples/search/search.jade
deleted file mode 100644
index 37d77e434c6..00000000000
--- a/examples/search/search.jade
+++ /dev/null
@@ -1,15 +0,0 @@
-doctype
-html
-  head
-    title Search example
-    style.
-      body {
-        font: 14px "Helvetica Neue", Helvetica;
-        padding: 50px;
-      }
-  body
-    h2 Search
-    p Try searching for "ferret" or "cat".
-    input(type='search')
-    pre
-    script(src='client.js')

From b4550fbe7a154d3fb9e935935e266a9eca9a4d69 Mon Sep 17 00:00:00 2001
From: Jamie Barton 
Date: Sun, 26 Feb 2017 13:12:35 +0000
Subject: [PATCH 1047/1265] Use ejs instead of jade within engine jsdoc

closes #3222
---
 lib/application.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/application.js b/lib/application.js
index 0fe0eb44023..21a81ee9efe 100644
--- a/lib/application.js
+++ b/lib/application.js
@@ -262,9 +262,9 @@ app.route = function route(path) {
  *
  * By default will `require()` the engine based on the
  * file extension. For example if you try to render
- * a "foo.jade" file Express will invoke the following internally:
+ * a "foo.ejs" file Express will invoke the following internally:
  *
- *     app.engine('jade', require('jade').__express);
+ *     app.engine('ejs', require('ejs').__express);
  *
  * For engines that do not provide `.__express` out of the box,
  * or if you wish to "map" a different extension to the template engine

From 7027b37764050c550366e808ea84fee1c58233ed Mon Sep 17 00:00:00 2001
From: Jianru Lin 
Date: Wed, 1 Mar 2017 10:38:13 +0800
Subject: [PATCH 1048/1265] lint: remove unused err argument

closes #3228
---
 lib/router/index.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/router/index.js b/lib/router/index.js
index 1f426068d7e..51db4c28ff9 100644
--- a/lib/router/index.js
+++ b/lib/router/index.js
@@ -626,7 +626,7 @@ function restore(fn, obj) {
     vals[i] = obj[props[i]];
   }
 
-  return function(err){
+  return function () {
     // restore vals
     for (var i = 0; i < props.length; i++) {
       obj[props[i]] = vals[i];

From dc8acc8676bed4aa4afa391ee312baa497d680e2 Mon Sep 17 00:00:00 2001
From: Douglas Christopher Wilson 
Date: Sun, 5 Mar 2017 00:04:47 -0500
Subject: [PATCH 1049/1265] tests: use supertest expect for simple assertions

---
 test/app.param.js         |  9 ++++-----
 test/app.router.js        |  4 ++--
 test/req.signedCookies.js |  6 +-----
 test/res.clearCookie.js   | 14 ++++----------
 test/res.cookie.js        | 28 ++++++++--------------------
 5 files changed, 19 insertions(+), 42 deletions(-)

diff --git a/test/app.param.js b/test/app.param.js
index 30885bcdc89..c7a375418cd 100644
--- a/test/app.param.js
+++ b/test/app.param.js
@@ -29,8 +29,8 @@ describe('app', function(){
 
       request(app)
       .get('/user/tj')
-      .end(function(err, res){
-        res.text.should.equal('tj');
+      .expect(200, 'tj', function (err) {
+        if (err) return done(err)
         request(app)
         .get('/user/123')
         .expect(404, done);
@@ -69,9 +69,8 @@ describe('app', function(){
 
       request(app)
       .get('/user/123')
-      .end(function(err, res){
-        res.text.should.equal('123');
-
+      .expect(200, '123', function (err) {
+        if (err) return done(err)
         request(app)
         .get('/post/123')
         .expect('123', done);
diff --git a/test/app.router.js b/test/app.router.js
index e838b2e33fc..95680f9139c 100644
--- a/test/app.router.js
+++ b/test/app.router.js
@@ -539,8 +539,8 @@ describe('app.router', function(){
 
     request(app)
     .get('/user/10')
-    .end(function(err, res){
-      res.statusCode.should.equal(200);
+    .expect(200, function (err) {
+      if (err) return done(err)
       request(app)
       .get('/user/tj')
       .expect(404, done);
diff --git a/test/req.signedCookies.js b/test/req.signedCookies.js
index 111a0f77df8..73880b01b4c 100644
--- a/test/req.signedCookies.js
+++ b/test/req.signedCookies.js
@@ -28,11 +28,7 @@ describe('req', function(){
         request(app)
         .get('/')
         .set('Cookie', cookie)
-        .end(function(err, res){
-          if (err) return done(err);
-          res.body.should.eql({ obj: { foo: 'bar' } });
-          done();
-        });
+        .expect(200, { obj: { foo: 'bar' } }, done)
       });
     })
   })
diff --git a/test/res.clearCookie.js b/test/res.clearCookie.js
index 92c9d049f0d..4822057e926 100644
--- a/test/res.clearCookie.js
+++ b/test/res.clearCookie.js
@@ -13,11 +13,8 @@ describe('res', function(){
 
       request(app)
       .get('/')
-      .end(function(err, res){
-        var val = 'sid=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT';
-        res.header['set-cookie'].should.eql([val]);
-        done();
-      })
+      .expect('Set-Cookie', 'sid=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
+      .expect(200, done)
     })
   })
 
@@ -31,11 +28,8 @@ describe('res', function(){
 
       request(app)
       .get('/')
-      .end(function(err, res){
-        var val = 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT';
-        res.header['set-cookie'].should.eql([val]);
-        done();
-      })
+      .expect('Set-Cookie', 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
+      .expect(200, done)
     })
   })
 })
diff --git a/test/res.cookie.js b/test/res.cookie.js
index 543af99dcdd..4eeaaf094ad 100644
--- a/test/res.cookie.js
+++ b/test/res.cookie.js
@@ -16,11 +16,8 @@ describe('res', function(){
 
       request(app)
       .get('/')
-      .end(function(err, res){
-        var val = ['user=' + encodeURIComponent('j:{"name":"tobi"}') + '; Path=/'];
-        res.headers['set-cookie'].should.eql(val);
-        done();
-      })
+      .expect('Set-Cookie', 'user=j%3A%7B%22name%22%3A%22tobi%22%7D; Path=/')
+      .expect(200, done)
     })
   })
 
@@ -34,11 +31,8 @@ describe('res', function(){
 
       request(app)
       .get('/')
-      .end(function(err, res){
-        var val = ['name=tobi; Path=/'];
-        res.headers['set-cookie'].should.eql(val);
-        done();
-      })
+      .expect('Set-Cookie', 'name=tobi; Path=/')
+      .expect(200, done)
     })
 
     it('should allow multiple calls', function(done){
@@ -72,11 +66,8 @@ describe('res', function(){
 
       request(app)
       .get('/')
-      .end(function(err, res){
-        var val = ['name=tobi; Path=/; HttpOnly; Secure'];
-        res.headers['set-cookie'].should.eql(val);
-        done();
-      })
+      .expect('Set-Cookie', 'name=tobi; Path=/; HttpOnly; Secure')
+      .expect(200, done)
     })
 
     describe('maxAge', function(){
@@ -178,11 +169,8 @@ describe('res', function(){
 
         request(app)
         .get('/')
-        .end(function(err, res){
-          var val = ['name=s%3Atobi.xJjV2iZ6EI7C8E5kzwbfA9PVLl1ZR07UTnuTgQQ4EnQ; Path=/'];
-          res.headers['set-cookie'].should.eql(val);
-          done();
-        })
+        .expect('Set-Cookie', 'name=s%3Atobi.xJjV2iZ6EI7C8E5kzwbfA9PVLl1ZR07UTnuTgQQ4EnQ; Path=/')
+        .expect(200, done)
       })
     })
   })

From c0089d971b9880b17c652bfde95cc4f36fd8aaf8 Mon Sep 17 00:00:00 2001
From: Douglas Christopher Wilson 
Date: Sun, 5 Mar 2017 00:06:59 -0500
Subject: [PATCH 1050/1265] deps: send@0.15.1

---
 History.md   | 7 +++++++
 package.json | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/History.md b/History.md
index 24f0c2e41f7..aadd7ece046 100644
--- a/History.md
+++ b/History.md
@@ -1,3 +1,10 @@
+unreleased
+==========
+
+  * deps: send@0.15.1
+    - Fix issue when `Date.parse` does not return `NaN` on invalid date
+    - Fix strict violation in broken environments
+
 4.15.0 / 2017-03-01
 ===================
 
diff --git a/package.json b/package.json
index cc6f36633fe..aea1a83bc10 100644
--- a/package.json
+++ b/package.json
@@ -48,7 +48,7 @@
     "proxy-addr": "~1.1.3",
     "qs": "6.3.1",
     "range-parser": "~1.2.0",
-    "send": "0.15.0",
+    "send": "0.15.1",
     "serve-static": "1.12.0",
     "setprototypeof": "1.0.3",
     "statuses": "~1.3.1",

From 67168fe231445a82dc1e8dde6a93ee9441be28c1 Mon Sep 17 00:00:00 2001
From: Douglas Christopher Wilson 
Date: Sun, 5 Mar 2017 00:08:16 -0500
Subject: [PATCH 1051/1265] deps: serve-static@1.12.1

fixes #3233
---
 History.md   | 3 +++
 package.json | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/History.md b/History.md
index aadd7ece046..e4de69bc488 100644
--- a/History.md
+++ b/History.md
@@ -4,6 +4,9 @@ unreleased
   * deps: send@0.15.1
     - Fix issue when `Date.parse` does not return `NaN` on invalid date
     - Fix strict violation in broken environments
+  * deps: serve-static@1.12.1
+    - Fix issue when `Date.parse` does not return `NaN` on invalid date
+    - deps: send@0.15.1
 
 4.15.0 / 2017-03-01
 ===================
diff --git a/package.json b/package.json
index aea1a83bc10..1b442295e03 100644
--- a/package.json
+++ b/package.json
@@ -49,7 +49,7 @@
     "qs": "6.3.1",
     "range-parser": "~1.2.0",
     "send": "0.15.1",
-    "serve-static": "1.12.0",
+    "serve-static": "1.12.1",
     "setprototypeof": "1.0.3",
     "statuses": "~1.3.1",
     "type-is": "~1.6.14",

From 8eb95ae57973b2cbe7778bc2e10450a380ca2efe Mon Sep 17 00:00:00 2001
From: chainhelen 
Date: Mon, 6 Mar 2017 02:44:22 +0800
Subject: [PATCH 1052/1265] examples: use path.join instead of concatenation

closes #3236
---
 examples/auth/index.js             |  3 ++-
 examples/downloads/index.js        |  6 ++---
 examples/ejs/index.js              |  3 ++-
 examples/error-pages/index.js      |  3 ++-
 examples/jade/index.js             |  5 +++--
 examples/markdown/index.js         |  3 ++-
 examples/mvc/index.js              |  5 +++--
 examples/mvc/lib/boot.js           | 35 ++++++++++++++++--------------
 examples/route-separation/index.js |  5 +++--
 examples/search/index.js           |  5 +++--
 10 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/examples/auth/index.js b/examples/auth/index.js
index 1c3ca217512..084fba79a97 100644
--- a/examples/auth/index.js
+++ b/examples/auth/index.js
@@ -5,6 +5,7 @@
 var express = require('../..');
 var bodyParser = require('body-parser');
 var hash = require('pbkdf2-password')()
+var path = require('path');
 var session = require('express-session');
 
 var app = module.exports = express();
@@ -12,7 +13,7 @@ var app = module.exports = express();
 // config
 
 app.set('view engine', 'ejs');
-app.set('views', __dirname + '/views');
+app.set('views', path.join(__dirname, 'views'));
 
 // middleware
 
diff --git a/examples/downloads/index.js b/examples/downloads/index.js
index 6ab6ba0213e..e6f3fa9db69 100644
--- a/examples/downloads/index.js
+++ b/examples/downloads/index.js
@@ -3,6 +3,7 @@
  */
 
 var express = require('../../');
+var path = require('path');
 var app = module.exports = express();
 
 app.get('/', function(req, res){
@@ -16,10 +17,9 @@ app.get('/', function(req, res){
 // /files/* is accessed via req.params[0]
 // but here we name it :file
 app.get('/files/:file(*)', function(req, res, next){
-  var file = req.params.file;
-  var path = __dirname + '/files/' + file;
+  var filePath = path.join(__dirname, 'files', req.params.file);
 
-  res.download(path, function(err){
+  res.download(filePath, function (err) {
     if (!err) return; // file sent
     if (err && err.status !== 404) return next(err); // non-404 error
     // file for download not found
diff --git a/examples/ejs/index.js b/examples/ejs/index.js
index bf78a9cc803..13a80efc193 100644
--- a/examples/ejs/index.js
+++ b/examples/ejs/index.js
@@ -3,6 +3,7 @@
  */
 
 var express = require('../../');
+var path = require('path');
 
 var app = module.exports = express();
 
@@ -21,7 +22,7 @@ app.engine('.html', require('ejs').__express);
 
 // Optional since express defaults to CWD/views
 
-app.set('views', __dirname + '/views');
+app.set('views', path.join(__dirname, 'views'));
 
 // Without this you would need to
 // supply the extension to res.render()
diff --git a/examples/error-pages/index.js b/examples/error-pages/index.js
index d1219689f2c..790f6e30dfd 100644
--- a/examples/error-pages/index.js
+++ b/examples/error-pages/index.js
@@ -3,12 +3,13 @@
  */
 
 var express = require('../../');
+var path = require('path');
 var app = module.exports = express();
 var logger = require('morgan');
 var silent = 'test' == process.env.NODE_ENV;
 
 // general config
-app.set('views', __dirname + '/views');
+app.set('views', path.join(__dirname, 'views'));
 app.set('view engine', 'ejs');
 
 // our custom "verbose errors" setting
diff --git a/examples/jade/index.js b/examples/jade/index.js
index 738b382d267..86ca14c426e 100644
--- a/examples/jade/index.js
+++ b/examples/jade/index.js
@@ -3,10 +3,11 @@
  */
 
 var express = require('../../lib/express');
+var path = require('path');
 
 // Path to our public directory
 
-var pub = __dirname + '/public';
+var pub = path.join(__dirname, 'public');
 
 // setup middleware
 
@@ -15,7 +16,7 @@ app.use(express.static(pub));
 
 // Optional since express defaults to CWD/views
 
-app.set('views', __dirname + '/views');
+app.set('views', path.join(__dirname, 'views'));
 
 // Set our default template engine to "jade"
 // which prevents the need for extensions
diff --git a/examples/markdown/index.js b/examples/markdown/index.js
index 430628701fd..df8c195fb4e 100644
--- a/examples/markdown/index.js
+++ b/examples/markdown/index.js
@@ -6,6 +6,7 @@ var escapeHtml = require('escape-html');
 var express = require('../..');
 var fs = require('fs');
 var marked = require('marked');
+var path = require('path');
 
 var app = module.exports = express();
 
@@ -21,7 +22,7 @@ app.engine('md', function(path, options, fn){
   });
 });
 
-app.set('views', __dirname + '/views');
+app.set('views', path.join(__dirname, 'views'));
 
 // make it the default so we dont need .md
 app.set('view engine', 'md');
diff --git a/examples/mvc/index.js b/examples/mvc/index.js
index bf7f726e30f..c5e2678697a 100644
--- a/examples/mvc/index.js
+++ b/examples/mvc/index.js
@@ -4,6 +4,7 @@
 
 var express = require('../..');
 var logger = require('morgan');
+var path = require('path');
 var session = require('express-session');
 var bodyParser = require('body-parser');
 var methodOverride = require('method-override');
@@ -17,7 +18,7 @@ var app = module.exports = express();
 app.set('view engine', 'jade');
 
 // set views for error and 404 pages
-app.set('views', __dirname + '/views');
+app.set('views', path.join(__dirname, 'views'));
 
 // define a custom res.message() method
 // which stores messages in the session
@@ -34,7 +35,7 @@ app.response.message = function(msg){
 if (!module.parent) app.use(logger('dev'));
 
 // serve static files
-app.use(express.static(__dirname + '/public'));
+app.use(express.static(path.join(__dirname, 'public')));
 
 // session support
 app.use(session({
diff --git a/examples/mvc/lib/boot.js b/examples/mvc/lib/boot.js
index a0ca6ec37b1..422330dc066 100644
--- a/examples/mvc/lib/boot.js
+++ b/examples/mvc/lib/boot.js
@@ -4,23 +4,26 @@
 
 var express = require('../../..');
 var fs = require('fs');
+var path = require('path');
 
 module.exports = function(parent, options){
+  var dir = path.join(__dirname, '..', 'controllers');
   var verbose = options.verbose;
-  fs.readdirSync(__dirname + '/../controllers').forEach(function(name){
-    if (!fs.statSync(__dirname + '/../controllers/' + name).isDirectory()) return;
+  fs.readdirSync(dir).forEach(function(name){
+    var file = path.join(dir, name)
+    if (!fs.statSync(file).isDirectory()) return;
     verbose && console.log('\n   %s:', name);
-    var obj = require('./../controllers/' + name);
+    var obj = require(file);
     var name = obj.name || name;
     var prefix = obj.prefix || '';
     var app = express();
     var handler;
     var method;
-    var path;
+    var url;
 
     // allow specifying the view engine
     if (obj.engine) app.set('view engine', obj.engine);
-    app.set('views', __dirname + '/../controllers/' + name + '/views');
+    app.set('views', path.join(__dirname, '..', 'controllers', name, 'views'));
 
     // generate routes based
     // on the exported methods
@@ -31,27 +34,27 @@ module.exports = function(parent, options){
       switch (key) {
         case 'show':
           method = 'get';
-          path = '/' + name + '/:' + name + '_id';
+          url = '/' + name + '/:' + name + '_id';
           break;
         case 'list':
           method = 'get';
-          path = '/' + name + 's';
+          url = '/' + name + 's';
           break;
         case 'edit':
           method = 'get';
-          path = '/' + name + '/:' + name + '_id/edit';
+          url = '/' + name + '/:' + name + '_id/edit';
           break;
         case 'update':
           method = 'put';
-          path = '/' + name + '/:' + name + '_id';
+          url = '/' + name + '/:' + name + '_id';
           break;
         case 'create':
           method = 'post';
-          path = '/' + name;
+          url = '/' + name;
           break;
         case 'index':
           method = 'get';
-          path = '/';
+          url = '/';
           break;
         default:
           /* istanbul ignore next */
@@ -60,15 +63,15 @@ module.exports = function(parent, options){
 
       // setup
       handler = obj[key];
-      path = prefix + path;
+      url = prefix + url;
 
       // before middleware support
       if (obj.before) {
-        app[method](path, obj.before, handler);
-        verbose && console.log('     %s %s -> before -> %s', method.toUpperCase(), path, key);
+        app[method](url, obj.before, handler);
+        verbose && console.log('     %s %s -> before -> %s', method.toUpperCase(), url, key);
       } else {
-        app[method](path, handler);
-        verbose && console.log('     %s %s -> %s', method.toUpperCase(), path, key);
+        app[method](url, handler);
+        verbose && console.log('     %s %s -> %s', method.toUpperCase(), url, key);
       }
     }
 
diff --git a/examples/route-separation/index.js b/examples/route-separation/index.js
index 3d93d5cfd9c..c6605ada6cb 100644
--- a/examples/route-separation/index.js
+++ b/examples/route-separation/index.js
@@ -3,6 +3,7 @@
  */
 
 var express = require('../..');
+var path = require('path');
 var app = express();
 var logger = require('morgan');
 var cookieParser = require('cookie-parser');
@@ -17,7 +18,7 @@ module.exports = app;
 // Config
 
 app.set('view engine', 'jade');
-app.set('views', __dirname + '/views');
+app.set('views', path.join(__dirname, 'views'));
 
 /* istanbul ignore next */
 if (!module.parent) {
@@ -27,7 +28,7 @@ if (!module.parent) {
 app.use(methodOverride('_method'));
 app.use(cookieParser());
 app.use(bodyParser.urlencoded({ extended: true }));
-app.use(express.static(__dirname + '/public'));
+app.use(express.static(path.join(__dirname, 'public')));
 
 // General
 
diff --git a/examples/search/index.js b/examples/search/index.js
index 8027635f19e..79f5d9f4d36 100644
--- a/examples/search/index.js
+++ b/examples/search/index.js
@@ -7,6 +7,7 @@
  */
 
 var express = require('../..');
+var path = require('path');
 var redis = require('redis');
 
 var db = redis.createClient();
@@ -15,7 +16,7 @@ var db = redis.createClient();
 
 var app = express();
 
-app.use(express.static(__dirname + '/public'));
+app.use(express.static(path.join(__dirname, 'public')));
 
 // populate search
 
@@ -45,7 +46,7 @@ app.get('/search/:query?', function(req, res){
  */
 
 app.get('/client.js', function(req, res){
-  res.sendFile(__dirname + '/client.js');
+  res.sendFile(path.join(__dirname, 'client.js'));
 });
 
 /* istanbul ignore next */

From eece3850bc5206c28bfac78c986fbe0c193b34b8 Mon Sep 17 00:00:00 2001
From: chainhelen 
Date: Mon, 6 Mar 2017 02:44:22 +0800
Subject: [PATCH 1053/1265] tests: use path.join instead of concatenation

closes #3236
---
 test/app.engine.js   |  9 +++++----
 test/app.render.js   | 47 ++++++++++++++++++++++++++++----------------
 test/res.render.js   | 47 +++++++++++++++++++++++++-------------------
 test/res.sendFile.js |  4 ++--
 4 files changed, 64 insertions(+), 43 deletions(-)

diff --git a/test/app.engine.js b/test/app.engine.js
index 88311b2f6d5..6d1ee1cacbf 100644
--- a/test/app.engine.js
+++ b/test/app.engine.js
@@ -1,6 +1,7 @@
 
 var express = require('../')
   , fs = require('fs');
+var path = require('path')
 
 function render(path, options, fn) {
   fs.readFile(path, 'utf8', function(err, str){
@@ -15,7 +16,7 @@ describe('app', function(){
     it('should map a template engine', function(done){
       var app = express();
 
-      app.set('views', __dirname + '/fixtures');
+      app.set('views', path.join(__dirname, 'fixtures'))
       app.engine('.html', render);
       app.locals.user = { name: 'tobi' };
 
@@ -36,7 +37,7 @@ describe('app', function(){
     it('should work without leading "."', function(done){
       var app = express();
 
-      app.set('views', __dirname + '/fixtures');
+      app.set('views', path.join(__dirname, 'fixtures'))
       app.engine('html', render);
       app.locals.user = { name: 'tobi' };
 
@@ -50,7 +51,7 @@ describe('app', function(){
     it('should work "view engine" setting', function(done){
       var app = express();
 
-      app.set('views', __dirname + '/fixtures');
+      app.set('views', path.join(__dirname, 'fixtures'))
       app.engine('html', render);
       app.set('view engine', 'html');
       app.locals.user = { name: 'tobi' };
@@ -65,7 +66,7 @@ describe('app', function(){
     it('should work "view engine" with leading "."', function(done){
       var app = express();
 
-      app.set('views', __dirname + '/fixtures');
+      app.set('views', path.join(__dirname, 'fixtures'))
       app.engine('.html', render);
       app.set('view engine', '.html');
       app.locals.user = { name: 'tobi' };
diff --git a/test/app.render.js b/test/app.render.js
index c9737b7a060..729b1c97cc8 100644
--- a/test/app.render.js
+++ b/test/app.render.js
@@ -1,5 +1,7 @@
 
+var assert = require('assert')
 var express = require('..');
+var path = require('path')
 var tmpl = require('./support/tmpl');
 
 describe('app', function(){
@@ -9,7 +11,7 @@ describe('app', function(){
 
       app.locals.user = { name: 'tobi' };
 
-      app.render(__dirname + '/fixtures/user.tmpl', function (err, str) {
+      app.render(path.join(__dirname, 'fixtures', 'user.tmpl'), function (err, str) {
         if (err) return done(err);
         str.should.equal('

tobi

'); done(); @@ -22,7 +24,7 @@ describe('app', function(){ app.set('view engine', 'tmpl'); app.locals.user = { name: 'tobi' }; - app.render(__dirname + '/fixtures/user', function(err, str){ + app.render(path.join(__dirname, 'fixtures', 'user'), function (err, str) { if (err) return done(err); str.should.equal('

tobi

'); done(); @@ -32,7 +34,7 @@ describe('app', function(){ it('should expose app.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.user = { name: 'tobi' }; app.render('user.tmpl', function (err, str) { @@ -45,7 +47,7 @@ describe('app', function(){ it('should support index.', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.set('view engine', 'tmpl'); app.render('blog/post', function (err, str) { @@ -80,9 +82,10 @@ describe('app', function(){ it('should provide a helpful error', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.render('rawr.tmpl', function (err) { - err.message.should.equal('Failed to lookup view "rawr.tmpl" in views directory "' + __dirname + '/fixtures"'); + assert.ok(err) + assert.equal(err.message, 'Failed to lookup view "rawr.tmpl" in views directory "' + path.join(__dirname, 'fixtures') + '"') done(); }); }) @@ -92,7 +95,7 @@ describe('app', function(){ it('should invoke the callback', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.render('user.tmpl', function (err, str) { // nextTick to prevent cyclic @@ -108,7 +111,7 @@ describe('app', function(){ it('should render the template', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.render('email.tmpl', function (err, str) { if (err) return done(err); @@ -123,7 +126,7 @@ describe('app', function(){ var app = createApp(); app.set('view engine', 'tmpl'); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.render('email', function(err, str){ if (err) return done(err); @@ -137,7 +140,7 @@ describe('app', function(){ it('should lookup the file in the path', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures/default_layout'); + app.set('views', path.join(__dirname, 'fixtures', 'default_layout')) app.locals.user = { name: 'tobi' }; app.render('user.tmpl', function (err, str) { @@ -150,7 +153,10 @@ describe('app', function(){ describe('when array of paths', function(){ it('should lookup the file in the path', function(done){ var app = createApp(); - var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + var views = [ + path.join(__dirname, 'fixtures', 'local_layout'), + path.join(__dirname, 'fixtures', 'default_layout') + ] app.set('views', views); app.locals.user = { name: 'tobi' }; @@ -164,7 +170,10 @@ describe('app', function(){ it('should lookup in later paths until found', function(done){ var app = createApp(); - var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + var views = [ + path.join(__dirname, 'fixtures', 'local_layout'), + path.join(__dirname, 'fixtures', 'default_layout') + ] app.set('views', views); app.locals.name = 'tobi'; @@ -178,13 +187,17 @@ describe('app', function(){ it('should error if file does not exist', function(done){ var app = createApp(); - var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + var views = [ + path.join(__dirname, 'fixtures', 'local_layout'), + path.join(__dirname, 'fixtures', 'default_layout') + ] app.set('views', views); app.locals.name = 'tobi'; app.render('pet.tmpl', function (err, str) { - err.message.should.equal('Failed to lookup view "pet.tmpl" in views directories "' + __dirname + '/fixtures/local_layout" or "' + __dirname + '/fixtures/default_layout"'); + assert.ok(err) + assert.equal(err.message, 'Failed to lookup view "pet.tmpl" in views directories "' + views[0] + '" or "' + views[1] + '"') done(); }) }) @@ -281,7 +294,7 @@ describe('app', function(){ it('should render the template', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) var user = { name: 'tobi' }; @@ -295,7 +308,7 @@ describe('app', function(){ it('should expose app.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.user = { name: 'tobi' }; app.render('user.tmpl', {}, function (err, str) { @@ -308,7 +321,7 @@ describe('app', function(){ it('should give precedence to app.render() locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.user = { name: 'tobi' }; var jane = { name: 'jane' }; diff --git a/test/res.render.js b/test/res.render.js index d4d2a7616d1..2e3a16f1370 100644 --- a/test/res.render.js +++ b/test/res.render.js @@ -1,5 +1,6 @@ var express = require('..'); +var path = require('path') var request = require('supertest'); var tmpl = require('./support/tmpl'); @@ -11,7 +12,7 @@ describe('res', function(){ app.locals.user = { name: 'tobi' }; app.use(function(req, res){ - res.render(__dirname + '/fixtures/user.tmpl'); + res.render(path.join(__dirname, 'fixtures', 'user.tmpl')) }); request(app) @@ -26,7 +27,7 @@ describe('res', function(){ app.set('view engine', 'tmpl'); app.use(function(req, res){ - res.render(__dirname + '/fixtures/user'); + res.render(path.join(__dirname, 'fixtures', 'user')) }); request(app) @@ -40,7 +41,7 @@ describe('res', function(){ app.locals.user = { name: 'tobi' }; app.use(function(req, res){ - res.render(__dirname + '/fixtures/user'); + res.render(path.join(__dirname, 'fixtures', 'user')) }); request(app) @@ -51,7 +52,7 @@ describe('res', function(){ it('should expose app.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.user = { name: 'tobi' }; app.use(function(req, res){ @@ -66,7 +67,7 @@ describe('res', function(){ it('should expose app.locals with `name` property', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.name = 'tobi'; app.use(function(req, res){ @@ -81,7 +82,7 @@ describe('res', function(){ it('should support index.', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.set('view engine', 'tmpl'); app.use(function(req, res){ @@ -97,7 +98,7 @@ describe('res', function(){ it('should next(err)', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.use(function(req, res){ res.render('user.tmpl'); @@ -118,7 +119,7 @@ describe('res', function(){ var app = createApp(); app.set('view engine', 'tmpl'); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.use(function(req, res){ res.render('email'); @@ -134,7 +135,7 @@ describe('res', function(){ it('should lookup the file in the path', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures/default_layout'); + app.set('views', path.join(__dirname, 'fixtures', 'default_layout')) app.use(function(req, res){ res.render('user.tmpl', { user: { name: 'tobi' } }); @@ -148,7 +149,10 @@ describe('res', function(){ describe('when array of paths', function(){ it('should lookup the file in the path', function(done){ var app = createApp(); - var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + var views = [ + path.join(__dirname, 'fixtures', 'local_layout'), + path.join(__dirname, 'fixtures', 'default_layout') + ] app.set('views', views); @@ -163,7 +167,10 @@ describe('res', function(){ it('should lookup in later paths until found', function(done){ var app = createApp(); - var views = [__dirname + '/fixtures/local_layout', __dirname + '/fixtures/default_layout']; + var views = [ + path.join(__dirname, 'fixtures', 'local_layout'), + path.join(__dirname, 'fixtures', 'default_layout') + ] app.set('views', views); @@ -183,7 +190,7 @@ describe('res', function(){ it('should render the template', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) var user = { name: 'tobi' }; @@ -199,7 +206,7 @@ describe('res', function(){ it('should expose app.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.user = { name: 'tobi' }; app.use(function(req, res){ @@ -214,7 +221,7 @@ describe('res', function(){ it('should expose res.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.use(function(req, res){ res.locals.user = { name: 'tobi' }; @@ -229,7 +236,7 @@ describe('res', function(){ it('should give precedence to res.locals over app.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.user = { name: 'tobi' }; app.use(function(req, res){ @@ -245,7 +252,7 @@ describe('res', function(){ it('should give precedence to res.render() locals over res.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) var jane = { name: 'jane' }; app.use(function(req, res){ @@ -261,7 +268,7 @@ describe('res', function(){ it('should give precedence to res.render() locals over app.locals', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.locals.user = { name: 'tobi' }; var jane = { name: 'jane' }; @@ -279,7 +286,7 @@ describe('res', function(){ it('should pass the resulting string', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.use(function(req, res){ var tobi = { name: 'tobi' }; @@ -299,7 +306,7 @@ describe('res', function(){ it('should pass the resulting string', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.use(function(req, res){ res.locals.user = { name: 'tobi' }; @@ -318,7 +325,7 @@ describe('res', function(){ it('should pass it to the callback', function(done){ var app = createApp(); - app.set('views', __dirname + '/fixtures'); + app.set('views', path.join(__dirname, 'fixtures')) app.use(function(req, res){ res.render('user.tmpl', function (err) { diff --git a/test/res.sendFile.js b/test/res.sendFile.js index 927d31991f0..be3a23ebc2c 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -613,7 +613,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - res.sendfile(__dirname + '/fixtures/user.html'); + res.sendfile(path.join(__dirname, '/fixtures/user.html')) }); request(app) @@ -718,7 +718,7 @@ describe('res', function(){ , calls = 0; app.use(function(req, res){ - res.sendfile(__dirname + '/fixtures/name.txt'); + res.sendfile(path.join(__dirname, '/fixtures/name.txt')) }); request(app) From 57d3dfd9f828c4529fa90dde4b3d216898181e99 Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Sun, 26 Feb 2017 13:26:39 +0000 Subject: [PATCH 1054/1265] examples: merge the jade example into ejs closes #3223 --- examples/ejs/index.js | 4 ++ .../public/stylesheets/style.css | 0 examples/ejs/views/header.html | 9 +--- examples/jade/index.js | 52 ------------------- examples/jade/views/header.jade | 3 -- examples/jade/views/layout.jade | 5 -- examples/jade/views/users/index.jade | 8 --- examples/jade/views/users/user.jade | 3 -- 8 files changed, 6 insertions(+), 78 deletions(-) rename examples/{jade => ejs}/public/stylesheets/style.css (100%) delete mode 100644 examples/jade/index.js delete mode 100644 examples/jade/views/header.jade delete mode 100644 examples/jade/views/layout.jade delete mode 100644 examples/jade/views/users/index.jade delete mode 100644 examples/jade/views/users/user.jade diff --git a/examples/ejs/index.js b/examples/ejs/index.js index 13a80efc193..b868bdd7cb9 100644 --- a/examples/ejs/index.js +++ b/examples/ejs/index.js @@ -24,6 +24,10 @@ app.engine('.html', require('ejs').__express); app.set('views', path.join(__dirname, 'views')); +// Path to our public directory + +app.use(express.static(path.join(__dirname + 'public'))); + // Without this you would need to // supply the extension to res.render() // ex: res.render('users.html'). diff --git a/examples/jade/public/stylesheets/style.css b/examples/ejs/public/stylesheets/style.css similarity index 100% rename from examples/jade/public/stylesheets/style.css rename to examples/ejs/public/stylesheets/style.css diff --git a/examples/ejs/views/header.html b/examples/ejs/views/header.html index 8dbeb8d3c01..4396bc444fa 100644 --- a/examples/ejs/views/header.html +++ b/examples/ejs/views/header.html @@ -2,12 +2,7 @@ - <%= title %> - + <%= title %> + diff --git a/examples/jade/index.js b/examples/jade/index.js deleted file mode 100644 index 86ca14c426e..00000000000 --- a/examples/jade/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Module dependencies. - */ - -var express = require('../../lib/express'); -var path = require('path'); - -// Path to our public directory - -var pub = path.join(__dirname, 'public'); - -// setup middleware - -var app = express(); -app.use(express.static(pub)); - -// Optional since express defaults to CWD/views - -app.set('views', path.join(__dirname, 'views')); - -// Set our default template engine to "jade" -// which prevents the need for extensions -// (although you can still mix and match) -app.set('view engine', 'jade'); - -function User(name, email) { - this.name = name; - this.email = email; -} - -// Dummy users -var users = [ - new User('tj', 'tj@vision-media.ca') - , new User('ciaran', 'ciaranj@gmail.com') - , new User('aaron', 'aaron.heckmann+github@gmail.com') -]; - -app.get('/', function(req, res){ - res.render('users', { users: users }); -}); - -// change this to a better error handler in your code -// sending stacktrace to users in production is not good -app.use(function(err, req, res, next) { - res.send(err.stack); -}); - -/* istanbul ignore next */ -if (!module.parent) { - app.listen(3000); - console.log('Express started on port 3000'); -} diff --git a/examples/jade/views/header.jade b/examples/jade/views/header.jade deleted file mode 100644 index 6c42929d837..00000000000 --- a/examples/jade/views/header.jade +++ /dev/null @@ -1,3 +0,0 @@ -head - title Jade Example - link(rel="stylesheet", href="/stylesheets/style.css") \ No newline at end of file diff --git a/examples/jade/views/layout.jade b/examples/jade/views/layout.jade deleted file mode 100644 index 300cdc78473..00000000000 --- a/examples/jade/views/layout.jade +++ /dev/null @@ -1,5 +0,0 @@ -doctype html -html - include header - body - block content diff --git a/examples/jade/views/users/index.jade b/examples/jade/views/users/index.jade deleted file mode 100644 index feb7623fa3d..00000000000 --- a/examples/jade/views/users/index.jade +++ /dev/null @@ -1,8 +0,0 @@ - -extends ../layout - -block content - h1 Users - #users - for user in users - include user \ No newline at end of file diff --git a/examples/jade/views/users/user.jade b/examples/jade/views/users/user.jade deleted file mode 100644 index 9e603298cbf..00000000000 --- a/examples/jade/views/users/user.jade +++ /dev/null @@ -1,3 +0,0 @@ -.user - h2= user.name - .email= user.email \ No newline at end of file From d32ed68b2995e0322100ace29d86e7a86b9c6378 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 5 Mar 2017 23:19:32 -0500 Subject: [PATCH 1055/1265] 4.15.1 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index e4de69bc488..82511c3f400 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.15.1 / 2017-03-05 +=================== * deps: send@0.15.1 - Fix issue when `Date.parse` does not return `NaN` on invalid date diff --git a/package.json b/package.json index 1b442295e03..727064b6652 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.15.0", + "version": "4.15.1", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 85c96fd64edad8ce076bb82c065ef0c9fea6c559 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Mar 2017 08:32:13 -0500 Subject: [PATCH 1056/1265] deps: qs@6.4.0 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 82511c3f400..dd529f16320 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: qs@6.4.0 + - Fix regression parsing keys starting with `[` + 4.15.1 / 2017-03-05 =================== diff --git a/package.json b/package.json index 727064b6652..05a9ce56d90 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", "proxy-addr": "~1.1.3", - "qs": "6.3.1", + "qs": "6.4.0", "range-parser": "~1.2.0", "send": "0.15.1", "serve-static": "1.12.1", From 05fd1e444198954c1e275d485bccabafed052868 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Mar 2017 08:33:37 -0500 Subject: [PATCH 1057/1265] deps: update example dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05a9ce56d90..7894722c4db 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ }, "devDependencies": { "after": "0.8.2", - "body-parser": "1.17.0", + "body-parser": "1.17.1", "cookie-parser": "~1.4.3", "ejs": "2.5.6", "express-session": "1.15.1", From d43b074f0b3b56a91f240e62798c932ba104b79a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Mar 2017 08:34:38 -0500 Subject: [PATCH 1058/1265] 4.15.2 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index dd529f16320..5bfd5690a53 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.15.2 / 2017-03-06 +=================== * deps: qs@6.4.0 - Fix regression parsing keys starting with `[` diff --git a/package.json b/package.json index 7894722c4db..ef49b40d425 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.15.1", + "version": "4.15.2", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 64dd446aa85a3fc28bd4662626593f29a45689f6 Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Wed, 8 Mar 2017 14:10:39 +0000 Subject: [PATCH 1059/1265] docs: remove dead link to translated readme closes #3239 --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index 0ddc68fdc9a..7b261a3d94d 100644 --- a/Readme.md +++ b/Readme.md @@ -43,7 +43,6 @@ $ npm install express * Visit the [Wiki](https://github.com/expressjs/express/wiki) * [Google Group](https://groups.google.com/group/express-js) for discussion * [Gitter](https://gitter.im/expressjs/express) for support and discussion - * [Русскоязычная документация](http://jsman.ru/express/) **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x). From f44368f8bede4ffc56929b183d6d5508e222a949 Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Wed, 8 Mar 2017 14:32:43 +0000 Subject: [PATCH 1060/1265] examples: replace jade with ejs in view-locals closes #3240 --- examples/view-locals/index.js | 11 ++++++----- examples/view-locals/layout.jade | 12 ------------ examples/view-locals/user.jade | 8 -------- examples/view-locals/views/index.ejs | 19 +++++++++++++++++++ 4 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 examples/view-locals/layout.jade delete mode 100644 examples/view-locals/user.jade create mode 100644 examples/view-locals/views/index.ejs diff --git a/examples/view-locals/index.js b/examples/view-locals/index.js index cf347ed38d6..3814e6e4962 100644 --- a/examples/view-locals/index.js +++ b/examples/view-locals/index.js @@ -3,11 +3,12 @@ */ var express = require('../..'); +var path = require('path'); var User = require('./user'); var app = express(); -app.set('views', __dirname); -app.set('view engine', 'jade'); +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'ejs'); // filter ferrets only @@ -25,7 +26,7 @@ app.get('/', function(req, res, next){ if (err) return next(err); User.all(function(err, users){ if (err) return next(err); - res.render('user', { + res.render('index', { title: 'Users', count: count, users: users.filter(ferrets) @@ -59,7 +60,7 @@ function users(req, res, next) { } app.get('/middleware', count, users, function(req, res, next){ - res.render('user', { + res.render('index', { title: 'Users', count: req.count, users: req.users.filter(ferrets) @@ -101,7 +102,7 @@ app.get('/middleware-locals', count2, users2, function(req, res, next){ // to pass to res.render(). If we have // several routes related to users this // can be a great productivity booster - res.render('user', { title: 'Users' }); + res.render('index', { title: 'Users' }); }); // keep in mind that middleware may be placed anywhere diff --git a/examples/view-locals/layout.jade b/examples/view-locals/layout.jade deleted file mode 100644 index 5616cfaf7c2..00000000000 --- a/examples/view-locals/layout.jade +++ /dev/null @@ -1,12 +0,0 @@ -doctype html -html - head - title= title - style. - body { - padding: 50px; - font: 16px Helvetica, Arial; - } - body - h2= title - block content \ No newline at end of file diff --git a/examples/view-locals/user.jade b/examples/view-locals/user.jade deleted file mode 100644 index b07d2b17563..00000000000 --- a/examples/view-locals/user.jade +++ /dev/null @@ -1,8 +0,0 @@ - -extends layout - -block content - for user in users - .user - h3= user.name - p #{user.name} is a #{user.age} year old #{user.species}. \ No newline at end of file diff --git a/examples/view-locals/views/index.ejs b/examples/view-locals/views/index.ejs new file mode 100644 index 00000000000..1cbfc40bc00 --- /dev/null +++ b/examples/view-locals/views/index.ejs @@ -0,0 +1,19 @@ + + + + + <%= title %> + + + +

<%= title %>

+ <% users.forEach(function(user) { %> +
  • <%= user.name %> is a <% user.age %> year old <%= user.species %>
  • + <% }); %> + + From a1fffda3f2c879dac1b2ba7a28c457957768e874 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 14 Mar 2017 23:46:29 -0400 Subject: [PATCH 1061/1265] build: should@11.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef49b40d425..1ec44636566 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "morgan": "1.8.1", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", - "should": "11.2.0", + "should": "11.2.1", "supertest": "1.2.0", "connect-redis": "~2.4.1", "cookie-session": "~1.2.0", From 1b6ad080952f026fc7913beb84176519658ee07b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 14 Mar 2017 23:53:19 -0400 Subject: [PATCH 1062/1265] deps: debug@2.6.3 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5bfd5690a53..aa32ea6b893 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +unreleased +========== + + * deps: debug@2.6.3 + - Fix: `DEBUG_MAX_ARRAY_LENGTH` + 4.15.2 / 2017-03-06 =================== diff --git a/package.json b/package.json index 1ec44636566..dd03d7e9bc5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "content-type": "~1.0.2", "cookie": "0.3.1", "cookie-signature": "1.0.6", - "debug": "2.6.1", + "debug": "2.6.3", "depd": "~1.1.0", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", From 245fa8942a4478862b7a620c6ce66f55311c556e Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Wed, 8 Mar 2017 14:52:43 +0000 Subject: [PATCH 1063/1265] examples: replace jade with ejs in route-separation closes #3241 --- examples/route-separation/index.js | 2 +- examples/route-separation/views/footer.ejs | 2 ++ examples/route-separation/views/header.ejs | 8 +++++++ examples/route-separation/views/index.ejs | 10 ++++++++ examples/route-separation/views/index.jade | 6 ----- examples/route-separation/views/layout.jade | 6 ----- .../route-separation/views/posts/index.ejs | 12 ++++++++++ .../route-separation/views/posts/index.jade | 8 ------- .../route-separation/views/users/edit.ejs | 23 +++++++++++++++++++ .../route-separation/views/users/edit.jade | 12 ---------- .../route-separation/views/users/index.ejs | 14 +++++++++++ .../route-separation/views/users/index.jade | 9 -------- .../route-separation/views/users/view.ejs | 9 ++++++++ .../route-separation/views/users/view.jade | 6 ----- 14 files changed, 79 insertions(+), 48 deletions(-) create mode 100644 examples/route-separation/views/footer.ejs create mode 100644 examples/route-separation/views/header.ejs create mode 100644 examples/route-separation/views/index.ejs delete mode 100644 examples/route-separation/views/index.jade delete mode 100644 examples/route-separation/views/layout.jade create mode 100644 examples/route-separation/views/posts/index.ejs delete mode 100644 examples/route-separation/views/posts/index.jade create mode 100644 examples/route-separation/views/users/edit.ejs delete mode 100644 examples/route-separation/views/users/edit.jade create mode 100644 examples/route-separation/views/users/index.ejs delete mode 100644 examples/route-separation/views/users/index.jade create mode 100644 examples/route-separation/views/users/view.ejs delete mode 100644 examples/route-separation/views/users/view.jade diff --git a/examples/route-separation/index.js b/examples/route-separation/index.js index c6605ada6cb..79e26497f45 100644 --- a/examples/route-separation/index.js +++ b/examples/route-separation/index.js @@ -17,7 +17,7 @@ module.exports = app; // Config -app.set('view engine', 'jade'); +app.set('view engine', 'ejs'); app.set('views', path.join(__dirname, 'views')); /* istanbul ignore next */ diff --git a/examples/route-separation/views/footer.ejs b/examples/route-separation/views/footer.ejs new file mode 100644 index 00000000000..308b1d01b6c --- /dev/null +++ b/examples/route-separation/views/footer.ejs @@ -0,0 +1,2 @@ + + diff --git a/examples/route-separation/views/header.ejs b/examples/route-separation/views/header.ejs new file mode 100644 index 00000000000..141f114ddba --- /dev/null +++ b/examples/route-separation/views/header.ejs @@ -0,0 +1,8 @@ + + + + + <%= title %> + + + diff --git a/examples/route-separation/views/index.ejs b/examples/route-separation/views/index.ejs new file mode 100644 index 00000000000..6d1afb4ac3d --- /dev/null +++ b/examples/route-separation/views/index.ejs @@ -0,0 +1,10 @@ +<% include header %> + +

    <%= title %>

    + +
      +
    • Visit the users page.
    • +
    • Visit the posts page.
    • +
    + +<% include footer %> diff --git a/examples/route-separation/views/index.jade b/examples/route-separation/views/index.jade deleted file mode 100644 index af9d499387a..00000000000 --- a/examples/route-separation/views/index.jade +++ /dev/null @@ -1,6 +0,0 @@ -extends layout - -block content - ul - li Visit the users page - li Visit the posts page diff --git a/examples/route-separation/views/layout.jade b/examples/route-separation/views/layout.jade deleted file mode 100644 index 6535c8cc89d..00000000000 --- a/examples/route-separation/views/layout.jade +++ /dev/null @@ -1,6 +0,0 @@ -html - head - title= title - link(href="/style.css", rel="stylesheet") - body - block content diff --git a/examples/route-separation/views/posts/index.ejs b/examples/route-separation/views/posts/index.ejs new file mode 100644 index 00000000000..12303444858 --- /dev/null +++ b/examples/route-separation/views/posts/index.ejs @@ -0,0 +1,12 @@ +<% include ../header %> + +

    Posts

    + +
    + <% posts.forEach(function(post) { %> +
    <%= post.title %>
    +
    <%= post.body %>
    + <% }) %> +
    + +<% include ../footer %> diff --git a/examples/route-separation/views/posts/index.jade b/examples/route-separation/views/posts/index.jade deleted file mode 100644 index 46efb2ea222..00000000000 --- a/examples/route-separation/views/posts/index.jade +++ /dev/null @@ -1,8 +0,0 @@ -extends ../layout - -block content - h1 Posts - dl#posts - for post in posts - dt= post.title - dd= post.body diff --git a/examples/route-separation/views/users/edit.ejs b/examples/route-separation/views/users/edit.ejs new file mode 100644 index 00000000000..c64160e037f --- /dev/null +++ b/examples/route-separation/views/users/edit.ejs @@ -0,0 +1,23 @@ +<% include ../header %> + +

    Editing <%= user.name %>

    + +
    +
    +

    + Name: + +

    + +

    + Email: + +

    + +

    + +

    +
    +
    + +<% include ../footer %> diff --git a/examples/route-separation/views/users/edit.jade b/examples/route-separation/views/users/edit.jade deleted file mode 100644 index f9ef180d6db..00000000000 --- a/examples/route-separation/views/users/edit.jade +++ /dev/null @@ -1,12 +0,0 @@ -extends ../layout - -block content - h1 Editing #{user.name} - #user - form(action="?_method=put", method="post") - p Name: - input(type="text", value= user.name, name="user[name]") - p Email: - input(type="text", value= user.email, name="user[email]") - p - input(type="submit", value="Save") diff --git a/examples/route-separation/views/users/index.ejs b/examples/route-separation/views/users/index.ejs new file mode 100644 index 00000000000..0f97fc691c0 --- /dev/null +++ b/examples/route-separation/views/users/index.ejs @@ -0,0 +1,14 @@ +<% include ../header %> + +

    <%= title %>

    + +
    + <% users.forEach(function(user, index) { %> +
  • + <%= user.name %> + edit +
  • + <% }) %> +
    + +<% include ../footer %> diff --git a/examples/route-separation/views/users/index.jade b/examples/route-separation/views/users/index.jade deleted file mode 100644 index c4c54d0cf0d..00000000000 --- a/examples/route-separation/views/users/index.jade +++ /dev/null @@ -1,9 +0,0 @@ -extends ../layout - -block content - h1 Users - #users - for user, i in users - li - a(href="/user/#{i}")= user.name - a.edit(href="/user/#{i}/edit") edit diff --git a/examples/route-separation/views/users/view.ejs b/examples/route-separation/views/users/view.ejs new file mode 100644 index 00000000000..696abc04504 --- /dev/null +++ b/examples/route-separation/views/users/view.ejs @@ -0,0 +1,9 @@ +<% include ../header %> + +

    <%= user.name %>

    + +
    +

    Email: <%= user.email %>

    +
    + +<% include ../footer %> diff --git a/examples/route-separation/views/users/view.jade b/examples/route-separation/views/users/view.jade deleted file mode 100644 index f5af1ae8cc0..00000000000 --- a/examples/route-separation/views/users/view.jade +++ /dev/null @@ -1,6 +0,0 @@ -extends ../layout - -block content - h1= user.name - #user - p Email: #{user.email} From 2189ff14a9ba5ff2109412edd7009fcf5bc802f3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 19 Mar 2017 16:45:58 -0400 Subject: [PATCH 1064/1265] lint: remove trailing new lines from docs --- Contributing.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Contributing.md b/Contributing.md index 214e9070126..41386568d64 100644 --- a/Contributing.md +++ b/Contributing.md @@ -12,7 +12,7 @@ contributors can be involved in decision making. * A **Contributor** is any individual creating or commenting on an issue or pull request. * A **Committer** is a subset of contributors who have been given write access to the repository. -* A **TC (Technical Committee)** is a group of committers representing the required technical +* A **TC (Technical Committee)** is a group of committers representing the required technical expertise to resolve rare disputes. # Logging Issues @@ -36,24 +36,24 @@ pull requests. No pull request can be merged without being reviewed. For non-trivial contributions, pull requests should sit for at least 36 hours to ensure that -contributors in other timezones have time to review. Consideration should also be given to -weekends and other holiday periods to ensure active committers all have reasonable time to +contributors in other timezones have time to review. Consideration should also be given to +weekends and other holiday periods to ensure active committers all have reasonable time to become involved in the discussion and review process if they wish. The default for each contribution is that it is accepted once no committer has an objection. -During review committers may also request that a specific contributor who is most versed in a -particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off" -process for contributions to land. Once all issues brought by committers are addressed it can +During review committers may also request that a specific contributor who is most versed in a +particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off" +process for contributions to land. Once all issues brought by committers are addressed it can be landed by any committer. -In the case of an objection being raised in a pull request by another committer, all involved -committers should seek to arrive at a consensus by way of addressing concerns being expressed +In the case of an objection being raised in a pull request by another committer, all involved +committers should seek to arrive at a consensus by way of addressing concerns being expressed by discussion, compromise on the proposed change, or withdrawal of the proposed change. If a contribution is controversial and committers cannot agree about how to get it to land or if it should land then it should be escalated to the TC. TC members should regularly -discuss pending contributions in order to find a resolution. It is expected that only a -small minority of issues be brought to the TC for resolution and that discussion and +discuss pending contributions in order to find a resolution. It is expected that only a +small minority of issues be brought to the TC for resolution and that discussion and compromise among committers be the default resolution mechanism. # Becoming a Committer @@ -66,20 +66,20 @@ proper review, and have other committers merge their pull requests. # TC Process -The TC uses a "consensus seeking" process for issues that are escalated to the TC. +The TC uses a "consensus seeking" process for issues that are escalated to the TC. The group tries to find a resolution that has no open objections among TC members. If a consensus cannot be reached that has no objections then a majority wins vote -is called. It is also expected that the majority of decisions made by the TC are via +is called. It is also expected that the majority of decisions made by the TC are via a consensus seeking process and that voting is only used as a last-resort. -Resolution may involve returning the issue to committers with suggestions on how to -move forward towards a consensus. It is not expected that a meeting of the TC +Resolution may involve returning the issue to committers with suggestions on how to +move forward towards a consensus. It is not expected that a meeting of the TC will resolve all issues on its agenda during that meeting and may prefer to continue the discussion happening among the committers. Members can be added to the TC at any time. Any committer can nominate another committer to the TC and the TC uses its standard consensus seeking process to evaluate whether or -not to add this new member. Members who do not participate consistently at the level of +not to add this new member. Members who do not participate consistently at the level of a majority of the other members are expected to resign. From efd7032f71f3ef18060a100edc4aa11f4c912dde Mon Sep 17 00:00:00 2001 From: Wes Todd Date: Fri, 24 Feb 2017 09:05:43 -0600 Subject: [PATCH 1065/1265] build: Add .editorconfig closes #3221 --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..cdb36c1b466 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true + +[{*.js,*.json,*.yml}] +indent_size = 2 +indent_style = space From dbf092d3ea5aefd65815ca022ab9e89246cd67b9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Mar 2017 02:10:43 -0400 Subject: [PATCH 1066/1265] deps: vary@~1.1.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index aa32ea6b893..8ecd3970c70 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,8 @@ unreleased * deps: debug@2.6.3 - Fix: `DEBUG_MAX_ARRAY_LENGTH` + * deps: vary@~1.1.1 + - perf: hoist regular expression 4.15.2 / 2017-03-06 =================== diff --git a/package.json b/package.json index dd03d7e9bc5..1bb93d378c1 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "statuses": "~1.3.1", "type-is": "~1.6.14", "utils-merge": "1.0.0", - "vary": "~1.1.0" + "vary": "~1.1.1" }, "devDependencies": { "after": "0.8.2", From 8acaa9a3ea209be604e73477445c991e842ffe9e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Mar 2017 02:12:06 -0400 Subject: [PATCH 1067/1265] deps: finalhandler@~1.0.1 fixes #3252 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 8ecd3970c70..a8647e2484a 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,9 @@ unreleased * deps: debug@2.6.3 - Fix: `DEBUG_MAX_ARRAY_LENGTH` + * deps: finalhandler@~1.0.1 + - Fix missing `` in HTML document + - deps: debug@2.6.3 * deps: vary@~1.1.1 - perf: hoist regular expression diff --git a/package.json b/package.json index 1bb93d378c1..42fd1ca46be 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.8.0", - "finalhandler": "~1.0.0", + "finalhandler": "~1.0.1", "fresh": "0.5.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", From 3763d73a1f6663460b32e600b8fc892075e069c5 Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Wed, 8 Mar 2017 16:31:18 +0000 Subject: [PATCH 1068/1265] examples: replace jade with hbs in mvc example fixes #3181 closes #3185 closes #3243 closes #3245 closes #3249 --- examples/mvc/controllers/user/index.js | 2 ++ examples/mvc/controllers/user/views/edit.hbs | 25 ++++++++++++++++ examples/mvc/controllers/user/views/edit.jade | 11 ------- examples/mvc/controllers/user/views/list.hbs | 16 ++++++++++ examples/mvc/controllers/user/views/list.jade | 7 ----- examples/mvc/controllers/user/views/show.hbs | 29 +++++++++++++++++++ examples/mvc/controllers/user/views/show.jade | 17 ----------- examples/mvc/index.js | 8 ++--- examples/mvc/views/404.ejs | 12 ++++++++ examples/mvc/views/404.jade | 3 -- examples/mvc/views/5xx.ejs | 12 ++++++++ examples/mvc/views/5xx.jade | 3 -- package.json | 2 +- 13 files changed, 100 insertions(+), 47 deletions(-) create mode 100644 examples/mvc/controllers/user/views/edit.hbs delete mode 100644 examples/mvc/controllers/user/views/edit.jade create mode 100644 examples/mvc/controllers/user/views/list.hbs delete mode 100644 examples/mvc/controllers/user/views/list.jade create mode 100644 examples/mvc/controllers/user/views/show.hbs delete mode 100644 examples/mvc/controllers/user/views/show.jade create mode 100644 examples/mvc/views/404.ejs delete mode 100644 examples/mvc/views/404.jade create mode 100644 examples/mvc/views/5xx.ejs delete mode 100644 examples/mvc/views/5xx.jade diff --git a/examples/mvc/controllers/user/index.js b/examples/mvc/controllers/user/index.js index 9ccbcccb9ca..a7b0208c8e7 100644 --- a/examples/mvc/controllers/user/index.js +++ b/examples/mvc/controllers/user/index.js @@ -4,6 +4,8 @@ var db = require('../../db'); +exports.engine = 'hbs'; + exports.before = function(req, res, next){ var id = req.params.user_id; if (!id) return next(); diff --git a/examples/mvc/controllers/user/views/edit.hbs b/examples/mvc/controllers/user/views/edit.hbs new file mode 100644 index 00000000000..d356f5ee7f3 --- /dev/null +++ b/examples/mvc/controllers/user/views/edit.hbs @@ -0,0 +1,25 @@ + + + + + Edit {{user.name}} + + +

    {{user.name}}

    +
    + + + +
    + +
    + + + +
    + + diff --git a/examples/mvc/controllers/user/views/edit.jade b/examples/mvc/controllers/user/views/edit.jade deleted file mode 100644 index a2fde5d477e..00000000000 --- a/examples/mvc/controllers/user/views/edit.jade +++ /dev/null @@ -1,11 +0,0 @@ -link(rel='stylesheet', href='/style.css') -h1= user.name -form(action='/user/#{user.id}?_method=put', method='post') - label= 'Name: ' - input(type='text', name='user[name]', value='#{user.name}') - input(type='submit', value='Update') - -form(action='/user/#{user.id}/pet', method='post') - label= 'Pet: ' - input(type='text', name='pet[name]', placeholder='Name') - input(type='submit', value='Add') diff --git a/examples/mvc/controllers/user/views/list.hbs b/examples/mvc/controllers/user/views/list.hbs new file mode 100644 index 00000000000..191867de3ff --- /dev/null +++ b/examples/mvc/controllers/user/views/list.hbs @@ -0,0 +1,16 @@ + + + + + Users + + +

    Users

    +

    Click a user below to view their pets.

    +
      + {{#each users}} +
    • {{name}}
    • + {{/each}} +
    + + diff --git a/examples/mvc/controllers/user/views/list.jade b/examples/mvc/controllers/user/views/list.jade deleted file mode 100644 index af8933cfe05..00000000000 --- a/examples/mvc/controllers/user/views/list.jade +++ /dev/null @@ -1,7 +0,0 @@ -link(rel='stylesheet', href='/style.css') -h1 Users -p Click a user below to view their pets. -ul - each user in users - li - a(href='/user/#{user.id}')= user.name diff --git a/examples/mvc/controllers/user/views/show.hbs b/examples/mvc/controllers/user/views/show.hbs new file mode 100644 index 00000000000..f064cf54f1f --- /dev/null +++ b/examples/mvc/controllers/user/views/show.hbs @@ -0,0 +1,29 @@ + + + + + {{user.name}} + + +

    {{user.name}} edit

    + +{{#if hasMessages}} +
      + {{#each messages}} +
    • {{this}}
    • + {{/each}} +
    +{{/if}} + +{{#if user.pets.length}} +

    View {{user.name}}'s pets:

    +
      + {{#each user.pets}} +
    • {{name}}
    • + {{/each}} +
    +{{else}} +

    No pets!

    +{{/if}} + + diff --git a/examples/mvc/controllers/user/views/show.jade b/examples/mvc/controllers/user/views/show.jade deleted file mode 100644 index 267d3ef7e40..00000000000 --- a/examples/mvc/controllers/user/views/show.jade +++ /dev/null @@ -1,17 +0,0 @@ -link(rel='stylesheet', href='/style.css') -h1= user.name + ' ' - a(href='/user/#{user.id}/edit') edit - -if (hasMessages) - ul#messages - each msg in messages - li= msg - -if (user.pets.length) - p View #{user.name}'s pets: - ul - each pet in user.pets - li - a(href='/pet/#{pet.id}')= pet.name -else - p No pets! diff --git a/examples/mvc/index.js b/examples/mvc/index.js index c5e2678697a..0d5624b63d3 100644 --- a/examples/mvc/index.js +++ b/examples/mvc/index.js @@ -11,11 +11,9 @@ var methodOverride = require('method-override'); var app = module.exports = express(); -// settings - -// set our default template engine to "jade" -// which prevents the need for extensions -app.set('view engine', 'jade'); +// set our default template engine to "ejs" +// which prevents the need for using file extensions +app.set('view engine', 'ejs'); // set views for error and 404 pages app.set('views', path.join(__dirname, 'views')); diff --git a/examples/mvc/views/404.ejs b/examples/mvc/views/404.ejs new file mode 100644 index 00000000000..18d7e4afe3a --- /dev/null +++ b/examples/mvc/views/404.ejs @@ -0,0 +1,12 @@ + + + + + Not Found + + + +

    404: Not Found

    +

    Sorry we can't find <%= url %>

    + + diff --git a/examples/mvc/views/404.jade b/examples/mvc/views/404.jade deleted file mode 100644 index 110c471f1b9..00000000000 --- a/examples/mvc/views/404.jade +++ /dev/null @@ -1,3 +0,0 @@ -link(rel='stylesheet', href='/style.css') -h1 404: Not Found -p Sorry we can't find #{url} diff --git a/examples/mvc/views/5xx.ejs b/examples/mvc/views/5xx.ejs new file mode 100644 index 00000000000..ea0f246ddfd --- /dev/null +++ b/examples/mvc/views/5xx.ejs @@ -0,0 +1,12 @@ + + + + + Internal Server Error + + + +

    500: Internal Server Error

    +

    Looks like something blew up!

    + + diff --git a/examples/mvc/views/5xx.jade b/examples/mvc/views/5xx.jade deleted file mode 100644 index 3508b7c0e2a..00000000000 --- a/examples/mvc/views/5xx.jade +++ /dev/null @@ -1,3 +0,0 @@ -link(rel='stylesheet', href='/style.css') -h1 500: Internal Server Error -p Looks like something blew up! diff --git a/package.json b/package.json index 42fd1ca46be..8c1d415f212 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "cookie-parser": "~1.4.3", "ejs": "2.5.6", "express-session": "1.15.1", + "hbs": "4.0.1", "istanbul": "0.4.5", "marked": "0.3.6", "method-override": "2.3.7", @@ -73,7 +74,6 @@ "supertest": "1.2.0", "connect-redis": "~2.4.1", "cookie-session": "~1.2.0", - "jade": "~1.11.0", "vhost": "~3.0.2" }, "engines": { From aabf7802a979f44cf75ffac2978724935d064fec Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Fri, 24 Mar 2017 08:53:03 +0000 Subject: [PATCH 1069/1265] docs: fix the security issues heading format closes #3256 --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 7b261a3d94d..786756a1cd2 100644 --- a/Readme.md +++ b/Readme.md @@ -46,7 +46,7 @@ $ npm install express **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x). -###Security Issues +### Security Issues If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md). From 347d4db3cac2979d639cb2be161ba01c9b2336d2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 28 Mar 2017 22:56:32 -0400 Subject: [PATCH 1070/1265] deps: proxy-addr@~1.1.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a8647e2484a..8e80d0e5ee7 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,8 @@ unreleased * deps: finalhandler@~1.0.1 - Fix missing `` in HTML document - deps: debug@2.6.3 + * deps: proxy-addr@~1.1.4 + - deps: ipaddr.js@1.3.0 * deps: vary@~1.1.1 - perf: hoist regular expression diff --git a/package.json b/package.json index 8c1d415f212..940c58d1bef 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", - "proxy-addr": "~1.1.3", + "proxy-addr": "~1.1.4", "qs": "6.4.0", "range-parser": "~1.2.0", "send": "0.15.1", From c087a45b9cc3eb69c777e260ee880758b6e03a40 Mon Sep 17 00:00:00 2001 From: asaf david Date: Fri, 31 Mar 2017 15:57:28 +0300 Subject: [PATCH 1071/1265] Fix typo in variable name setPrototypeOf closes #3266 --- lib/application.js | 14 +++++++------- lib/middleware/init.js | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/application.js b/lib/application.js index 21a81ee9efe..1abe8d08f58 100644 --- a/lib/application.js +++ b/lib/application.js @@ -28,7 +28,7 @@ var deprecate = require('depd')('express'); var flatten = require('array-flatten'); var merge = require('utils-merge'); var resolve = require('path').resolve; -var setPrototyeOf = require('setprototypeof') +var setPrototypeOf = require('setprototypeof') var slice = Array.prototype.slice; /** @@ -95,10 +95,10 @@ app.defaultConfiguration = function defaultConfiguration() { } // inherit protos - setPrototyeOf(this.request, parent.request) - setPrototyeOf(this.response, parent.response) - setPrototyeOf(this.engines, parent.engines) - setPrototyeOf(this.settings, parent.settings) + setPrototypeOf(this.request, parent.request) + setPrototypeOf(this.response, parent.response) + setPrototypeOf(this.engines, parent.engines) + setPrototypeOf(this.settings, parent.settings) }); // setup locals @@ -228,8 +228,8 @@ app.use = function use(fn) { router.use(path, function mounted_app(req, res, next) { var orig = req.app; fn.handle(req, res, function (err) { - setPrototyeOf(req, orig.request) - setPrototyeOf(res, orig.response) + setPrototypeOf(req, orig.request) + setPrototypeOf(res, orig.response) next(err); }); }); diff --git a/lib/middleware/init.js b/lib/middleware/init.js index 328c4a863d9..dfd042747bd 100644 --- a/lib/middleware/init.js +++ b/lib/middleware/init.js @@ -13,7 +13,7 @@ * @private */ -var setPrototyeOf = require('setprototypeof') +var setPrototypeOf = require('setprototypeof') /** * Initialization middleware, exposing the @@ -32,8 +32,8 @@ exports.init = function(app){ res.req = req; req.next = next; - setPrototyeOf(req, app.request) - setPrototyeOf(res, app.response) + setPrototypeOf(req, app.request) + setPrototypeOf(res, app.response) res.locals = res.locals || Object.create(null); From df4f2719db909ab333d8173f57a96bc213680c2a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 26 Apr 2017 23:49:41 -0400 Subject: [PATCH 1072/1265] deps: type-is@~1.6.15 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 8e80d0e5ee7..336e7428c91 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ unreleased - deps: debug@2.6.3 * deps: proxy-addr@~1.1.4 - deps: ipaddr.js@1.3.0 + * deps: type-is@~1.6.15 + - deps: mime-types@~2.1.15 * deps: vary@~1.1.1 - perf: hoist regular expression diff --git a/package.json b/package.json index 940c58d1bef..3ce5dc3cbc2 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "serve-static": "1.12.1", "setprototypeof": "1.0.3", "statuses": "~1.3.1", - "type-is": "~1.6.14", + "type-is": "~1.6.15", "utils-merge": "1.0.0", "vary": "~1.1.1" }, From 2d1dade36a867dcd68a2169270d524d73a3b92eb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 27 Apr 2017 00:00:57 -0400 Subject: [PATCH 1073/1265] deps: serve-static@1.12.2 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 336e7428c91..f6bd295727a 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ unreleased - deps: debug@2.6.3 * deps: proxy-addr@~1.1.4 - deps: ipaddr.js@1.3.0 + * deps: serve-static@1.12.2 + - deps: send@0.15.2 * deps: type-is@~1.6.15 - deps: mime-types@~2.1.15 * deps: vary@~1.1.1 diff --git a/package.json b/package.json index 3ce5dc3cbc2..9dcc7266c73 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "qs": "6.4.0", "range-parser": "~1.2.0", "send": "0.15.1", - "serve-static": "1.12.1", + "serve-static": "1.12.2", "setprototypeof": "1.0.3", "statuses": "~1.3.1", "type-is": "~1.6.15", From 1b6e7004b7e46a7c9fd3f53cd408debbcb689367 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 27 Apr 2017 01:11:58 -0400 Subject: [PATCH 1074/1265] deps: send@0.15.2 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f6bd295727a..10b15b2b6a0 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,9 @@ unreleased - deps: debug@2.6.3 * deps: proxy-addr@~1.1.4 - deps: ipaddr.js@1.3.0 + * deps: send@0.15.2 + - deps: debug@2.6.4 + - deps: ms@1.0.0 * deps: serve-static@1.12.2 - deps: send@0.15.2 * deps: type-is@~1.6.15 diff --git a/package.json b/package.json index 9dcc7266c73..1fbff92544f 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "proxy-addr": "~1.1.4", "qs": "6.4.0", "range-parser": "~1.2.0", - "send": "0.15.1", + "send": "0.15.2", "serve-static": "1.12.2", "setprototypeof": "1.0.3", "statuses": "~1.3.1", From a13938eed7b67ce13b86a45c7b0f2ae766a3166d Mon Sep 17 00:00:00 2001 From: Colin Richardson Date: Thu, 27 Apr 2017 19:51:38 +0100 Subject: [PATCH 1075/1265] tests: add tests for res.location('back') closes #3292 closes #3293 --- test/res.location.js | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/test/res.location.js b/test/res.location.js index bb9eb6f92e3..c0bfbe8c8ec 100644 --- a/test/res.location.js +++ b/test/res.location.js @@ -42,5 +42,63 @@ describe('res', function(){ .expect('Location', 'https://google.com?q=%A710') .expect(200, done) }) + + describe('when url is "back"', function () { + it('should set location from "Referer" header', function (done) { + var app = express() + + app.use(function (req, res) { + res.location('back').end() + }) + + request(app) + .get('/') + .set('Referer', '/some/page.html') + .expect('Location', '/some/page.html') + .expect(200, done) + }) + + it('should set location from "Referrer" header', function (done) { + var app = express() + + app.use(function (req, res) { + res.location('back').end() + }) + + request(app) + .get('/') + .set('Referrer', '/some/page.html') + .expect('Location', '/some/page.html') + .expect(200, done) + }) + + it('should prefer "Referrer" header', function (done) { + var app = express() + + app.use(function (req, res) { + res.location('back').end() + }) + + request(app) + .get('/') + .set('Referer', '/some/page1.html') + .set('Referrer', '/some/page2.html') + .expect('Location', '/some/page2.html') + .expect(200, done) + }) + + it('should set the header to "/" without referrer', function (done) { + var app = express() + + app.use(function (req, res) { + res.location('back').end() + }) + + request(app) + .get('/') + .expect('Location', '/') + .expect(200, done) + }) + }) }) }) From de41c0bfa4fc9ff78fb5f0f72daf5e83e53a93ae Mon Sep 17 00:00:00 2001 From: Tony Anisimov Date: Tue, 9 May 2017 23:35:20 +0300 Subject: [PATCH 1076/1265] Fix res.cookie jsdoc comment closes #3304 --- lib/response.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/response.js b/lib/response.js index 6aefe1b1782..f3f043f5cd6 100644 --- a/lib/response.js +++ b/lib/response.js @@ -777,7 +777,7 @@ res.clearCookie = function clearCookie(name, options) { * * @param {String} name * @param {String|Object} value - * @param {Options} options + * @param {Object} [options] * @return {ServerResponse} for chaining * @public */ From 5ea2a8ff8e78349484d2887db2f10a94ec79b8d7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 14 May 2017 23:29:13 -0400 Subject: [PATCH 1077/1265] build: Node.js@7.9 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1230c7e2f95..b4beea77f36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ node_js: - "4.8" - "5.12" - "6.10" - - "7.6" + - "7.9" matrix: include: - node_js: "8.0" diff --git a/appveyor.yml b/appveyor.yml index b4bb184dd8f..cd4f9d23e5e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ environment: - nodejs_version: "4.8" - nodejs_version: "5.12" - nodejs_version: "6.10" - - nodejs_version: "7.6" + - nodejs_version: "7.9" cache: - node_modules install: From ae0b630ac7e8f34e4ea37285f30db4b52adf8436 Mon Sep 17 00:00:00 2001 From: Oz Michaeli Date: Wed, 10 May 2017 16:23:55 -0400 Subject: [PATCH 1078/1265] Fix error when res.set cannot add charset to Content-Type fixes #3303 closes #3305 closes #3307 --- History.md | 1 + lib/response.js | 11 ++++++++--- test/res.set.js | 13 +++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 10b15b2b6a0..cbf13eb837e 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix error when `res.set` cannot add charset to `Content-Type` * deps: debug@2.6.3 - Fix: `DEBUG_MAX_ARRAY_LENGTH` * deps: finalhandler@~1.0.1 diff --git a/lib/response.js b/lib/response.js index f3f043f5cd6..b852a60e2f5 100644 --- a/lib/response.js +++ b/lib/response.js @@ -717,9 +717,14 @@ res.header = function header(field, val) { : String(val); // add charset to content-type - if (field.toLowerCase() === 'content-type' && !charsetRegExp.test(value)) { - var charset = mime.charsets.lookup(value.split(';')[0]); - if (charset) value += '; charset=' + charset.toLowerCase(); + if (field.toLowerCase() === 'content-type') { + if (Array.isArray(value)) { + throw new TypeError('Content-Type cannot be set to an Array'); + } + if (!charsetRegExp.test(value)) { + var charset = mime.charsets.lookup(value.split(';')[0]); + if (charset) value += '; charset=' + charset.toLowerCase(); + } } this.setHeader(field, value); diff --git a/test/res.set.js b/test/res.set.js index b15bc5d7e3d..e46d123947a 100644 --- a/test/res.set.js +++ b/test/res.set.js @@ -73,6 +73,19 @@ describe('res', function(){ .expect('Content-Type', 'text/html; charset=lol') .expect(200, done); }) + + it('should throw when Content-Type is an array', function (done) { + var app = express() + + app.use(function (req, res) { + res.set('Content-Type', ['text/html']) + res.end() + }); + + request(app) + .get('/') + .expect(500, /TypeError: Content-Type cannot be set to an Array/, done) + }) }) describe('.set(object)', function(){ From 1ba9a9ac23e48cc7295a53919953e1b3f0b0ea7f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 May 2017 01:28:21 -0400 Subject: [PATCH 1079/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1fbff92544f..67a20144c35 100644 --- a/package.json +++ b/package.json @@ -61,11 +61,11 @@ "body-parser": "1.17.1", "cookie-parser": "~1.4.3", "ejs": "2.5.6", - "express-session": "1.15.1", + "express-session": "1.15.2", "hbs": "4.0.1", "istanbul": "0.4.5", "marked": "0.3.6", - "method-override": "2.3.7", + "method-override": "2.3.8", "mocha": "3.2.0", "morgan": "1.8.1", "multiparty": "4.1.3", From ad4456c491fc2ecd8358fd3958da5c0a95c2c3ab Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 May 2017 01:46:34 -0400 Subject: [PATCH 1080/1265] deps: send@0.15.3 --- History.md | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index cbf13eb837e..b62e24b6e6b 100644 --- a/History.md +++ b/History.md @@ -9,9 +9,9 @@ unreleased - deps: debug@2.6.3 * deps: proxy-addr@~1.1.4 - deps: ipaddr.js@1.3.0 - * deps: send@0.15.2 - - deps: debug@2.6.4 - - deps: ms@1.0.0 + * deps: send@0.15.3 + - deps: debug@2.6.7 + - deps: ms@2.0.0 * deps: serve-static@1.12.2 - deps: send@0.15.2 * deps: type-is@~1.6.15 diff --git a/package.json b/package.json index 67a20144c35..6e2c5995c8d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "proxy-addr": "~1.1.4", "qs": "6.4.0", "range-parser": "~1.2.0", - "send": "0.15.2", + "send": "0.15.3", "serve-static": "1.12.2", "setprototypeof": "1.0.3", "statuses": "~1.3.1", From 58cfc9911b5f1e67397ba481535320a1c3b9e954 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 May 2017 01:47:17 -0400 Subject: [PATCH 1081/1265] deps: serve-static@1.12.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index b62e24b6e6b..0ebb6ea31a2 100644 --- a/History.md +++ b/History.md @@ -12,8 +12,8 @@ unreleased * deps: send@0.15.3 - deps: debug@2.6.7 - deps: ms@2.0.0 - * deps: serve-static@1.12.2 - - deps: send@0.15.2 + * deps: serve-static@1.12.3 + - deps: send@0.15.3 * deps: type-is@~1.6.15 - deps: mime-types@~2.1.15 * deps: vary@~1.1.1 diff --git a/package.json b/package.json index 6e2c5995c8d..d9f003e8531 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "qs": "6.4.0", "range-parser": "~1.2.0", "send": "0.15.3", - "serve-static": "1.12.2", + "serve-static": "1.12.3", "setprototypeof": "1.0.3", "statuses": "~1.3.1", "type-is": "~1.6.15", From bc2986fe59c233ac58d981e620fddd4c58b55c9b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 May 2017 01:56:36 -0400 Subject: [PATCH 1082/1265] deps: finalhandler@~1.0.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 0ebb6ea31a2..4ca0255a6cd 100644 --- a/History.md +++ b/History.md @@ -4,9 +4,9 @@ unreleased * Fix error when `res.set` cannot add charset to `Content-Type` * deps: debug@2.6.3 - Fix: `DEBUG_MAX_ARRAY_LENGTH` - * deps: finalhandler@~1.0.1 + * deps: finalhandler@~1.0.3 - Fix missing `` in HTML document - - deps: debug@2.6.3 + - deps: debug@2.6.7 * deps: proxy-addr@~1.1.4 - deps: ipaddr.js@1.3.0 * deps: send@0.15.3 diff --git a/package.json b/package.json index d9f003e8531..f469ca5a713 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.8.0", - "finalhandler": "~1.0.1", + "finalhandler": "~1.0.3", "fresh": "0.5.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", From 65494692c2d83bb99586166afe463ba1177dbbdb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 May 2017 01:57:31 -0400 Subject: [PATCH 1083/1265] build: mocha@3.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f469ca5a713..ac2f32d6796 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "istanbul": "0.4.5", "marked": "0.3.6", "method-override": "2.3.8", - "mocha": "3.2.0", + "mocha": "3.4.1", "morgan": "1.8.1", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", From 5cf473dc5d51c66a0cd373f4eca469505dfa4f32 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 May 2017 02:08:50 -0400 Subject: [PATCH 1084/1265] deps: debug@2.6.7 --- History.md | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 4ca0255a6cd..2222778710b 100644 --- a/History.md +++ b/History.md @@ -2,8 +2,9 @@ unreleased ========== * Fix error when `res.set` cannot add charset to `Content-Type` - * deps: debug@2.6.3 - - Fix: `DEBUG_MAX_ARRAY_LENGTH` + * deps: debug@2.6.7 + - Fix `DEBUG_MAX_ARRAY_LENGTH` + - deps: ms@2.0.0 * deps: finalhandler@~1.0.3 - Fix missing `` in HTML document - deps: debug@2.6.7 diff --git a/package.json b/package.json index ac2f32d6796..4acb1ff2e58 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "content-type": "~1.0.2", "cookie": "0.3.1", "cookie-signature": "1.0.6", - "debug": "2.6.3", + "debug": "2.6.7", "depd": "~1.1.0", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", From 6da454c7fb37e68ed65ffe0371aa688b89f5bd6e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 May 2017 02:14:11 -0400 Subject: [PATCH 1085/1265] 4.15.3 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 2222778710b..83b439c63e8 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.15.3 / 2017-05-16 +=================== * Fix error when `res.set` cannot add charset to `Content-Type` * deps: debug@2.6.7 diff --git a/package.json b/package.json index 4acb1ff2e58..98adaea686a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.15.2", + "version": "4.15.3", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From fde8f647d368df1dc62d55ce4d68370ef3eb0a49 Mon Sep 17 00:00:00 2001 From: Owen Luke Date: Wed, 17 May 2017 16:00:49 +0800 Subject: [PATCH 1086/1265] examples: fix route in params example closes #3310 --- examples/params/index.js | 2 +- test/acceptance/params.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/params/index.js b/examples/params/index.js index d70f0beeeb1..f918b5fd30d 100644 --- a/examples/params/index.js +++ b/examples/params/index.js @@ -68,7 +68,7 @@ app.get('/users/:from-:to', function(req, res, next){ var from = req.params.from; var to = req.params.to; var names = users.map(function(user){ return user.name; }); - res.send('users ' + names.slice(from, to).join(', ')); + res.send('users ' + names.slice(from, to + 1).join(', ')); }); /* istanbul ignore next */ diff --git a/test/acceptance/params.js b/test/acceptance/params.js index 56b7a72ce0f..e7c30cf7732 100644 --- a/test/acceptance/params.js +++ b/test/acceptance/params.js @@ -29,8 +29,8 @@ describe('params', function(){ describe('GET /users/0-2', function(){ it('should respond with three users', function(done){ request(app) - .get('/users/0-2') - .expect(/users tj, tobi/,done) + .get('/users/0-2') + .expect(/users tj, tobi, loki/, done) }) }) From 60f87f8074c28a1727305530058d8c2c9596387c Mon Sep 17 00:00:00 2001 From: Owen Luke Date: Wed, 17 May 2017 17:04:10 +0800 Subject: [PATCH 1087/1265] examples: fix posts link in route-separation example closes #3310 --- examples/route-separation/views/index.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/route-separation/views/index.ejs b/examples/route-separation/views/index.ejs index 6d1afb4ac3d..2a0b095fa36 100644 --- a/examples/route-separation/views/index.ejs +++ b/examples/route-separation/views/index.ejs @@ -4,7 +4,7 @@ <% include footer %> From cf37240e7306c5085f3d2a232a4649279d020667 Mon Sep 17 00:00:00 2001 From: Owen Luke Date: Wed, 17 May 2017 17:10:38 +0800 Subject: [PATCH 1088/1265] examples: fix reference error in view-constructor closes #3310 --- examples/view-constructor/github-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/view-constructor/github-view.js b/examples/view-constructor/github-view.js index 53890291056..0a98a908434 100644 --- a/examples/view-constructor/github-view.js +++ b/examples/view-constructor/github-view.js @@ -2,7 +2,7 @@ * Module dependencies. */ -var http = require('http'); +var https = require('https'); var path = require('path'); var extname = path.extname; From 9f019c8c6966736803a65eb4a96d0e7e87e85ede Mon Sep 17 00:00:00 2001 From: Owen Luke Date: Wed, 17 May 2017 23:55:27 +0800 Subject: [PATCH 1089/1265] examples: add comment about Redis install in examples closes #3310 --- examples/online/index.js | 6 +++++- examples/search/index.js | 6 +++++- examples/session/index.js | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/online/index.js b/examples/online/index.js index 5cdaa6ca8d2..f14474c08d3 100644 --- a/examples/online/index.js +++ b/examples/online/index.js @@ -1,4 +1,8 @@ -// first: + +// install redis first: +// https://redis.io/ + +// then: // $ npm install redis online // $ redis-server diff --git a/examples/search/index.js b/examples/search/index.js index 79f5d9f4d36..246993caa5a 100644 --- a/examples/search/index.js +++ b/examples/search/index.js @@ -1,4 +1,8 @@ -// first: + +// install redis first: +// https://redis.io/ + +// then: // $ npm install redis // $ redis-server diff --git a/examples/session/index.js b/examples/session/index.js index de41a77d2c0..9bae48b8d33 100644 --- a/examples/session/index.js +++ b/examples/session/index.js @@ -1,4 +1,8 @@ -// first: + +// install redis first: +// https://redis.io/ + +// then: // $ npm install redis // $ redis-server From 9467a392e33ad1575f2d76aad5fc19f9290d6cd6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jun 2017 19:09:25 -0400 Subject: [PATCH 1090/1265] build: Node.js@7.10 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b4beea77f36..c9172c302ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ node_js: - "4.8" - "5.12" - "6.10" - - "7.9" + - "7.10" matrix: include: - node_js: "8.0" diff --git a/appveyor.yml b/appveyor.yml index cd4f9d23e5e..9fbc9d39a38 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ environment: - nodejs_version: "4.8" - nodejs_version: "5.12" - nodejs_version: "6.10" - - nodejs_version: "7.9" + - nodejs_version: "7.10" cache: - node_modules install: From 48777dc37774eaa2c328a1d9bb9541dfa47ca90f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 4 Jun 2017 19:12:30 -0400 Subject: [PATCH 1091/1265] build: mocha@3.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98adaea686a..1788e9ffd16 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "istanbul": "0.4.5", "marked": "0.3.6", "method-override": "2.3.8", - "mocha": "3.4.1", + "mocha": "3.4.2", "morgan": "1.8.1", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", From deffce5704913df9e6b00aca5536345610222417 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 30 Jun 2017 23:47:12 -0400 Subject: [PATCH 1092/1265] deps: qs@6.5.0 --- History.md | 5 +++++ lib/middleware/query.js | 3 ++- package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 83b439c63e8..36fadc4b990 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * deps: qs@6.5.0 + 4.15.3 / 2017-05-16 =================== diff --git a/lib/middleware/query.js b/lib/middleware/query.js index 5f76f8458f0..7e9166947af 100644 --- a/lib/middleware/query.js +++ b/lib/middleware/query.js @@ -12,6 +12,7 @@ * Module dependencies. */ +var merge = require('utils-merge') var parseUrl = require('parseurl'); var qs = require('qs'); @@ -22,7 +23,7 @@ var qs = require('qs'); */ module.exports = function query(options) { - var opts = Object.create(options || null); + var opts = merge({}, options) var queryparse = qs.parse; if (typeof options === 'function') { diff --git a/package.json b/package.json index 1788e9ffd16..cb37b98a7f5 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", "proxy-addr": "~1.1.4", - "qs": "6.4.0", + "qs": "6.5.0", "range-parser": "~1.2.0", "send": "0.15.3", "serve-static": "1.12.3", From bd5951e603c16c1db779a76bc5e500c243f96cf8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 30 Jun 2017 23:51:18 -0400 Subject: [PATCH 1093/1265] deps: debug@2.6.8 closes #3286 closes #3337 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 36fadc4b990..59663eb712d 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * deps: debug@2.6.8 * deps: qs@6.5.0 4.15.3 / 2017-05-16 diff --git a/package.json b/package.json index cb37b98a7f5..674c8601ab0 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "content-type": "~1.0.2", "cookie": "0.3.1", "cookie-signature": "1.0.6", - "debug": "2.6.7", + "debug": "2.6.8", "depd": "~1.1.0", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", From 1adee79e636400c734f2307c1ef4fb0fff5db92b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 30 Jun 2017 23:58:01 -0400 Subject: [PATCH 1094/1265] deps: update example dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 674c8601ab0..7f401132cae 100644 --- a/package.json +++ b/package.json @@ -58,16 +58,16 @@ }, "devDependencies": { "after": "0.8.2", - "body-parser": "1.17.1", + "body-parser": "1.17.2", "cookie-parser": "~1.4.3", "ejs": "2.5.6", - "express-session": "1.15.2", + "express-session": "1.15.3", "hbs": "4.0.1", "istanbul": "0.4.5", "marked": "0.3.6", - "method-override": "2.3.8", + "method-override": "2.3.9", "mocha": "3.4.2", - "morgan": "1.8.1", + "morgan": "1.8.2", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", "should": "11.2.1", From 04beebb2c087e3b9795d6f1c3d0bd1112bf1f244 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 26 Jul 2017 11:52:42 -0400 Subject: [PATCH 1095/1265] build: Node.js@6.11 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9172c302ca..3e899dd2351 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ node_js: - "3.3" - "4.8" - "5.12" - - "6.10" + - "6.11" - "7.10" matrix: include: diff --git a/appveyor.yml b/appveyor.yml index 9fbc9d39a38..ed8d4aa9f05 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ environment: - nodejs_version: "3.3" - nodejs_version: "4.8" - nodejs_version: "5.12" - - nodejs_version: "6.10" + - nodejs_version: "6.11" - nodejs_version: "7.10" cache: - node_modules From 43dff4ceb3446397aa3fe8c48b2de67b9e76a031 Mon Sep 17 00:00:00 2001 From: Piper Chester Date: Tue, 27 Jun 2017 11:48:08 +0200 Subject: [PATCH 1096/1265] docs: fix GitHub capitalization closes #3353 --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 786756a1cd2..17326615776 100644 --- a/Readme.md +++ b/Readme.md @@ -39,7 +39,7 @@ $ npm install express * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)] * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC - * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules + * [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules * Visit the [Wiki](https://github.com/expressjs/express/wiki) * [Google Group](https://groups.google.com/group/express-js) for discussion * [Gitter](https://gitter.im/expressjs/express) for support and discussion From 5e16f400f17ca4bac48226446b09299e392db3b2 Mon Sep 17 00:00:00 2001 From: Owen Luke Date: Fri, 19 May 2017 00:18:28 +0800 Subject: [PATCH 1097/1265] examples: use 1-based visitor count in cookie-sessions closes #3312 --- examples/cookie-sessions/index.js | 5 ++--- test/acceptance/cookie-sessions.js | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/cookie-sessions/index.js b/examples/cookie-sessions/index.js index 73653f63af9..1dda15de612 100644 --- a/examples/cookie-sessions/index.js +++ b/examples/cookie-sessions/index.js @@ -15,9 +15,8 @@ app.use(count); // custom middleware function count(req, res) { - req.session.count = req.session.count || 0; - var n = req.session.count++; - res.send('viewed ' + n + ' times\n'); + req.session.count = (req.session.count || 0) + 1 + res.send('viewed ' + req.session.count + ' times\n') } /* istanbul ignore next */ diff --git a/test/acceptance/cookie-sessions.js b/test/acceptance/cookie-sessions.js index 611ebe462a2..d438cfe6d5d 100644 --- a/test/acceptance/cookie-sessions.js +++ b/test/acceptance/cookie-sessions.js @@ -7,7 +7,7 @@ describe('cookie-sessions', function () { it('should display no views', function (done) { request(app) .get('/') - .expect(200, 'viewed 0 times\n', done) + .expect(200, 'viewed 1 times\n', done) }) it('should set a session cookie', function (done) { @@ -20,12 +20,12 @@ describe('cookie-sessions', function () { it('should display 1 view on revisit', function (done) { request(app) .get('/') - .expect(200, 'viewed 0 times\n', function (err, res) { + .expect(200, 'viewed 1 times\n', function (err, res) { if (err) return done(err) request(app) .get('/') .set('Cookie', getCookies(res)) - .expect(200, 'viewed 1 times\n', done) + .expect(200, 'viewed 2 times\n', done) }) }) }) From 582381bcebf2a2344e7e054eed9606cc2221dd97 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 26 Jul 2017 13:09:46 -0400 Subject: [PATCH 1098/1265] deps: proxy-addr@~1.1.5 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 59663eb712d..a724e84231f 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,9 @@ unreleased ========== * deps: debug@2.6.8 + * deps: proxy-addr@~1.1.5 + - Fix array argument being altered + - deps: ipaddr.js@1.4.0 * deps: qs@6.5.0 4.15.3 / 2017-05-16 diff --git a/package.json b/package.json index 7f401132cae..daf1f1feb1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", - "proxy-addr": "~1.1.4", + "proxy-addr": "~1.1.5", "qs": "6.5.0", "range-parser": "~1.2.0", "send": "0.15.3", From 3eb16c233c5bf76fb12558101565971372693c73 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 2 Aug 2017 23:30:47 -0400 Subject: [PATCH 1099/1265] deps: depd@~1.1.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a724e84231f..af2bcfb384c 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,8 @@ unreleased ========== * deps: debug@2.6.8 + * deps: depd@~1.1.1 + - Remove unnecessary `Buffer` loading * deps: proxy-addr@~1.1.5 - Fix array argument being altered - deps: ipaddr.js@1.4.0 diff --git a/package.json b/package.json index daf1f1feb1f..0a3848134fd 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "cookie": "0.3.1", "cookie-signature": "1.0.6", "debug": "2.6.8", - "depd": "~1.1.0", + "depd": "~1.1.1", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.8.0", From b2af1018215540964390aab0c739c1e688865122 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 2 Aug 2017 23:32:44 -0400 Subject: [PATCH 1100/1265] build: ejs@2.5.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a3848134fd..c14b8126b11 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "after": "0.8.2", "body-parser": "1.17.2", "cookie-parser": "~1.4.3", - "ejs": "2.5.6", + "ejs": "2.5.7", "express-session": "1.15.3", "hbs": "4.0.1", "istanbul": "0.4.5", From daf66beda49ebac6086b81dd1896a34395306a71 Mon Sep 17 00:00:00 2001 From: Hung HOANG Date: Thu, 3 Aug 2017 11:33:29 +0200 Subject: [PATCH 1101/1265] examples: fix path join in ejs example fixes #3382 closes #3383 closes #3385 --- examples/ejs/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ejs/index.js b/examples/ejs/index.js index b868bdd7cb9..72780912938 100644 --- a/examples/ejs/index.js +++ b/examples/ejs/index.js @@ -26,7 +26,7 @@ app.set('views', path.join(__dirname, 'views')); // Path to our public directory -app.use(express.static(path.join(__dirname + 'public'))); +app.use(express.static(path.join(__dirname, 'public'))); // Without this you would need to // supply the extension to res.render() From 85770a71fc3f3c7f3a1efe3e01d9f0c5fd68f82e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Aug 2017 00:25:59 -0400 Subject: [PATCH 1102/1265] deps: finalhandler@~1.0.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index af2bcfb384c..c67fd941745 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,8 @@ unreleased * deps: debug@2.6.8 * deps: depd@~1.1.1 - Remove unnecessary `Buffer` loading + * deps: finalhandler@~1.0.4 + - deps: debug@2.6.8 * deps: proxy-addr@~1.1.5 - Fix array argument being altered - deps: ipaddr.js@1.4.0 diff --git a/package.json b/package.json index c14b8126b11..839f370cbcb 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.8.0", - "finalhandler": "~1.0.3", + "finalhandler": "~1.0.4", "fresh": "0.5.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", From e0aa8bf74eed76df4e5cf02005233d9de2401348 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Aug 2017 00:26:50 -0400 Subject: [PATCH 1103/1265] build: mocha@3.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 839f370cbcb..15e80f1934b 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "istanbul": "0.4.5", "marked": "0.3.6", "method-override": "2.3.9", - "mocha": "3.4.2", + "mocha": "3.5.0", "morgan": "1.8.2", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", From 713d2aed93586a7c11fc2c8beeaa0c03c6f565c9 Mon Sep 17 00:00:00 2001 From: Daniel Walasek Date: Sat, 5 Aug 2017 12:42:45 +0200 Subject: [PATCH 1104/1265] tests: fix incorrect should usage closes #3387 --- test/Route.js | 14 +++++++------- test/Router.js | 2 +- test/app.js | 4 ++-- test/app.param.js | 6 +++--- test/app.render.js | 2 +- test/app.routes.error.js | 8 ++++---- test/exports.js | 8 ++++---- test/req.acceptsEncoding.js | 6 +++--- test/req.acceptsEncodings.js | 6 +++--- test/req.acceptsLanguage.js | 12 ++++++------ test/req.acceptsLanguages.js | 12 ++++++------ test/req.xhr.js | 8 ++++---- test/res.sendFile.js | 14 +++++++------- 13 files changed, 51 insertions(+), 51 deletions(-) diff --git a/test/Route.js b/test/Route.js index ada54086bf0..d7a80bdbc01 100644 --- a/test/Route.js +++ b/test/Route.js @@ -25,7 +25,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - should(req.called).be.ok; + should(req.called).be.ok() done(); }); }) @@ -84,7 +84,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - should(req.called).be.ok; + should(req.called).be.ok() done(); }); }) @@ -104,7 +104,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - should(req.called).be.true; + should(req.called).be.true() done(); }); }) @@ -156,7 +156,7 @@ describe('Route', function(){ }); route.dispatch(req, {}, function (err) { - should(err).be.ok; + should(err).be.ok() should(err.message).equal('foobar'); req.order.should.equal('a'); done(); @@ -182,7 +182,7 @@ describe('Route', function(){ }); route.dispatch(req, {}, function (err) { - should(err).be.ok; + should(err).be.ok() should(err.message).equal('foobar'); req.order.should.equal('a'); done(); @@ -222,7 +222,7 @@ describe('Route', function(){ }); route.dispatch(req, {}, function(err){ - should(err).be.ok; + should(err).be.ok() err.message.should.equal('boom!'); done(); }); @@ -234,7 +234,7 @@ describe('Route', function(){ route.all(function(err, req, res, next){ // this should not execute - true.should.be.false; + true.should.be.false() }); route.dispatch(req, {}, done); diff --git a/test/Router.js b/test/Router.js index 01a6e2c472b..18153d29267 100644 --- a/test/Router.js +++ b/test/Router.js @@ -47,7 +47,7 @@ describe('Router', function(){ var router = new Router(); router.use(function (req, res) { - false.should.be.true; + false.should.be.true() }); router.handle({ url: '', method: 'GET' }, {}, done); diff --git a/test/app.js b/test/app.js index 941d35ff1cc..e52365c36bb 100644 --- a/test/app.js +++ b/test/app.js @@ -86,7 +86,7 @@ describe('in development', function(){ it('should disable "view cache"', function(){ process.env.NODE_ENV = 'development'; var app = express(); - app.enabled('view cache').should.be.false; + app.enabled('view cache').should.be.false() process.env.NODE_ENV = 'test'; }) }) @@ -95,7 +95,7 @@ describe('in production', function(){ it('should enable "view cache"', function(){ process.env.NODE_ENV = 'production'; var app = express(); - app.enabled('view cache').should.be.true; + app.enabled('view cache').should.be.true() process.env.NODE_ENV = 'test'; }) }) diff --git a/test/app.param.js b/test/app.param.js index c7a375418cd..ba43e46f8e3 100644 --- a/test/app.param.js +++ b/test/app.param.js @@ -57,13 +57,13 @@ describe('app', function(){ app.get('/post/:id', function(req, res){ var id = req.params.id; - id.should.be.a.Number; + id.should.be.a.Number() res.send('' + id); }); app.get('/user/:uid', function(req, res){ var id = req.params.id; - id.should.be.a.Number; + id.should.be.a.Number() res.send('' + id); }); @@ -91,7 +91,7 @@ describe('app', function(){ app.get('/user/:id', function(req, res){ var id = req.params.id; - id.should.be.a.Number; + id.should.be.a.Number() res.send('' + id); }); diff --git a/test/app.render.js b/test/app.render.js index 729b1c97cc8..1485098f582 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -72,7 +72,7 @@ describe('app', function(){ app.set('view', View); app.render('something', function(err, str){ - err.should.be.ok; + err.should.be.ok() err.message.should.equal('err!'); done(); }) diff --git a/test/app.routes.error.js b/test/app.routes.error.js index 7c49d50ffe2..cbbc23ef574 100644 --- a/test/app.routes.error.js +++ b/test/app.routes.error.js @@ -44,10 +44,10 @@ describe('app', function(){ d = true; next(); }, function(req, res){ - a.should.be.false; - b.should.be.true; - c.should.be.true; - d.should.be.false; + a.should.be.false() + b.should.be.true() + c.should.be.true() + d.should.be.false() res.send(204); }); diff --git a/test/exports.js b/test/exports.js index d34a7b1cf3e..2a80eedbbe8 100644 --- a/test/exports.js +++ b/test/exports.js @@ -5,19 +5,19 @@ var should = require('should'); describe('exports', function(){ it('should expose Router', function(){ - express.Router.should.be.a.Function; + express.Router.should.be.a.Function() }) it('should expose the application prototype', function(){ - express.application.set.should.be.a.Function; + express.application.set.should.be.a.Function() }) it('should expose the request prototype', function(){ - express.request.accepts.should.be.a.Function; + express.request.accepts.should.be.a.Function() }) it('should expose the response prototype', function(){ - express.response.send.should.be.a.Function; + express.response.send.should.be.a.Function() }) it('should permit modifying the .application prototype', function(){ diff --git a/test/req.acceptsEncoding.js b/test/req.acceptsEncoding.js index 12708fc0144..9ed9197829f 100644 --- a/test/req.acceptsEncoding.js +++ b/test/req.acceptsEncoding.js @@ -8,8 +8,8 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsEncoding('gzip').should.be.ok; - req.acceptsEncoding('deflate').should.be.ok; + req.acceptsEncoding('gzip').should.be.ok() + req.acceptsEncoding('deflate').should.be.ok() res.end(); }); @@ -23,7 +23,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsEncoding('bogus').should.not.be.ok; + req.acceptsEncoding('bogus').should.not.be.ok() res.end(); }); diff --git a/test/req.acceptsEncodings.js b/test/req.acceptsEncodings.js index c036c297691..aba8ea5fbeb 100644 --- a/test/req.acceptsEncodings.js +++ b/test/req.acceptsEncodings.js @@ -8,8 +8,8 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsEncodings('gzip').should.be.ok; - req.acceptsEncodings('deflate').should.be.ok; + req.acceptsEncodings('gzip').should.be.ok() + req.acceptsEncodings('deflate').should.be.ok() res.end(); }); @@ -23,7 +23,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsEncodings('bogus').should.not.be.ok; + req.acceptsEncodings('bogus').should.not.be.ok() res.end(); }); diff --git a/test/req.acceptsLanguage.js b/test/req.acceptsLanguage.js index b14d920bd69..1c7c5fd86f6 100644 --- a/test/req.acceptsLanguage.js +++ b/test/req.acceptsLanguage.js @@ -8,8 +8,8 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsLanguage('en-us').should.be.ok; - req.acceptsLanguage('en').should.be.ok; + req.acceptsLanguage('en-us').should.be.ok() + req.acceptsLanguage('en').should.be.ok() res.end(); }); @@ -23,7 +23,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsLanguage('es').should.not.be.ok; + req.acceptsLanguage('es').should.not.be.ok() res.end(); }); @@ -38,9 +38,9 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsLanguage('en').should.be.ok; - req.acceptsLanguage('es').should.be.ok; - req.acceptsLanguage('jp').should.be.ok; + req.acceptsLanguage('en').should.be.ok() + req.acceptsLanguage('es').should.be.ok() + req.acceptsLanguage('jp').should.be.ok() res.end(); }); diff --git a/test/req.acceptsLanguages.js b/test/req.acceptsLanguages.js index 6a9cb3366bc..1d92f44b2b3 100644 --- a/test/req.acceptsLanguages.js +++ b/test/req.acceptsLanguages.js @@ -8,8 +8,8 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsLanguages('en-us').should.be.ok; - req.acceptsLanguages('en').should.be.ok; + req.acceptsLanguages('en-us').should.be.ok() + req.acceptsLanguages('en').should.be.ok() res.end(); }); @@ -23,7 +23,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsLanguages('es').should.not.be.ok; + req.acceptsLanguages('es').should.not.be.ok() res.end(); }); @@ -38,9 +38,9 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.acceptsLanguages('en').should.be.ok; - req.acceptsLanguages('es').should.be.ok; - req.acceptsLanguages('jp').should.be.ok; + req.acceptsLanguages('en').should.be.ok() + req.acceptsLanguages('es').should.be.ok() + req.acceptsLanguages('jp').should.be.ok() res.end(); }); diff --git a/test/req.xhr.js b/test/req.xhr.js index cc8754ce4cf..1bbc247104d 100644 --- a/test/req.xhr.js +++ b/test/req.xhr.js @@ -8,7 +8,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.xhr.should.be.true; + req.xhr.should.be.true() res.end(); }); @@ -25,7 +25,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.xhr.should.be.true; + req.xhr.should.be.true() res.end(); }); @@ -42,7 +42,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.xhr.should.be.false; + req.xhr.should.be.false() res.end(); }); @@ -59,7 +59,7 @@ describe('req', function(){ var app = express(); app.use(function(req, res){ - req.xhr.should.be.false; + req.xhr.should.be.false() res.end(); }); diff --git a/test/res.sendFile.js b/test/res.sendFile.js index be3a23ebc2c..a3576d02196 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -108,7 +108,7 @@ describe('res', function(){ }); app.use(function (err, req, res, next) { - err.code.should.be.empty; + err.code.should.be.empty() cb(); }); @@ -224,7 +224,7 @@ describe('res', function(){ app.use(function (req, res) { setImmediate(function () { res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { - should(err).be.ok; + should(err).be.ok() err.code.should.equal('ECONNABORTED'); cb(); }); @@ -243,7 +243,7 @@ describe('res', function(){ app.use(function (req, res) { onFinished(res, function () { res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { - should(err).be.ok; + should(err).be.ok() err.code.should.equal('ECONNABORTED'); cb(); }); @@ -294,7 +294,7 @@ describe('res', function(){ app.use(function (req, res) { res.sendFile(path.resolve(fixtures, 'does-not-exist'), function (err) { - should(err).be.ok; + should(err).be.ok() err.status.should.equal(404); res.send('got it'); }); @@ -348,7 +348,7 @@ describe('res', function(){ app.use(function (req, res) { setImmediate(function () { res.sendfile('test/fixtures/name.txt', function (err) { - should(err).be.ok; + should(err).be.ok() err.code.should.equal('ECONNABORTED'); cb(); }); @@ -367,7 +367,7 @@ describe('res', function(){ app.use(function (req, res) { onFinished(res, function () { res.sendfile('test/fixtures/name.txt', function (err) { - should(err).be.ok; + should(err).be.ok() err.code.should.equal('ECONNABORTED'); cb(); }); @@ -600,7 +600,7 @@ describe('res', function(){ }); app.use(function (err, req, res, next) { - err.code.should.be.empty; + err.code.should.be.empty() cb(); }); From 56e90e3c7267782febe35754806ce3f63b527485 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 5 Aug 2017 23:37:39 -0400 Subject: [PATCH 1105/1265] lint: add eslint rules that cover editorconfig --- .eslintignore | 2 ++ .eslintrc | 7 +++++++ .travis.yml | 4 +++- appveyor.yml | 1 + examples/content-negotiation/db.js | 2 +- examples/mvc/controllers/main/index.js | 2 +- examples/mvc/db.js | 2 +- examples/resource/index.js | 2 +- examples/route-separation/site.js | 2 +- examples/search/public/client.js | 2 +- examples/static-files/public/js/app.js | 2 +- examples/web-service/index.js | 2 +- package.json | 2 ++ test/acceptance/error-pages.js | 2 +- test/acceptance/error.js | 2 +- test/acceptance/route-map.js | 2 +- test/app.engine.js | 4 ++-- test/config.js | 12 ++++++------ 18 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000000..62562b74a3b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +coverage +node_modules diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000000..8f51db362e8 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "eol-last": "error", + "indent": ["error", 2, { "SwitchCase": 1 }], + "no-trailing-spaces": "error" + } +} diff --git a/.travis.yml b/.travis.yml index 3e899dd2351..5926ca5650a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,7 @@ before_install: # Update Node.js modules - "test ! -d node_modules || npm prune" - "test ! -d node_modules || npm rebuild" -script: "npm run-script test-ci" +script: + - "npm run test-ci" + - "npm run lint" after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls" diff --git a/appveyor.yml b/appveyor.yml index ed8d4aa9f05..9863c08e272 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,4 +22,5 @@ test_script: - node --version - npm --version - npm run test-ci + - npm run lint version: "{build}" diff --git a/examples/content-negotiation/db.js b/examples/content-negotiation/db.js index 8def2f5ad21..43fb04baa18 100644 --- a/examples/content-negotiation/db.js +++ b/examples/content-negotiation/db.js @@ -4,4 +4,4 @@ users.push({ name: 'Tobi' }); users.push({ name: 'Loki' }); users.push({ name: 'Jane' }); -module.exports = users; \ No newline at end of file +module.exports = users; diff --git a/examples/mvc/controllers/main/index.js b/examples/mvc/controllers/main/index.js index 83db90f6f20..031862d345e 100644 --- a/examples/mvc/controllers/main/index.js +++ b/examples/mvc/controllers/main/index.js @@ -1,3 +1,3 @@ exports.index = function(req, res){ res.redirect('/users'); -}; \ No newline at end of file +}; diff --git a/examples/mvc/db.js b/examples/mvc/db.js index 565fdfaa507..c992afcfd74 100644 --- a/examples/mvc/db.js +++ b/examples/mvc/db.js @@ -11,4 +11,4 @@ var users = exports.users = []; users.push({ name: 'TJ', pets: [pets[0], pets[1], pets[2]], id: 0 }); users.push({ name: 'Guillermo', pets: [pets[3]], id: 1 }); -users.push({ name: 'Nathan', pets: [], id: 2 }); \ No newline at end of file +users.push({ name: 'Nathan', pets: [], id: 2 }); diff --git a/examples/resource/index.js b/examples/resource/index.js index 9137167cdf9..0c2a7a32079 100644 --- a/examples/resource/index.js +++ b/examples/resource/index.js @@ -75,7 +75,7 @@ app.resource('/users', User); app.get('/', function(req, res){ res.send([ - '

    Examples:

      ' + '

      Examples:

        ' , '
      • GET /users
      • ' , '
      • GET /users/1
      • ' , '
      • GET /users/3
      • ' diff --git a/examples/route-separation/site.js b/examples/route-separation/site.js index 698892cc89c..a3d20bc8a1f 100644 --- a/examples/route-separation/site.js +++ b/examples/route-separation/site.js @@ -1,3 +1,3 @@ exports.index = function(req, res){ res.render('index', { title: 'Route Separation Example' }); -}; \ No newline at end of file +}; diff --git a/examples/search/public/client.js b/examples/search/public/client.js index 0c198cc39fa..a7eeb6a75af 100644 --- a/examples/search/public/client.js +++ b/examples/search/public/client.js @@ -10,4 +10,4 @@ search.addEventListener('keyup', function(){ } }; xhr.send(); -}, false); \ No newline at end of file +}, false); diff --git a/examples/static-files/public/js/app.js b/examples/static-files/public/js/app.js index 19102815663..257cc5642cb 100644 --- a/examples/static-files/public/js/app.js +++ b/examples/static-files/public/js/app.js @@ -1 +1 @@ -foo \ No newline at end of file +foo diff --git a/examples/web-service/index.js b/examples/web-service/index.js index 694e121d91b..41747cfdc7f 100644 --- a/examples/web-service/index.js +++ b/examples/web-service/index.js @@ -61,7 +61,7 @@ var users = [ ]; var userRepos = { - tobi: [repos[0], repos[1]] + tobi: [repos[0], repos[1]] , loki: [repos[1]] , jane: [repos[2]] }; diff --git a/package.json b/package.json index 15e80f1934b..9f38f52bc1a 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "body-parser": "1.17.2", "cookie-parser": "~1.4.3", "ejs": "2.5.7", + "eslint": "2.13.1", "express-session": "1.15.3", "hbs": "4.0.1", "istanbul": "0.4.5", @@ -87,6 +88,7 @@ "lib/" ], "scripts": { + "lint": "eslint .", "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", diff --git a/test/acceptance/error-pages.js b/test/acceptance/error-pages.js index 886cedcabe3..9af950178da 100644 --- a/test/acceptance/error-pages.js +++ b/test/acceptance/error-pages.js @@ -99,4 +99,4 @@ describe('error-pages', function(){ }) }) }) -}) \ No newline at end of file +}) diff --git a/test/acceptance/error.js b/test/acceptance/error.js index 6010f2e2ae4..6bdf099feed 100644 --- a/test/acceptance/error.js +++ b/test/acceptance/error.js @@ -26,4 +26,4 @@ describe('error', function(){ .expect(404,done) }) }) -}) \ No newline at end of file +}) diff --git a/test/acceptance/route-map.js b/test/acceptance/route-map.js index ae3eeea6507..0bd2a6d32e1 100644 --- a/test/acceptance/route-map.js +++ b/test/acceptance/route-map.js @@ -42,4 +42,4 @@ describe('route-map', function(){ .expect('delete 12\'s pet 2', done); }) }) -}) \ No newline at end of file +}) diff --git a/test/app.engine.js b/test/app.engine.js index 6d1ee1cacbf..b198292fa03 100644 --- a/test/app.engine.js +++ b/test/app.engine.js @@ -47,7 +47,7 @@ describe('app', function(){ done(); }) }) - + it('should work "view engine" setting', function(done){ var app = express(); @@ -62,7 +62,7 @@ describe('app', function(){ done(); }) }) - + it('should work "view engine" with leading "."', function(done){ var app = express(); diff --git a/test/config.js b/test/config.js index e298e76a5c5..17a02b7ebab 100644 --- a/test/config.js +++ b/test/config.js @@ -49,7 +49,7 @@ describe('config', function () { var app = express(); assert.strictEqual(app.get('foo'), undefined); }) - + it('should otherwise return the value', function(){ var app = express(); app.set('foo', 'bar'); @@ -125,7 +125,7 @@ describe('config', function () { assert.strictEqual(app.get('tobi'), true); }) }) - + describe('.disable()', function(){ it('should set the value to false', function(){ var app = express(); @@ -133,26 +133,26 @@ describe('config', function () { assert.strictEqual(app.get('tobi'), false); }) }) - + describe('.enabled()', function(){ it('should default to false', function(){ var app = express(); assert.strictEqual(app.enabled('foo'), false); }) - + it('should return true when set', function(){ var app = express(); app.set('foo', 'bar'); assert.strictEqual(app.enabled('foo'), true); }) }) - + describe('.disabled()', function(){ it('should default to true', function(){ var app = express(); assert.strictEqual(app.disabled('foo'), true); }) - + it('should return false when set', function(){ var app = express(); app.set('foo', 'bar'); From 1dbaae51ddb64c7397d19546bacb0792dbb7d59b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 5 Aug 2017 23:54:31 -0400 Subject: [PATCH 1106/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f38f52bc1a..ab6db290342 100644 --- a/package.json +++ b/package.json @@ -60,9 +60,10 @@ "after": "0.8.2", "body-parser": "1.17.2", "cookie-parser": "~1.4.3", + "cookie-session": "1.3.0", "ejs": "2.5.7", "eslint": "2.13.1", - "express-session": "1.15.3", + "express-session": "1.15.5", "hbs": "4.0.1", "istanbul": "0.4.5", "marked": "0.3.6", @@ -74,7 +75,6 @@ "should": "11.2.1", "supertest": "1.2.0", "connect-redis": "~2.4.1", - "cookie-session": "~1.2.0", "vhost": "~3.0.2" }, "engines": { From 44881fabe3680722368df75c66125fbd5f8ed569 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 6 Aug 2017 00:18:57 -0400 Subject: [PATCH 1107/1265] docs: update collaborator guide for lint script --- Collaborator-Guide.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Collaborator-Guide.md b/Collaborator-Guide.md index 7c0d265dd0a..75d4e7c8f28 100644 --- a/Collaborator-Guide.md +++ b/Collaborator-Guide.md @@ -6,7 +6,7 @@ Open issues for the expressjs.com website in https://github.com/expressjs/expres ## PRs and Code contributions * Tests must pass. -* Follow the [JavaScript Standard Style](http://standardjs.com/). +* Follow the [JavaScript Standard Style](http://standardjs.com/) and `npm run lint`. * If you fix a bug, add a test. ## Branches @@ -27,7 +27,9 @@ a future release of Express. each new issue you work on, although not compulsory. 4. To run the test suite, first install the dependencies by running `npm install`, then run `npm test`. -5. If the tests pass, you can commit your changes to your fork and then create +5. Ensure your code is linted by running `npm run lint` -- fix any issue you + see listed. +6. If the tests pass, you can commit your changes to your fork and then create a pull request from there. Make sure to reference your issue from the pull request comments by including the issue number e.g. `#123`. From e0066227f787931bb0db09e76e007450d0f365b7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 6 Aug 2017 00:19:32 -0400 Subject: [PATCH 1108/1265] lint: remove all unused varaibles --- .eslintrc | 3 ++- benchmarks/middleware.js | 1 - examples/view-constructor/index.js | 1 - lib/utils.js | 1 - lib/view.js | 1 - test/Route.js | 1 - test/app.listen.js | 1 - test/app.locals.js | 1 - test/app.router.js | 1 - test/req.host.js | 1 - test/req.hostname.js | 1 - test/req.range.js | 1 - test/res.download.js | 1 - test/res.format.js | 1 - test/res.send.js | 1 - test/res.sendFile.js | 4 ---- test/res.sendStatus.js | 1 - test/res.vary.js | 1 - 18 files changed, 2 insertions(+), 21 deletions(-) diff --git a/.eslintrc b/.eslintrc index 8f51db362e8..ad9c0ce9eb7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,6 +2,7 @@ "rules": { "eol-last": "error", "indent": ["error", 2, { "SwitchCase": 1 }], - "no-trailing-spaces": "error" + "no-trailing-spaces": "error", + "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }] } } diff --git a/benchmarks/middleware.js b/benchmarks/middleware.js index 3aa7a8b4ac7..efbac12983a 100644 --- a/benchmarks/middleware.js +++ b/benchmarks/middleware.js @@ -1,5 +1,4 @@ -var http = require('http'); var express = require('..'); var app = express(); diff --git a/examples/view-constructor/index.js b/examples/view-constructor/index.js index 195d32db0eb..175a254e4ee 100644 --- a/examples/view-constructor/index.js +++ b/examples/view-constructor/index.js @@ -3,7 +3,6 @@ */ var express = require('../../'); -var http = require('http'); var GithubView = require('./github-view'); var md = require('marked').parse; diff --git a/lib/utils.js b/lib/utils.js index f418c5807c7..ae2a7f862d2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -17,7 +17,6 @@ var contentType = require('content-type'); var deprecate = require('depd')('express'); var flatten = require('array-flatten'); var mime = require('send').mime; -var basename = require('path').basename; var etag = require('etag'); var proxyaddr = require('proxy-addr'); var qs = require('qs'); diff --git a/lib/view.js b/lib/view.js index 1728725d291..99d5aed7a07 100644 --- a/lib/view.js +++ b/lib/view.js @@ -16,7 +16,6 @@ var debug = require('debug')('express:view'); var path = require('path'); var fs = require('fs'); -var utils = require('./utils'); /** * Module variables. diff --git a/test/Route.js b/test/Route.js index d7a80bdbc01..8f90152d8c8 100644 --- a/test/Route.js +++ b/test/Route.js @@ -4,7 +4,6 @@ var should = require('should'); var express = require('../') , Route = express.Route , methods = require('methods') - , assert = require('assert'); describe('Route', function(){ it('should work without handlers', function(done) { diff --git a/test/app.listen.js b/test/app.listen.js index b6f68578934..a78d16e4e1a 100644 --- a/test/app.listen.js +++ b/test/app.listen.js @@ -1,6 +1,5 @@ var express = require('../') - , request = require('supertest'); describe('app.listen()', function(){ it('should wrap with an HTTP server', function(done){ diff --git a/test/app.locals.js b/test/app.locals.js index a8b022957a2..d8bfb5a9874 100644 --- a/test/app.locals.js +++ b/test/app.locals.js @@ -1,6 +1,5 @@ var express = require('../') - , request = require('supertest'); describe('app', function(){ describe('.locals(obj)', function(){ diff --git a/test/app.router.js b/test/app.router.js index 95680f9139c..28561c2fbcd 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -39,7 +39,6 @@ describe('app.router', function(){ it('should include ' + method.toUpperCase(), function(done){ var app = express(); - var calls = []; app[method]('/foo', function(req, res){ if ('head' == method) { diff --git a/test/req.host.js b/test/req.host.js index 8fa3409054f..7bb0b27acf8 100644 --- a/test/req.host.js +++ b/test/req.host.js @@ -1,7 +1,6 @@ var express = require('../') , request = require('supertest') - , assert = require('assert'); describe('req', function(){ describe('.host', function(){ diff --git a/test/req.hostname.js b/test/req.hostname.js index 65c2be81a1f..816cd597990 100644 --- a/test/req.hostname.js +++ b/test/req.hostname.js @@ -1,7 +1,6 @@ var express = require('../') , request = require('supertest') - , assert = require('assert'); describe('req', function(){ describe('.hostname', function(){ diff --git a/test/req.range.js b/test/req.range.js index 09459d1e127..5443c0658d2 100644 --- a/test/req.range.js +++ b/test/req.range.js @@ -1,5 +1,4 @@ -var assert = require('assert'); var express = require('..'); var request = require('supertest') diff --git a/test/res.download.js b/test/res.download.js index 0671d8318c4..fad56ee256a 100644 --- a/test/res.download.js +++ b/test/res.download.js @@ -89,7 +89,6 @@ describe('res', function(){ it('should remove Content-Disposition', function(done){ var app = express() - , calls = 0; app.use(function (req, res, next) { res.download('test/fixtures/foobar.html', function(err){ diff --git a/test/res.format.js b/test/res.format.js index 2b0dfd517e7..3c1d095b426 100644 --- a/test/res.format.js +++ b/test/res.format.js @@ -1,7 +1,6 @@ var express = require('../') , request = require('supertest') - , utils = require('../lib/utils') , assert = require('assert'); var app1 = express(); diff --git a/test/res.send.js b/test/res.send.js index f2e7d759c15..88d231eab55 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -1,5 +1,4 @@ -var assert = require('assert'); var express = require('..'); var methods = require('methods'); var request = require('supertest'); diff --git a/test/res.sendFile.js b/test/res.sendFile.js index a3576d02196..ff4b1cb2dd1 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -446,12 +446,10 @@ describe('res', function(){ it('should invoke the callback on 403', function(done){ var app = express() - , calls = 0; app.use(function(req, res){ res.sendfile('test/fixtures/foo/../user.html', function(err){ assert(!res.headersSent); - ++calls; res.send(err.message); }); }); @@ -464,7 +462,6 @@ describe('res', function(){ it('should invoke the callback on socket error', function(done){ var app = express() - , calls = 0; app.use(function(req, res){ res.sendfile('test/fixtures/user.html', function(err){ @@ -715,7 +712,6 @@ describe('res', function(){ describe('with non-GET', function(){ it('should still serve', function(done){ var app = express() - , calls = 0; app.use(function(req, res){ res.sendfile(path.join(__dirname, '/fixtures/name.txt')) diff --git a/test/res.sendStatus.js b/test/res.sendStatus.js index a97e1bf8d81..c355bc408f3 100644 --- a/test/res.sendStatus.js +++ b/test/res.sendStatus.js @@ -1,5 +1,4 @@ -var assert = require('assert') var express = require('..') var request = require('supertest') diff --git a/test/res.vary.js b/test/res.vary.js index 9a2edd24c09..9d39a341c0b 100644 --- a/test/res.vary.js +++ b/test/res.vary.js @@ -1,5 +1,4 @@ -var assert = require('assert'); var express = require('..'); var request = require('supertest'); var utils = require('./support/utils'); From e2d725e01620fc3c8b3720e5521a124836e32cb2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 6 Aug 2017 02:37:10 -0400 Subject: [PATCH 1109/1265] deps: send@0.15.4 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c67fd941745..422d52dede3 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,10 @@ unreleased - Fix array argument being altered - deps: ipaddr.js@1.4.0 * deps: qs@6.5.0 + * deps: send@0.15.4 + - deps: debug@2.6.8 + - deps: depd@~1.1.1 + - deps: http-errors@~1.6.2 4.15.3 / 2017-05-16 =================== diff --git a/package.json b/package.json index ab6db290342..5c9e94f4898 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "proxy-addr": "~1.1.5", "qs": "6.5.0", "range-parser": "~1.2.0", - "send": "0.15.3", + "send": "0.15.4", "serve-static": "1.12.3", "setprototypeof": "1.0.3", "statuses": "~1.3.1", From a50f1098d014e2393e2d5f4beae37a85830c203d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 6 Aug 2017 02:38:02 -0400 Subject: [PATCH 1110/1265] deps: serve-static@1.12.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 422d52dede3..91707e6c03d 100644 --- a/History.md +++ b/History.md @@ -14,6 +14,8 @@ unreleased - deps: debug@2.6.8 - deps: depd@~1.1.1 - deps: http-errors@~1.6.2 + * deps: serve-static@1.12.4 + - deps: send@0.15.4 4.15.3 / 2017-05-16 =================== diff --git a/package.json b/package.json index 5c9e94f4898..d5b9ae405df 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "qs": "6.5.0", "range-parser": "~1.2.0", "send": "0.15.4", - "serve-static": "1.12.3", + "serve-static": "1.12.4", "setprototypeof": "1.0.3", "statuses": "~1.3.1", "type-is": "~1.6.15", From a4bd4373b2c3b2521ee4c499cb8e90e98f78bfa5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 6 Aug 2017 22:03:53 -0400 Subject: [PATCH 1111/1265] 4.15.4 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 91707e6c03d..f297e3b075c 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.15.4 / 2017-08-06 +=================== * deps: debug@2.6.8 * deps: depd@~1.1.1 diff --git a/package.json b/package.json index d5b9ae405df..d8ec444d539 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.15.3", + "version": "4.15.4", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 48817a798f3820bbe252d30d33bd701779511dc5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 17 Aug 2017 22:03:40 -0400 Subject: [PATCH 1112/1265] build: remove minor pin for nightly --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5926ca5650a..3dbeb41fcda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ node_js: - "7.10" matrix: include: - - node_js: "8.0" + - node_js: "8" env: "NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly" allow_failures: # Allow the nightly installs to fail From 78e55108e40ce8ce751baa10324f48a6bb21b47e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 13 Sep 2017 20:03:42 -0400 Subject: [PATCH 1113/1265] build: mocha@3.5.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8ec444d539..2eec2887a7b 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "istanbul": "0.4.5", "marked": "0.3.6", "method-override": "2.3.9", - "mocha": "3.5.0", + "mocha": "3.5.3", "morgan": "1.8.2", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", From b208b24f8323930419d9b5bbe0f442b36852dc36 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 13 Sep 2017 20:09:33 -0400 Subject: [PATCH 1114/1265] build: should@13.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2eec2887a7b..5068a5d6144 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "morgan": "1.8.2", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", - "should": "11.2.1", + "should": "13.0.1", "supertest": "1.2.0", "connect-redis": "~2.4.1", "vhost": "~3.0.2" From de5fb62b1ac8d02efcb7931ef12936cb0a954307 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 17 Sep 2017 20:13:05 -0400 Subject: [PATCH 1115/1265] deps: update example dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5068a5d6144..a02a6943d37 100644 --- a/package.json +++ b/package.json @@ -58,9 +58,9 @@ }, "devDependencies": { "after": "0.8.2", - "body-parser": "1.17.2", + "body-parser": "1.18.1", "cookie-parser": "~1.4.3", - "cookie-session": "1.3.0", + "cookie-session": "1.3.1", "ejs": "2.5.7", "eslint": "2.13.1", "express-session": "1.15.5", From 9e067ad2cb96f23f7997758a7f5a3c69ada03c12 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Sep 2017 20:45:32 -0400 Subject: [PATCH 1116/1265] deps: fresh@0.5.2 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f297e3b075c..e7e37e92e24 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +unreleased +========== + + * deps: fresh@0.5.2 + - Fix handling of modified headers with invalid dates + - perf: improve ETag match loop + - perf: improve `If-None-Match` token parsing + 4.15.4 / 2017-08-06 =================== diff --git a/package.json b/package.json index a02a6943d37..87e4ee8eae4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "escape-html": "~1.0.3", "etag": "~1.8.0", "finalhandler": "~1.0.4", - "fresh": "0.5.0", + "fresh": "0.5.2", "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "~2.3.0", From 9e0fa7f1ca2efe768e91ee84534f837d2cff243a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Sep 2017 20:46:42 -0400 Subject: [PATCH 1117/1265] deps: send@0.15.5 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e7e37e92e24..83cd43185e5 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,10 @@ unreleased - Fix handling of modified headers with invalid dates - perf: improve ETag match loop - perf: improve `If-None-Match` token parsing + * deps: send@0.15.5 + - Fix handling of modified headers with invalid dates + - deps: etag@~1.8.1 + - deps: fresh@0.5.2 4.15.4 / 2017-08-06 =================== diff --git a/package.json b/package.json index 87e4ee8eae4..2ad3c5e2a99 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "proxy-addr": "~1.1.5", "qs": "6.5.0", "range-parser": "~1.2.0", - "send": "0.15.4", + "send": "0.15.5", "serve-static": "1.12.4", "setprototypeof": "1.0.3", "statuses": "~1.3.1", From 961dbff904d3e6b1b10cfe6741506ae851d272ff Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Sep 2017 20:48:23 -0400 Subject: [PATCH 1118/1265] deps: serve-static@1.12.5 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 83cd43185e5..95fad3d3d97 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,9 @@ unreleased - Fix handling of modified headers with invalid dates - deps: etag@~1.8.1 - deps: fresh@0.5.2 + * deps: serve-static@1.12.5 + - deps: parseurl@~1.3.2 + - deps: send@0.15.5 4.15.4 / 2017-08-06 =================== diff --git a/package.json b/package.json index 2ad3c5e2a99..4bb68915b8e 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "qs": "6.5.0", "range-parser": "~1.2.0", "send": "0.15.5", - "serve-static": "1.12.4", + "serve-static": "1.12.5", "setprototypeof": "1.0.3", "statuses": "~1.3.1", "type-is": "~1.6.15", From d7da22550da484ddcdf77623272b64c36030b216 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 21 Sep 2017 20:49:14 -0400 Subject: [PATCH 1119/1265] build: should@13.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4bb68915b8e..97f94459b83 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "morgan": "1.8.2", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", - "should": "13.0.1", + "should": "13.1.0", "supertest": "1.2.0", "connect-redis": "~2.4.1", "vhost": "~3.0.2" From 19a2eeb47697feecae5960a726fb5b7ae2c7644b Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 21 Mar 2017 14:53:42 -0700 Subject: [PATCH 1120/1265] tests: check render error without engine-specific message closes #3251 --- test/app.render.js | 10 ++++------ test/res.render.js | 10 ++++++---- test/support/tmpl.js | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/app.render.js b/test/app.render.js index 1485098f582..54f6c2ca82d 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -97,12 +97,10 @@ describe('app', function(){ app.set('views', path.join(__dirname, 'fixtures')) - app.render('user.tmpl', function (err, str) { - // nextTick to prevent cyclic - process.nextTick(function(){ - err.message.should.match(/Cannot read property '[^']+' of undefined/); - done(); - }); + app.render('user.tmpl', function (err) { + assert.ok(err) + assert.equal(err.name, 'RenderError') + done() }) }) }) diff --git a/test/res.render.js b/test/res.render.js index 2e3a16f1370..e19e8cc542b 100644 --- a/test/res.render.js +++ b/test/res.render.js @@ -105,12 +105,12 @@ describe('res', function(){ }); app.use(function(err, req, res, next){ - res.end(err.message); + res.status(500).send('got error: ' + err.name) }); request(app) .get('/') - .expect(/Cannot read property '[^']+' of undefined/, done); + .expect(500, 'got error: RenderError', done) }) }) @@ -329,13 +329,15 @@ describe('res', function(){ app.use(function(req, res){ res.render('user.tmpl', function (err) { - res.end(err.message); + if (err) { + res.status(500).send('got error: ' + err.name) + } }); }); request(app) .get('/') - .expect(/Cannot read property '[^']+' of undefined/, done); + .expect(500, 'got error: RenderError', done) }) }) }) diff --git a/test/support/tmpl.js b/test/support/tmpl.js index 2e8bec86388..bab65669d33 100644 --- a/test/support/tmpl.js +++ b/test/support/tmpl.js @@ -13,6 +13,7 @@ module.exports = function renderFile(fileName, options, callback) { str = str.replace(variableRegExp, generateVariableLookup(options)); } catch (e) { err = e; + err.name = 'RenderError' } callback(err, str); From 9395db4c22567d09f19ac7cd629e23908784ec6d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 22 Sep 2017 20:25:18 -0400 Subject: [PATCH 1121/1265] deps: debug@2.6.9 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 95fad3d3d97..5bf412451be 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * deps: debug@2.6.9 * deps: fresh@0.5.2 - Fix handling of modified headers with invalid dates - perf: improve ETag match loop diff --git a/package.json b/package.json index 97f94459b83..7f465d0e642 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "content-type": "~1.0.2", "cookie": "0.3.1", "cookie-signature": "1.0.6", - "debug": "2.6.8", + "debug": "2.6.9", "depd": "~1.1.1", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", From bd1672f0a45e2722126a05723aca68cbd65e3f74 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 22 Sep 2017 20:26:30 -0400 Subject: [PATCH 1122/1265] deps: finalhandler@~1.0.6 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 5bf412451be..e4770be6885 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,9 @@ unreleased ========== * deps: debug@2.6.9 + * deps: finalhandler@~1.0.6 + - deps: debug@2.6.9 + - deps: parseurl@~1.3.2 * deps: fresh@0.5.2 - Fix handling of modified headers with invalid dates - perf: improve ETag match loop diff --git a/package.json b/package.json index 7f465d0e642..3afcec06718 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.8.0", - "finalhandler": "~1.0.4", + "finalhandler": "~1.0.6", "fresh": "0.5.2", "merge-descriptors": "1.0.1", "methods": "~1.1.2", From 7137bf567db674fa5a93b71fffda09e7ac4ec73c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 22 Sep 2017 20:27:37 -0400 Subject: [PATCH 1123/1265] deps: send@0.15.6 --- History.md | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index e4770be6885..3d2bb66505c 100644 --- a/History.md +++ b/History.md @@ -9,10 +9,12 @@ unreleased - Fix handling of modified headers with invalid dates - perf: improve ETag match loop - perf: improve `If-None-Match` token parsing - * deps: send@0.15.5 + * deps: send@0.15.6 - Fix handling of modified headers with invalid dates + - deps: debug@2.6.9 - deps: etag@~1.8.1 - deps: fresh@0.5.2 + - perf: improve `If-Match` token parsing * deps: serve-static@1.12.5 - deps: parseurl@~1.3.2 - deps: send@0.15.5 diff --git a/package.json b/package.json index 3afcec06718..16b11d6fdb1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "proxy-addr": "~1.1.5", "qs": "6.5.0", "range-parser": "~1.2.0", - "send": "0.15.5", + "send": "0.15.6", "serve-static": "1.12.5", "setprototypeof": "1.0.3", "statuses": "~1.3.1", From 40435ec99779b08202f9f139c9a0a7d64e941b40 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 22 Sep 2017 20:28:52 -0400 Subject: [PATCH 1124/1265] deps: serve-static@1.12.6 --- History.md | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 3d2bb66505c..fa520920d7c 100644 --- a/History.md +++ b/History.md @@ -15,9 +15,10 @@ unreleased - deps: etag@~1.8.1 - deps: fresh@0.5.2 - perf: improve `If-Match` token parsing - * deps: serve-static@1.12.5 + * deps: serve-static@1.12.6 - deps: parseurl@~1.3.2 - - deps: send@0.15.5 + - deps: send@0.15.6 + - perf: improve slash collapsing 4.15.4 / 2017-08-06 =================== diff --git a/package.json b/package.json index 16b11d6fdb1..bf48b83c7cc 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "qs": "6.5.0", "range-parser": "~1.2.0", "send": "0.15.6", - "serve-static": "1.12.5", + "serve-static": "1.12.6", "setprototypeof": "1.0.3", "statuses": "~1.3.1", "type-is": "~1.6.15", From ea3d60565242c47be97088ead2708d7b88390858 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 25 Sep 2017 01:04:38 -0400 Subject: [PATCH 1125/1265] 4.15.5 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index fa520920d7c..707677eb17a 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +4.15.5 / 2017-09-24 +=================== * deps: debug@2.6.9 * deps: finalhandler@~1.0.6 diff --git a/package.json b/package.json index bf48b83c7cc..954c20b3c30 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Fast, unopinionated, minimalist web framework", - "version": "4.15.4", + "version": "4.15.5", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 94fdb674b1df2e36d389fce51f5e07071f807adb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 25 Sep 2017 20:57:54 -0400 Subject: [PATCH 1126/1265] build: support Node.js 8.x --- .gitignore | 1 + .travis.yml | 4 ++++ appveyor.yml | 2 ++ 3 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 9723e60591d..5fee6a2dc97 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Desktop.ini # npm node_modules +package-lock.json *.log *.gz diff --git a/.travis.yml b/.travis.yml index 3dbeb41fcda..3e487a6f186 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ node_js: - "5.12" - "6.11" - "7.10" + - "8.4" matrix: include: - node_js: "8" @@ -21,6 +22,9 @@ cache: directories: - node_modules before_install: + # Skip updating shrinkwrap / lock + - "npm config set shrinkwrap false" + # Remove all non-test dependencies - "npm rm --save-dev connect-redis" diff --git a/appveyor.yml b/appveyor.yml index 9863c08e272..193660af715 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,10 +9,12 @@ environment: - nodejs_version: "5.12" - nodejs_version: "6.11" - nodejs_version: "7.10" + - nodejs_version: "8.4" cache: - node_modules install: - ps: Install-Product node $env:nodejs_version + - npm config set shrinkwrap false - npm rm --save-dev connect-redis - if exist node_modules npm prune - if exist node_modules npm rebuild From c3fb7e5adc1fd40e301ed1e25f0d5b5a393d0295 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 25 Sep 2017 21:06:00 -0400 Subject: [PATCH 1127/1265] build: test against Node.js 9.x nightly --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3e487a6f186..855168ff540 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ matrix: include: - node_js: "8" env: "NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly" + - node_js: "9" + env: "NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly" allow_failures: # Allow the nightly installs to fail - env: "NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly" From 80f1ea9bec3c5aedb08a6917ecc24fb8d22b707d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 25 Sep 2017 21:11:33 -0400 Subject: [PATCH 1128/1265] Improve error message when autoloading invalid view engine fixes #3403 --- History.md | 5 +++++ lib/view.js | 10 +++++++++- test/fixtures/broken.send | 0 test/res.render.js | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/broken.send diff --git a/History.md b/History.md index 707677eb17a..765f050318a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Improve error message when autoloading invalid view engine + 4.15.5 / 2017-09-24 =================== diff --git a/lib/view.js b/lib/view.js index 99d5aed7a07..cf101caeab9 100644 --- a/lib/view.js +++ b/lib/view.js @@ -76,7 +76,15 @@ function View(name, options) { // load engine var mod = this.ext.substr(1) debug('require "%s"', mod) - opts.engines[this.ext] = require(mod).__express + + // default engine export + var fn = require(mod).__express + + if (typeof fn !== 'function') { + throw new Error('Module "' + mod + '" does not provide a view engine.') + } + + opts.engines[this.ext] = fn } // store loaded engine diff --git a/test/fixtures/broken.send b/test/fixtures/broken.send new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/res.render.js b/test/res.render.js index e19e8cc542b..643a57002a0 100644 --- a/test/res.render.js +++ b/test/res.render.js @@ -35,6 +35,20 @@ describe('res', function(){ .expect('

        tobi

        ', done); }) + it('should error without "view engine" set and file extension to a non-engine module', function (done) { + var app = createApp() + + app.locals.user = { name: 'tobi' } + + app.use(function (req, res) { + res.render(path.join(__dirname, 'fixtures', 'broken.send')) + }) + + request(app) + .get('/') + .expect(500, /does not provide a view engine/, done) + }) + it('should error without "view engine" set and no file extension', function (done) { var app = createApp(); From 48940e61202be07677659b3b9d87c967fc4e8bdc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 25 Sep 2017 21:12:47 -0400 Subject: [PATCH 1129/1265] Skip Buffer encoding when not generating ETag for small response --- History.md | 1 + lib/response.js | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/History.md b/History.md index 765f050318a..83ba2cc5d76 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Improve error message when autoloading invalid view engine + * Skip `Buffer` encoding when not generating ETag for small response 4.15.5 / 2017-09-24 =================== diff --git a/lib/response.js b/lib/response.js index b852a60e2f5..e34af49d693 100644 --- a/lib/response.js +++ b/lib/response.js @@ -106,7 +106,6 @@ res.links = function(links){ res.send = function send(body) { var chunk = body; var encoding; - var len; var req = this.req; var type; @@ -171,23 +170,33 @@ res.send = function send(body) { } } + // determine if ETag should be generated + var etagFn = app.get('etag fn') + var generateETag = !this.get('ETag') && typeof etagFn === 'function' + // populate Content-Length + var len if (chunk !== undefined) { - if (!Buffer.isBuffer(chunk)) { - // convert chunk to Buffer; saves later double conversions + if (!generateETag && chunk.length < 1000) { + // just calculate length when no ETag + small chunk + len = Buffer.byteLength(chunk, encoding) + } else if (!Buffer.isBuffer(chunk)) { + // convert chunk to Buffer and calculate chunk = new Buffer(chunk, encoding); encoding = undefined; + len = chunk.length + } else { + // get length of Buffer + len = chunk.length } - len = chunk.length; this.set('Content-Length', len); } // populate ETag var etag; - var generateETag = len !== undefined && app.get('etag fn'); - if (typeof generateETag === 'function' && !this.get('ETag')) { - if ((etag = generateETag(chunk, encoding))) { + if (generateETag && len !== undefined) { + if ((etag = etagFn(chunk, encoding))) { this.set('ETag', etag); } } From 550043c21727674a9d00c30504beb95cfbd7bbba Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 25 Sep 2017 21:14:00 -0400 Subject: [PATCH 1130/1265] deps: setprototypeof@1.1.0 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 83ba2cc5d76..e8fcafa4149 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ unreleased * Improve error message when autoloading invalid view engine * Skip `Buffer` encoding when not generating ETag for small response + * deps: setprototypeof@1.1.0 4.15.5 / 2017-09-24 =================== diff --git a/package.json b/package.json index 954c20b3c30..cd94d1cf94a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "range-parser": "~1.2.0", "send": "0.15.6", "serve-static": "1.12.6", - "setprototypeof": "1.0.3", + "setprototypeof": "1.1.0", "statuses": "~1.3.1", "type-is": "~1.6.15", "utils-merge": "1.0.0", From 9a99c152703048591c031bd10d2a2e3ca55ebcac Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Sep 2017 21:28:25 -0400 Subject: [PATCH 1131/1265] deps: accepts@~1.3.4 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e8fcafa4149..0c206496496 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,8 @@ unreleased * Improve error message when autoloading invalid view engine * Skip `Buffer` encoding when not generating ETag for small response + * deps: accepts@~1.3.4 + - deps: mime-types@~2.1.16 * deps: setprototypeof@1.1.0 4.15.5 / 2017-09-24 diff --git a/package.json b/package.json index cd94d1cf94a..9351cf2e05b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "api" ], "dependencies": { - "accepts": "~1.3.3", + "accepts": "~1.3.4", "array-flatten": "1.1.1", "content-disposition": "0.5.2", "content-type": "~1.0.2", From 70589c3aef6fb64ce396848e78ca7ea0768d2d5d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Sep 2017 21:30:08 -0400 Subject: [PATCH 1132/1265] deps: content-type@~1.0.4 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0c206496496..0f6f82bffef 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,9 @@ unreleased * Skip `Buffer` encoding when not generating ETag for small response * deps: accepts@~1.3.4 - deps: mime-types@~2.1.16 + * deps: content-type@~1.0.4 + - perf: remove argument reassignment + - perf: skip parameter parsing when no parameters * deps: setprototypeof@1.1.0 4.15.5 / 2017-09-24 diff --git a/package.json b/package.json index 9351cf2e05b..5febf1048e5 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "accepts": "~1.3.4", "array-flatten": "1.1.1", "content-disposition": "0.5.2", - "content-type": "~1.0.2", + "content-type": "~1.0.4", "cookie": "0.3.1", "cookie-signature": "1.0.6", "debug": "2.6.9", From e62bb8bf9f68382414cdd7997fe661de4647c987 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Sep 2017 21:30:43 -0400 Subject: [PATCH 1133/1265] deps: etag@~1.8.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0f6f82bffef..077eec931b5 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,8 @@ unreleased * deps: content-type@~1.0.4 - perf: remove argument reassignment - perf: skip parameter parsing when no parameters + * deps: etag@~1.8.1 + - perf: replace regular expression with substring * deps: setprototypeof@1.1.0 4.15.5 / 2017-09-24 diff --git a/package.json b/package.json index 5febf1048e5..78834c50721 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "depd": "~1.1.1", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", - "etag": "~1.8.0", + "etag": "~1.8.1", "finalhandler": "~1.0.6", "fresh": "0.5.2", "merge-descriptors": "1.0.1", From ad7d96db479e6e9d93ab4848d5fe163905e123ed Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Sep 2017 21:31:39 -0400 Subject: [PATCH 1134/1265] deps: qs@6.5.1 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 077eec931b5..012d8a2ffed 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,8 @@ unreleased - perf: skip parameter parsing when no parameters * deps: etag@~1.8.1 - perf: replace regular expression with substring + * deps: qs@6.5.1 + - Fix parsing & compacting very deep objects * deps: setprototypeof@1.1.0 4.15.5 / 2017-09-24 diff --git a/package.json b/package.json index 78834c50721..0bbfeb8e6ea 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", "proxy-addr": "~1.1.5", - "qs": "6.5.0", + "qs": "6.5.1", "range-parser": "~1.2.0", "send": "0.15.6", "serve-static": "1.12.6", From 5cc761c86593f2e87c7a9dac02135548096bb952 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 28 Sep 2017 00:04:47 -0400 Subject: [PATCH 1135/1265] deps: parseurl@~1.3.2 --- History.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 012d8a2ffed..2c9866dbb5d 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,9 @@ unreleased - perf: skip parameter parsing when no parameters * deps: etag@~1.8.1 - perf: replace regular expression with substring + * deps: parseurl@~1.3.2 + - perf: reduce overhead for full URLs + - perf: unroll the "fast-path" `RegExp` * deps: qs@6.5.1 - Fix parsing & compacting very deep objects * deps: setprototypeof@1.1.0 diff --git a/package.json b/package.json index 0bbfeb8e6ea..4330b141f08 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "~2.3.0", - "parseurl": "~1.3.1", + "parseurl": "~1.3.2", "path-to-regexp": "0.1.7", "proxy-addr": "~1.1.5", "qs": "6.5.1", From 673d51f4f0fa83f6b663ed6f9f0426940d07664b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 28 Sep 2017 00:19:30 -0400 Subject: [PATCH 1136/1265] deps: utils-merge@1.0.1 --- History.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2c9866dbb5d..eb01929864f 100644 --- a/History.md +++ b/History.md @@ -16,6 +16,7 @@ unreleased * deps: qs@6.5.1 - Fix parsing & compacting very deep objects * deps: setprototypeof@1.1.0 + * deps: utils-merge@1.0.1 4.15.5 / 2017-09-24 =================== diff --git a/package.json b/package.json index 4330b141f08..1298b943275 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "setprototypeof": "1.1.0", "statuses": "~1.3.1", "type-is": "~1.6.15", - "utils-merge": "1.0.0", + "utils-merge": "1.0.1", "vary": "~1.1.1" }, "devDependencies": { From c2f4fb535688eaec14c713190a4ab881e195a41a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 28 Sep 2017 00:42:05 -0400 Subject: [PATCH 1137/1265] deps: finalhandler@1.1.0 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index eb01929864f..c4b34a76439 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,8 @@ unreleased - perf: skip parameter parsing when no parameters * deps: etag@~1.8.1 - perf: replace regular expression with substring + * deps: finalhandler@1.1.0 + - Use `res.headersSent` when available * deps: parseurl@~1.3.2 - perf: reduce overhead for full URLs - perf: unroll the "fast-path" `RegExp` diff --git a/package.json b/package.json index 1298b943275..ea49823cbbf 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "~1.0.6", + "finalhandler": "1.1.0", "fresh": "0.5.2", "merge-descriptors": "1.0.1", "methods": "~1.1.2", From 02a9d5fb28e313fd94ee5ec24fe5da02fbc0d6eb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 28 Sep 2017 01:18:04 -0400 Subject: [PATCH 1138/1265] deps: proxy-addr@~2.0.2 closes #3432 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c4b34a76439..4352f26acdf 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,11 @@ unreleased * deps: parseurl@~1.3.2 - perf: reduce overhead for full URLs - perf: unroll the "fast-path" `RegExp` + * deps: proxy-addr@~2.0.2 + - Fix trimming leading / trailing OWS in `X-Forwarded-For` + - deps: forwarded@~0.1.2 + - deps: ipaddr.js@1.5.2 + - perf: reduce overhead when no `X-Forwarded-For` header * deps: qs@6.5.1 - Fix parsing & compacting very deep objects * deps: setprototypeof@1.1.0 diff --git a/package.json b/package.json index ea49823cbbf..219e21fe23b 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.2", "path-to-regexp": "0.1.7", - "proxy-addr": "~1.1.5", + "proxy-addr": "~2.0.2", "qs": "6.5.1", "range-parser": "~1.2.0", "send": "0.15.6", From d9d09b8b9041504b645f3173ca70ef173c7e1563 Mon Sep 17 00:00:00 2001 From: Lawrence Page Date: Thu, 18 May 2017 11:04:27 -0700 Subject: [PATCH 1139/1265] perf: re-use options object when generating ETags closes #3313 closes #3314 --- History.md | 1 + lib/utils.js | 35 +++++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/History.md b/History.md index 4352f26acdf..4b4f0dd5cbf 100644 --- a/History.md +++ b/History.md @@ -24,6 +24,7 @@ unreleased - Fix parsing & compacting very deep objects * deps: setprototypeof@1.1.0 * deps: utils-merge@1.0.1 + * perf: re-use options object when generating ETags 4.15.5 / 2017-09-24 =================== diff --git a/lib/utils.js b/lib/utils.js index ae2a7f862d2..80f4edae3a3 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -31,13 +31,7 @@ var querystring = require('querystring'); * @api private */ -exports.etag = function (body, encoding) { - var buf = !Buffer.isBuffer(body) - ? new Buffer(body, encoding) - : body; - - return etag(buf, {weak: false}); -}; +exports.etag = createETagGenerator({ weak: false }) /** * Return weak ETag for `body`. @@ -48,13 +42,7 @@ exports.etag = function (body, encoding) { * @api private */ -exports.wetag = function wetag(body, encoding){ - var buf = !Buffer.isBuffer(body) - ? new Buffer(body, encoding) - : body; - - return etag(buf, {weak: true}); -}; +exports.wetag = createETagGenerator({ weak: true }) /** * Check if `path` looks absolute. @@ -273,6 +261,25 @@ exports.setCharset = function setCharset(type, charset) { return contentType.format(parsed); }; +/** + * Create an ETag generator function, generating ETags with + * the given options. + * + * @param {object} options + * @return {function} + * @private + */ + +function createETagGenerator (options) { + return function generateETag (body, encoding) { + var buf = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body + + return etag(buf, options) + } +} + /** * Parse an extended query string with qs. * From fa272edf843a31aa242390d46935437451707d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Wed, 27 Sep 2017 15:17:03 +0200 Subject: [PATCH 1140/1265] docs: fix typo in jsdoc comment closes #3430 --- lib/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index 1abe8d08f58..8097d81a3b9 100644 --- a/lib/application.js +++ b/lib/application.js @@ -338,7 +338,7 @@ app.param = function param(name, fn) { * Assign `setting` to `val`, or return `setting`'s value. * * app.set('foo', 'bar'); - * app.get('foo'); + * app.set('foo'); * // => "bar" * * Mounted servers inherit their parent server's settings. From 12c37124689380837b24a7ed962432596237b440 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 28 Sep 2017 08:26:39 -0400 Subject: [PATCH 1141/1265] Use safe-buffer for improved Buffer API --- History.md | 1 + benchmarks/middleware.js | 4 +--- lib/response.js | 5 +++-- lib/utils.js | 3 ++- package.json | 1 + test/res.attachment.js | 3 ++- test/res.send.js | 12 ++++++------ test/utils.js | 7 +++---- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/History.md b/History.md index 4b4f0dd5cbf..18f5e5da371 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ unreleased * Improve error message when autoloading invalid view engine * Skip `Buffer` encoding when not generating ETag for small response + * Use `safe-buffer` for improved Buffer API * deps: accepts@~1.3.4 - deps: mime-types@~2.1.16 * deps: content-type@~1.0.4 diff --git a/benchmarks/middleware.js b/benchmarks/middleware.js index efbac12983a..df4df2c5ac5 100644 --- a/benchmarks/middleware.js +++ b/benchmarks/middleware.js @@ -13,10 +13,8 @@ while (n--) { }); } -var body = new Buffer('Hello World'); - app.use(function(req, res, next){ - res.send(body); + res.send('Hello World') }); app.listen(3333); diff --git a/lib/response.js b/lib/response.js index e34af49d693..285daf4fb4b 100644 --- a/lib/response.js +++ b/lib/response.js @@ -12,6 +12,7 @@ * @private */ +var Buffer = require('safe-buffer').Buffer var contentDisposition = require('content-disposition'); var deprecate = require('depd')('express'); var encodeUrl = require('encodeurl'); @@ -95,7 +96,7 @@ res.links = function(links){ * * Examples: * - * res.send(new Buffer('wahoo')); + * res.send(Buffer.from('wahoo')); * res.send({ some: 'json' }); * res.send('

        some html

        '); * @@ -182,7 +183,7 @@ res.send = function send(body) { len = Buffer.byteLength(chunk, encoding) } else if (!Buffer.isBuffer(chunk)) { // convert chunk to Buffer and calculate - chunk = new Buffer(chunk, encoding); + chunk = Buffer.from(chunk, encoding) encoding = undefined; len = chunk.length } else { diff --git a/lib/utils.js b/lib/utils.js index 80f4edae3a3..bd81ac7f6d9 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -12,6 +12,7 @@ * @api private */ +var Buffer = require('safe-buffer').Buffer var contentDisposition = require('content-disposition'); var contentType = require('content-type'); var deprecate = require('depd')('express'); @@ -273,7 +274,7 @@ exports.setCharset = function setCharset(type, charset) { function createETagGenerator (options) { return function generateETag (body, encoding) { var buf = !Buffer.isBuffer(body) - ? new Buffer(body, encoding) + ? Buffer.from(body, encoding) : body return etag(buf, options) diff --git a/package.json b/package.json index 219e21fe23b..dbbd7810042 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "proxy-addr": "~2.0.2", "qs": "6.5.1", "range-parser": "~1.2.0", + "safe-buffer": "5.1.1", "send": "0.15.6", "serve-static": "1.12.6", "setprototypeof": "1.1.0", diff --git a/test/res.attachment.js b/test/res.attachment.js index 662b1dd4e01..4c3d4aa2f1b 100644 --- a/test/res.attachment.js +++ b/test/res.attachment.js @@ -1,4 +1,5 @@ +var Buffer = require('safe-buffer').Buffer var express = require('../') , request = require('supertest'); @@ -36,7 +37,7 @@ describe('res', function(){ app.use(function(req, res){ res.attachment('/path/to/image.png'); - res.send(new Buffer(4)); + res.send(Buffer.alloc(4, '.')) }); request(app) diff --git a/test/res.send.js b/test/res.send.js index 88d231eab55..7aa8d7d90e2 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -1,4 +1,5 @@ +var Buffer = require('safe-buffer').Buffer var express = require('..'); var methods = require('methods'); var request = require('supertest'); @@ -166,7 +167,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - res.set('Content-Type', 'text/plain; charset=iso-8859-1').send(new Buffer('hi')); + res.set('Content-Type', 'text/plain; charset=iso-8859-1').send(Buffer.from('hi')) }); request(app) @@ -181,7 +182,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - res.send(new Buffer('hello')); + res.send(Buffer.from('hello')) }); request(app) @@ -194,8 +195,7 @@ describe('res', function(){ var app = express(); app.use(function (req, res) { - var str = Array(1000).join('-'); - res.send(new Buffer(str)); + res.send(Buffer.alloc(999, '-')) }); request(app) @@ -208,7 +208,7 @@ describe('res', function(){ var app = express(); app.use(function(req, res){ - res.set('Content-Type', 'text/plain').send(new Buffer('hey')); + res.set('Content-Type', 'text/plain').send(Buffer.from('hey')) }); request(app) @@ -512,7 +512,7 @@ describe('res', function(){ app.set('etag', function (body, encoding) { var chunk = !Buffer.isBuffer(body) - ? new Buffer(body, encoding) + ? Buffer.from(body, encoding) : body; chunk.toString().should.equal('hello, world!'); return '"custom"'; diff --git a/test/utils.js b/test/utils.js index c49019fe126..b51d223af97 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,5 +1,6 @@ var assert = require('assert'); +var Buffer = require('safe-buffer').Buffer var utils = require('../lib/utils'); describe('utils.etag(body, encoding)', function(){ @@ -14,8 +15,7 @@ describe('utils.etag(body, encoding)', function(){ }) it('should support buffer', function(){ - var buf = new Buffer('express!') - utils.etag(buf) + utils.etag(Buffer.from('express!')) .should.eql('"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"') }) @@ -59,8 +59,7 @@ describe('utils.wetag(body, encoding)', function(){ }) it('should support buffer', function(){ - var buf = new Buffer('express!') - utils.wetag(buf) + utils.wetag(Buffer.from('express!')) .should.eql('W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"') }) From 2df1ad26a58bf51228d7600df0d62ed17a90ff71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Tue, 26 Sep 2017 16:00:53 +0200 Subject: [PATCH 1142/1265] Improve error messages when non-function provided as middleware closes #3426 --- History.md | 1 + lib/application.js | 2 +- lib/router/index.js | 4 ++-- lib/router/route.js | 4 ++-- test/Router.js | 30 +++++++++++++++++++++--------- test/app.use.js | 31 ++++++++++++++++++++++--------- 6 files changed, 49 insertions(+), 23 deletions(-) diff --git a/History.md b/History.md index 18f5e5da371..63a1bdf60b7 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ unreleased ========== * Improve error message when autoloading invalid view engine + * Improve error messages when non-function provided as middleware * Skip `Buffer` encoding when not generating ETag for small response * Use `safe-buffer` for improved Buffer API * deps: accepts@~1.3.4 diff --git a/lib/application.js b/lib/application.js index 8097d81a3b9..91f77d241e4 100644 --- a/lib/application.js +++ b/lib/application.js @@ -207,7 +207,7 @@ app.use = function use(fn) { var fns = flatten(slice.call(arguments, offset)); if (fns.length === 0) { - throw new TypeError('app.use() requires middleware functions'); + throw new TypeError('app.use() requires a middleware function') } // setup router diff --git a/lib/router/index.js b/lib/router/index.js index 51db4c28ff9..60727ed6d64 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -448,14 +448,14 @@ proto.use = function use(fn) { var callbacks = flatten(slice.call(arguments, offset)); if (callbacks.length === 0) { - throw new TypeError('Router.use() requires middleware functions'); + throw new TypeError('Router.use() requires a middleware function') } for (var i = 0; i < callbacks.length; i++) { var fn = callbacks[i]; if (typeof fn !== 'function') { - throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn)); + throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn)) } // add the middleware diff --git a/lib/router/route.js b/lib/router/route.js index ea82ed29df5..178df0d5160 100644 --- a/lib/router/route.js +++ b/lib/router/route.js @@ -175,7 +175,7 @@ Route.prototype.all = function all() { if (typeof handle !== 'function') { var type = toString.call(handle); - var msg = 'Route.all() requires callback functions but got a ' + type; + var msg = 'Route.all() requires a callback function but got a ' + type throw new TypeError(msg); } @@ -198,7 +198,7 @@ methods.forEach(function(method){ if (typeof handle !== 'function') { var type = toString.call(handle); - var msg = 'Route.' + method + '() requires callback functions but got a ' + type; + var msg = 'Route.' + method + '() requires a callback function but got a ' + type throw new Error(msg); } diff --git a/test/Router.js b/test/Router.js index 18153d29267..057ce443df4 100644 --- a/test/Router.js +++ b/test/Router.js @@ -368,17 +368,29 @@ describe('Router', function(){ }) describe('.use', function() { - it('should require arguments', function(){ - var router = new Router(); - router.use.bind(router).should.throw(/requires middleware function/) + it('should require middleware', function () { + var router = new Router() + assert.throws(function () { router.use('/') }, /requires a middleware function/) }) - it('should not accept non-functions', function(){ - var router = new Router(); - router.use.bind(router, '/', 'hello').should.throw(/requires middleware function.*string/) - router.use.bind(router, '/', 5).should.throw(/requires middleware function.*number/) - router.use.bind(router, '/', null).should.throw(/requires middleware function.*Null/) - router.use.bind(router, '/', new Date()).should.throw(/requires middleware function.*Date/) + it('should reject string as middleware', function () { + var router = new Router() + assert.throws(function () { router.use('/', 'foo') }, /requires a middleware function but got a string/) + }) + + it('should reject number as middleware', function () { + var router = new Router() + assert.throws(function () { router.use('/', 42) }, /requires a middleware function but got a number/) + }) + + it('should reject null as middleware', function () { + var router = new Router() + assert.throws(function () { router.use('/', null) }, /requires a middleware function but got a Null/) + }) + + it('should reject Date as middleware', function () { + var router = new Router() + assert.throws(function () { router.use('/', new Date()) }, /requires a middleware function but got a Date/) }) it('should be called for any URL', function (done) { diff --git a/test/app.use.js b/test/app.use.js index b2031e4c56c..347937fbb3b 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -1,5 +1,6 @@ var after = require('after'); +var assert = require('assert') var express = require('..'); var request = require('supertest'); @@ -253,17 +254,29 @@ describe('app', function(){ }) describe('.use(path, middleware)', function(){ - it('should reject missing functions', function () { - var app = express(); - app.use.bind(app, '/').should.throw(/requires middleware function/); + it('should require middleware', function () { + var app = express() + assert.throws(function () { app.use('/') }, /requires a middleware function/) }) - it('should reject non-functions as middleware', function () { - var app = express(); - app.use.bind(app, '/', 'hi').should.throw(/requires middleware function.*string/); - app.use.bind(app, '/', 5).should.throw(/requires middleware function.*number/); - app.use.bind(app, '/', null).should.throw(/requires middleware function.*Null/); - app.use.bind(app, '/', new Date()).should.throw(/requires middleware function.*Date/); + it('should reject string as middleware', function () { + var app = express() + assert.throws(function () { app.use('/', 'foo') }, /requires a middleware function but got a string/) + }) + + it('should reject number as middleware', function () { + var app = express() + assert.throws(function () { app.use('/', 42) }, /requires a middleware function but got a number/) + }) + + it('should reject null as middleware', function () { + var app = express() + assert.throws(function () { app.use('/', null) }, /requires a middleware function but got a Null/) + }) + + it('should reject Date as middleware', function () { + var app = express() + assert.throws(function () { app.use('/', new Date()) }, /requires a middleware function but got a Date/) }) it('should strip path from req.url', function (done) { From 44591fee234dd83e05894c5b055703db1f68184c Mon Sep 17 00:00:00 2001 From: chainhelen Date: Thu, 28 Sep 2017 12:25:27 +0800 Subject: [PATCH 1143/1265] deps: vary@~1.1.2 closes #3434 --- History.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 63a1bdf60b7..04b68978330 100644 --- a/History.md +++ b/History.md @@ -26,6 +26,8 @@ unreleased - Fix parsing & compacting very deep objects * deps: setprototypeof@1.1.0 * deps: utils-merge@1.0.1 + * deps: vary@~1.1.2 + - perf: improve header token parsing speed * perf: re-use options object when generating ETags 4.15.5 / 2017-09-24 diff --git a/package.json b/package.json index dbbd7810042..0a476d67d90 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "statuses": "~1.3.1", "type-is": "~1.6.15", "utils-merge": "1.0.1", - "vary": "~1.1.1" + "vary": "~1.1.2" }, "devDependencies": { "after": "0.8.2", From 95fb5cc26848d4c2c57b0a7a74f088538d47d312 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 28 Sep 2017 10:30:10 -0400 Subject: [PATCH 1144/1265] perf: remove dead .charset set in res.jsonp --- History.md | 1 + lib/response.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/History.md b/History.md index 04b68978330..c2d2595731a 100644 --- a/History.md +++ b/History.md @@ -29,6 +29,7 @@ unreleased * deps: vary@~1.1.2 - perf: improve header token parsing speed * perf: re-use options object when generating ETags + * perf: remove dead `.charset` set in `res.jsonp` 4.15.5 / 2017-09-24 =================== diff --git a/lib/response.js b/lib/response.js index 285daf4fb4b..9f61648c17b 100644 --- a/lib/response.js +++ b/lib/response.js @@ -314,7 +314,6 @@ res.jsonp = function jsonp(obj) { // jsonp if (typeof callback === 'string' && callback.length !== 0) { - this.charset = 'utf-8'; this.set('X-Content-Type-Options', 'nosniff'); this.set('Content-Type', 'text/javascript'); From a24fd0ca6cfd29329444fddf678bcdd1c08e56ae Mon Sep 17 00:00:00 2001 From: Aaron Clover Date: Thu, 20 Jul 2017 21:24:04 +1000 Subject: [PATCH 1145/1265] Add options to res.download closes #3327 closes #3370 --- lib/response.js | 34 ++++++++++++++++--- test/res.download.js | 80 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 4 deletions(-) diff --git a/lib/response.js b/lib/response.js index 9f61648c17b..ae028ae81b6 100644 --- a/lib/response.js +++ b/lib/response.js @@ -515,19 +515,29 @@ res.sendfile = deprecate.function(res.sendfile, * when the data transfer is complete, or when an error has * ocurred. Be sure to check `res.headersSent` if you plan to respond. * - * This method uses `res.sendfile()`. + * Optionally providing an `options` object to use with `res.sendFile()`. + * This function will set the `Content-Disposition` header, overriding + * any `Content-Disposition` header passed as header options in order + * to set the attachment and filename. + * + * This method uses `res.sendFile()`. * * @public */ -res.download = function download(path, filename, callback) { +res.download = function download (path, filename, options, callback) { var done = callback; var name = filename; + var opts = options || null - // support function as second arg + // support function as second or third arg if (typeof filename === 'function') { done = filename; name = null; + opts = null + } else if (typeof options === 'function') { + done = options + opts = null } // set Content-Disposition when file is sent @@ -535,10 +545,26 @@ res.download = function download(path, filename, callback) { 'Content-Disposition': contentDisposition(name || path) }; + // merge user-provided headers + if (opts && opts.headers) { + var keys = Object.keys(opts.headers) + for (var i = 0; i < keys.length; i++) { + var key = keys[i] + if (key.toLowerCase() !== 'content-disposition') { + headers[key] = opts.headers[key] + } + } + } + + // merge user-provided options + opts = Object.create(opts) + opts.headers = headers + // Resolve the full path for sendFile var fullPath = resolve(path); - return this.sendFile(fullPath, { headers: headers }, done); + // send file + return this.sendFile(fullPath, opts, done) }; /** diff --git a/test/res.download.js b/test/res.download.js index fad56ee256a..30215bf6764 100644 --- a/test/res.download.js +++ b/test/res.download.js @@ -71,6 +71,86 @@ describe('res', function(){ }) }) + describe('.download(path, filename, options, fn)', function () { + it('should invoke the callback', function (done) { + var app = express() + var cb = after(2, done) + var options = {} + + app.use(function (req, res) { + res.download('test/fixtures/user.html', 'document', options, done) + }) + + request(app) + .get('/') + .expect(200) + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect('Content-Disposition', 'attachment; filename="document"') + .end(cb) + }) + + it('should allow options to res.sendFile()', function (done) { + var app = express() + + app.use(function (req, res) { + res.download('test/fixtures/.name', 'document', { + dotfiles: 'allow', + maxAge: '4h' + }) + }) + + request(app) + .get('/') + .expect(200) + .expect('Content-Disposition', 'attachment; filename="document"') + .expect('Cache-Control', 'public, max-age=14400') + .expect('tobi') + .end(done) + }) + + describe('when options.headers contains Content-Disposition', function () { + it('should should be ignored', function (done) { + var app = express() + + app.use(function (req, res) { + res.download('test/fixtures/user.html', 'document', { + headers: { + 'Content-Type': 'text/x-custom', + 'Content-Disposition': 'inline' + } + }) + }) + + request(app) + .get('/') + .expect(200) + .expect('Content-Type', 'text/x-custom') + .expect('Content-Disposition', 'attachment; filename="document"') + .end(done) + }) + + it('should should be ignored case-insensitively', function (done) { + var app = express() + + app.use(function (req, res) { + res.download('test/fixtures/user.html', 'document', { + headers: { + 'content-type': 'text/x-custom', + 'content-disposition': 'inline' + } + }) + }) + + request(app) + .get('/') + .expect(200) + .expect('Content-Type', 'text/x-custom') + .expect('Content-Disposition', 'attachment; filename="document"') + .end(done) + }) + }) + }) + describe('on failure', function(){ it('should invoke the callback', function(done){ var app = express(); From 628438d8d890f3707b8eecf57aeff7d0da348e8e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 28 Sep 2017 11:36:20 -0400 Subject: [PATCH 1146/1265] deps: update example dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0a476d67d90..addbdcb7f30 100644 --- a/package.json +++ b/package.json @@ -59,18 +59,18 @@ }, "devDependencies": { "after": "0.8.2", - "body-parser": "1.18.1", + "body-parser": "1.18.2", "cookie-parser": "~1.4.3", - "cookie-session": "1.3.1", + "cookie-session": "1.3.2", "ejs": "2.5.7", "eslint": "2.13.1", - "express-session": "1.15.5", + "express-session": "1.15.6", "hbs": "4.0.1", "istanbul": "0.4.5", "marked": "0.3.6", - "method-override": "2.3.9", + "method-override": "2.3.10", "mocha": "3.5.3", - "morgan": "1.8.2", + "morgan": "1.9.0", "multiparty": "4.1.3", "pbkdf2-password": "1.2.1", "should": "13.1.0", From 715401478516c39ea9b2f855d4109d7d6e1131e0 Mon Sep 17 00:00:00 2001 From: Greg Guthe Date: Wed, 5 Apr 2017 17:42:09 -0400 Subject: [PATCH 1147/1265] Add "escape json" setting for res.json and res.jsonp closes #3268 closes #3269 --- History.md | 1 + lib/response.js | 36 +++++++++++++++++++++++++++++++----- test/res.json.js | 22 ++++++++++++++++++++++ test/res.jsonp.js | 22 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index c2d2595731a..248b1c7a678 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * Add `"json escape"` setting for `res.json` and `res.jsonp` * Improve error message when autoloading invalid view engine * Improve error messages when non-function provided as middleware * Skip `Buffer` encoding when not generating ETag for small response diff --git a/lib/response.js b/lib/response.js index ae028ae81b6..832044be9ae 100644 --- a/lib/response.js +++ b/lib/response.js @@ -254,9 +254,10 @@ res.json = function json(obj) { // settings var app = this.app; + var escape = app.get('json escape') var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = stringify(val, replacer, spaces); + var body = stringify(val, replacer, spaces, escape) // content-type if (!this.get('Content-Type')) { @@ -296,9 +297,10 @@ res.jsonp = function jsonp(obj) { // settings var app = this.app; + var escape = app.get('json escape') var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = stringify(val, replacer, spaces); + var body = stringify(val, replacer, spaces, escape) var callback = this.req.query[app.get('jsonp callback name')]; // content-type @@ -1098,14 +1100,38 @@ function sendfile(res, file, options, callback) { } /** - * Stringify JSON, like JSON.stringify, but v8 optimized. + * Stringify JSON, like JSON.stringify, but v8 optimized, with the + * ability to escape characters that can trigger HTML sniffing. + * + * @param {*} value + * @param {function} replaces + * @param {number} spaces + * @param {boolean} escape + * @returns {string} * @private */ -function stringify(value, replacer, spaces) { +function stringify (value, replacer, spaces, escape) { // v8 checks arguments.length for optimizing simple call // https://bugs.chromium.org/p/v8/issues/detail?id=4730 - return replacer || spaces + var json = replacer || spaces ? JSON.stringify(value, replacer, spaces) : JSON.stringify(value); + + if (escape) { + json = json.replace(/[<>&]/g, function (c) { + switch (c.charCodeAt(0)) { + case 0x3c: + return '\\u003c' + case 0x3e: + return '\\u003e' + case 0x26: + return '\\u0026' + default: + return c + } + }) + } + + return json } diff --git a/test/res.json.js b/test/res.json.js index 69f6723af54..1041376235c 100644 --- a/test/res.json.js +++ b/test/res.json.js @@ -102,6 +102,28 @@ describe('res', function(){ }) }) + describe('"json escape" setting', function () { + it('should be undefined by default', function () { + var app = express() + assert.strictEqual(app.get('json escape'), undefined) + }) + + it('should unicode escape HTML-sniffing characters', function (done) { + var app = express() + + app.enable('json escape') + + app.use(function (req, res) { + res.json({ '&': '