Merge tag '4.12.0'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parents a9ef9e1, 51f960f · Browse files · 18 files·+411 added−202 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
18 files+411 added−202 removed
- tests:+241 added−150 removed
- other:+170 added−52 removed
Provenance
- Commit
f6ec710- Tree
9b6f11b- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent 1
a9ef9e1- Parent 2
51f960f
18 files changed+411 added−202 removed
modified:examples/mvc/controllers/pet/views/edit.ejs+1 added-1 removed
6 unmodified lines7 8 <body>9 <h1><%= pet.name %></h1>10 <form action="/pet/<%= pet.id %>?_method=put" method="post">11- <label>Name: <input type="text" name="user[name]" value="<%= pet.name %>"></label>11+ <label>Name: <input type="text" name="pet[name]" value="<%= pet.name %>"></label>12 <input type="submit" value="Update">13 </form>14 </body>15 </html>modified:examples/mvc/lib/boot.js+1 added-1 removed
64 unmodified lines656667686969707172734 unmodified lines64 unmodified lines if (obj.before) { 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); } }
4 unmodified linesmodified:lib/application.js+38 added-2 removed
1+/*!2+ * express3+ * Copyright(c) 2009-2013 TJ Holowaychuk4+ * Copyright(c) 2013 Roman Shtylman5+ * Copyright(c) 2014-2015 Douglas Christopher Wilson6+ * MIT Licensed7+ */8+9 /**10 * Module dependencies.11+ * @api private12 */13 14 var finalhandler = require('finalhandler');15 var flatten = require('./utils').flatten;15 unmodified lines31 32 var app = exports = module.exports = {};33 34 /**35+ * Variable for trust proxy inheritance back-compat36+ * @api private37+ */38+39+var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';40+41+/**42 * Initialize the server.43 *44 * - setup default configuration45 * - setup default middleware42 unmodified lines88 this.set('query parser', 'extended');89 this.set('subdomain offset', 2);90 this.set('trust proxy', false);91 92+ // trust proxy inherit back-compat93+ Object.defineProperty(this.settings, trustProxyDefaultSymbol, {94+ configurable: true,95+ value: true96+ });97+98 debug('booting in %s mode', env);99 78- // inherit protos79- this.on('mount', function(parent){100+ this.on('mount', function onmount(parent) {101+ // inherit trust proxy102+ if (this.settings[trustProxyDefaultSymbol] === true103+ && typeof parent.settings['trust proxy fn'] === 'function') {104+ delete this.settings['trust proxy'];105+ delete this.settings['trust proxy fn'];106+ }107+108+ // inherit protos109 this.request.__proto__ = parent.request;110 this.response.__proto__ = parent.response;111 this.engines.__proto__ = parent.engines;112 this.settings.__proto__ = parent.settings;236 unmodified lines349 break;350 case 'trust proxy':351 debug('compile trust proxy %s', val);352 this.set('trust proxy fn', compileTrust(val));353+354+ // trust proxy inherit back-compat355+ Object.defineProperty(this.settings, trustProxyDefaultSymbol, {356+ configurable: true,357+ value: false358+ });359+360 break;361 }362 363 return this;230 unmodified linesmodified:lib/request.js+4 added-4 removed
61 unmodified lines62 * Check if the given `type(s)` is acceptable, returning63 * the best match when true, otherwise `undefined`, in which64 * case you should respond with 406 "Not Acceptable".65 *66- * The `type` value may be a single mime type string67- * such as "application/json", the extension name68- * such as "json", a comma-delimted list such as "json, html, text/plain",66+ * The `type` value may be a single MIME type string67+ * such as "application/json", an extension name68+ * such as "json", a comma-delimited list such as "json, html, text/plain",69 * an argument list such as `"json", "html", "text/plain"`,70 * or an array `["json", "html", "text/plain"]`. When a list71- * or array is given the _best_ match, if any is returned.71+ * or array is given, the _best_ match, if any is returned.72 *73 * Examples:74 *75 * // Accept: text/html417 unmodified linesmodified:lib/response.js+15 added-10 removed
1+/*!2+ * express3+ * Copyright(c) 2009-2013 TJ Holowaychuk4+ * Copyright(c) 2014-2015 Douglas Christopher Wilson5+ * MIT Licensed6+ */7+8 /**9 * Module dependencies.10+ * @api private11 */12 13 var contentDisposition = require('content-disposition');14 var deprecate = require('depd')('express');133 unmodified lines148 len = chunk.length;149 this.set('Content-Length', len);150 }151 144- // method check145- var isHead = req.method === 'HEAD';146-147- // ETag support148- if (len !== undefined && (isHead || req.method === 'GET')) {149- var etag = app.get('etag fn');150- if (etag && !this.get('ETag')) {151- etag = etag(chunk, encoding);152- etag && this.set('ETag', etag);152+ // populate ETag153+ var etag;154+ var generateETag = len !== undefined && app.get('etag fn');155+ if (typeof generateETag === 'function' && !this.get('ETag')) {156+ if ((etag = generateETag(chunk, encoding))) {157+ this.set('ETag', etag);158 }159 }160 161 // freshness6 unmodified lines168 this.removeHeader('Transfer-Encoding');169 chunk = '';170 }171 167- if (isHead) {172+ if (req.method === 'HEAD') {173 // skip body for HEAD174 this.end();175 } else {176 // respond751 unmodified linesmodified:lib/utils.js+15 added-5 removed
1+/*!2+ * express3+ * Copyright(c) 2009-2013 TJ Holowaychuk4+ * Copyright(c) 2014-2015 Douglas Christopher Wilson5+ * MIT Licensed6+ */7+8 /**9 * Module dependencies.10+ * @api private11 */12 13 var mime = require('send').mime;14+var contentType = require('content-type');15 var etag = require('etag');16 var proxyaddr = require('proxy-addr');17 var qs = require('qs');18 var querystring = require('querystring');10-var typer = require('media-typer');19 20 /**21 * Return strong ETag for `body`.22 *226 unmodified lines249 * @return {String}250 * @api private251 */252 245-exports.setCharset = function(type, charset){246- if (!type || !charset) return type;253+exports.setCharset = function setCharset(type, charset) {254+ if (!type || !charset) {255+ return type;256+ }257 258 // parse type249- var parsed = typer.parse(type);259+ var parsed = contentType.parse(type);260 261 // set charset262 parsed.parameters.charset = charset;263 264 // format type255- return typer.format(parsed);265+ return contentType.format(parsed);266 };modified:test/config.js+74 added-29 removed
1 2-var express = require('../')3- , assert = require('assert');2+var assert = require('assert');3+var express = require('..');4 5-describe('config', function(){6- describe('.set()', function(){7- it('should set a value', function(){5+describe('config', function () {6+ describe('.set()', function () {7+ it('should set a value', function () {8 var app = express();9- app.set('foo', 'bar').should.equal(app);9+ app.set('foo', 'bar');10+ assert.equal(app.get('foo'), 'bar');11 })12 12- it('should return the app when undefined', function(){13+ it('should return the app', function () {14 var app = express();14- app.set('foo', undefined).should.equal(app);15+ assert.equal(app.set('foo', 'bar'), app);16 })17 18+ it('should return the app when undefined', function () {19+ var app = express();20+ assert.equal(app.set('foo', undefined), app);21+ })22+23 describe('"etag"', function(){24 it('should throw on bad value', function(){19- var app = express()20- app.set.bind(app, 'etag', 42).should.throw(/unknown value/)25+ var app = express();26+ assert.throws(app.set.bind(app, 'etag', 42), /unknown value/);27 })28 29 it('should set "etag fn"', function(){30 var app = express()31 var fn = function(){}32 app.set('etag', fn)27- app.get('etag fn').should.equal(fn)33+ assert.equal(app.get('etag fn'), fn)34 })35 })36 37 describe('"trust proxy"', function(){38 it('should set "trust proxy fn"', function(){39 var app = express()40 var fn = function(){}41 app.set('trust proxy', fn)36- app.get('trust proxy fn').should.equal(fn)42+ assert.equal(app.get('trust proxy fn'), fn)43 })44 })45 })46 47 describe('.get()', function(){48 it('should return undefined when unset', function(){49 var app = express();44- assert(undefined === app.get('foo'));50+ assert.strictEqual(app.get('foo'), undefined);51 })52 53 it('should otherwise return the value', function(){54 var app = express();55 app.set('foo', 'bar');50- app.get('foo').should.equal('bar');56+ assert.equal(app.get('foo'), 'bar');57 })58 59 describe('when mounted', function(){60 it('should default to the parent app', function(){55- var app = express()56- , blog = express();61+ var app = express();62+ var blog = express();63 64 app.set('title', 'Express');65 app.use(blog);60- blog.get('title').should.equal('Express');66+ assert.equal(blog.get('title'), 'Express');67 })62- 68+69 it('should given precedence to the child', function(){64- var app = express()65- , blog = express();70+ var app = express();71+ var blog = express();72 73 app.use(blog);74 app.set('title', 'Express');75 blog.set('title', 'Some Blog');76 71- blog.get('title').should.equal('Some Blog');77+ assert.equal(blog.get('title'), 'Some Blog');78 })79+80+ it('should inherit "trust proxy" setting', function () {81+ var app = express();82+ var blog = express();83+84+ function fn() { return false }85+86+ app.set('trust proxy', fn);87+ assert.equal(app.get('trust proxy'), fn);88+ assert.equal(app.get('trust proxy fn'), fn);89+90+ app.use(blog);91+92+ assert.equal(blog.get('trust proxy'), fn);93+ assert.equal(blog.get('trust proxy fn'), fn);94+ })95+96+ it('should prefer child "trust proxy" setting', function () {97+ var app = express();98+ var blog = express();99+100+ function fn1() { return false }101+ function fn2() { return true }102+103+ app.set('trust proxy', fn1);104+ assert.equal(app.get('trust proxy'), fn1);105+ assert.equal(app.get('trust proxy fn'), fn1);106+107+ blog.set('trust proxy', fn2);108+ assert.equal(blog.get('trust proxy'), fn2);109+ assert.equal(blog.get('trust proxy fn'), fn2);110+111+ app.use(blog);112+113+ assert.equal(app.get('trust proxy'), fn1);114+ assert.equal(app.get('trust proxy fn'), fn1);115+ assert.equal(blog.get('trust proxy'), fn2);116+ assert.equal(blog.get('trust proxy fn'), fn2);117+ })118 })119 })120 121 describe('.enable()', function(){122 it('should set the value to true', function(){123 var app = express();79- app.enable('tobi').should.equal(app);80- app.get('tobi').should.be.true;124+ assert.equal(app.enable('tobi'), app);125+ assert.strictEqual(app.get('tobi'), true);126 })127 })128 129 describe('.disable()', function(){130 it('should set the value to false', function(){131 var app = express();87- app.disable('tobi').should.equal(app);88- app.get('tobi').should.be.false;132+ assert.equal(app.disable('tobi'), app);133+ assert.strictEqual(app.get('tobi'), false);134 })135 })136 137 describe('.enabled()', function(){138 it('should default to false', function(){139 var app = express();95- app.enabled('foo').should.be.false;140+ assert.strictEqual(app.enabled('foo'), false);141 })142 143 it('should return true when set', function(){144 var app = express();145 app.set('foo', 'bar');101- app.enabled('foo').should.be.true;146+ assert.strictEqual(app.enabled('foo'), true);147 })148 })149 150 describe('.disabled()', function(){151 it('should default to true', function(){152 var app = express();108- app.disabled('foo').should.be.true;153+ assert.strictEqual(app.disabled('foo'), true);154 })155 156 it('should return false when set', function(){157 var app = express();158 app.set('foo', 'bar');114- app.disabled('foo').should.be.false;159+ assert.strictEqual(app.disabled('foo'), false);160 })161 })162 })modified:test/req.ip.js+17 added
33 unmodified lines3435363738394041424344454647484950515253545556575839 unmodified lines33 unmodified lines .get('/') .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(){ it('should return the remote address', function(done){39 unmodified linesmodified:test/req.signedCookies.js+1 added-1 removed
27 unmodified lines28 request(app)29 .get('/')30 .set('Cookie', cookie)31 .end(function(err, res){32- if (err) return don(err);32+ if (err) return done(err);33 res.body.should.eql({ obj: { foo: 'bar' } });34 done();35 });36 });4 unmodified linesmodified:test/res.download.js+26 added-28 removed
1 2-var express = require('../')3- , request = require('supertest')4- , assert = require('assert');2+var after = require('after');3+var assert = require('assert');4+var express = require('..');5+var request = require('supertest');6 7 describe('res', function(){8 describe('.download(path)', function(){9 it('should transfer as an attachment', function(done){28 unmodified lines38 })39 40 describe('.download(path, fn)', function(){41 it('should invoke the callback', function(done){41- var app = express()42- , calls = 0;42+ var app = express();43+ var cb = after(2, done);44 45 app.use(function(req, res){45- res.download('test/fixtures/user.html', done);46+ res.download('test/fixtures/user.html', cb);47 });48 49 request(app)50 .get('/')51 .expect('Content-Type', 'text/html; charset=UTF-8')52 .expect('Content-Disposition', 'attachment; filename="user.html"')52- .expect(200, function(err){53- assert.ifError(err)54- })53+ .expect(200, cb);54 })55 })56 57 describe('.download(path, filename, fn)', function(){58 it('should invoke the callback', function(done){60- var app = express()61- , calls = 0;59+ var app = express();60+ var cb = after(2, done);61 62 app.use(function(req, res){63 res.download('test/fixtures/user.html', 'document', done);64 });1 unmodified line66 request(app)67 .get('/')68 .expect('Content-Type', 'text/html; charset=UTF-8')69 .expect('Content-Disposition', 'attachment; filename="document"')71- .expect(200, function(err){72- assert.ifError(err)73- })70+ .expect(200, cb);71 })72 })73 74 describe('on failure', function(){75 it('should invoke the callback', function(done){79- var app = express()80- , calls = 0;76+ var app = express();77 82- app.use(function(req, res){78+ app.use(function (req, res, next) {79 res.download('test/fixtures/foobar.html', function(err){84- assert(404 == err.status);85- assert('ENOENT' == err.code);86- done();80+ if (!err) return next(new Error('expected error'));81+ res.send('got ' + err.status + ' ' + err.code);82 });83 });84 85 request(app)86 .get('/')92- .end(function(){});87+ .expect(200, 'got 404 ENOENT', done);88 })89 90 it('should remove Content-Disposition', function(done){91 var app = express()92 , calls = 0;93 99- app.use(function(req, res){94+ app.use(function (req, res, next) {95 res.download('test/fixtures/foobar.html', function(err){96+ if (!err) return next(new Error('expected error'));97 res.end('failed');98 });99 });100 101 request(app)102 .get('/')107- .expect('failed')108- .end(function(err, res){109- if (err) return done(err);110- res.header.should.not.have.property('content-disposition');111- done();112- });103+ .expect(shouldNotHaveHeader('Content-Disposition'))104+ .expect(200, 'failed', done);105 })106 })107 })108+109+function shouldNotHaveHeader(header) {110+ return function (res) {111+ assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header);112+ };113+}modified:test/res.send.js+99 added-90 removed
1 2-var express = require('../')3- , request = require('supertest')4- , assert = require('assert');2+var assert = require('assert');3+var express = require('..');4+var methods = require('methods');5+var request = require('supertest');6 7 describe('res', function(){8 describe('.send(null)', function(){9 it('should set body to ""', function(done){89 unmodified lines99 done();100 })101 })102 102- it('should set ETag', function(done){103+ it('should set ETag', function (done) {104 var app = express();105 105- app.use(function(req, res){106+ app.use(function (req, res) {107 var str = Array(1000).join('-');108 res.send(str);109 });110 111 request(app)112 .get('/')113 .expect('ETag', 'W/"3e7-8084ccd1"')113- .end(done);114+ .expect(200, done);115 })116 116- it('should not set ETag for non-GET/HEAD', function(done){117- var app = express();118-119- app.use(function(req, res){120- var str = Array(1000).join('-');121- res.send(str);122- });123-124- request(app)125- .post('/')126- .end(function(err, res){127- if (err) return done(err);128- assert(!res.header.etag, 'has an ETag');129- done();130- });131- })132-117 it('should not override Content-Type', function(done){118 var app = express();119 120 app.use(function(req, res){50 unmodified lines171 done();172 })173 })174 191- it('should set ETag', function(done){175+ it('should set ETag', function (done) {176 var app = express();177 194- app.use(function(req, res){178+ app.use(function (req, res) {179 var str = Array(1000).join('-');180 res.send(new Buffer(str));181 });182 183 request(app)184 .get('/')185 .expect('ETag', 'W/"3e7-8084ccd1"')202- .end(done);186+ .expect(200, done);187 })188 189 it('should not override Content-Type', function(done){190 var app = express();141 unmodified lines332 .get('/?callback=foo')333 .expect('{"foo":"bar"}', done);334 })335 352- describe('"etag" setting', function(){353- describe('when enabled', function(){354- it('should send ETag', function(done){336+ describe('"etag" setting', function () {337+ describe('when enabled', function () {338+ it('should send ETag', function (done) {339 var app = express();340 357- app.use(function(req, res){341+ app.use(function (req, res) {342 res.send('kajdslfkasdf');343 });344 345 app.enable('etag');346 347 request(app)348 .get('/')365- .expect('etag', 'W/"c-5aee35d8"', done)366- })349+ .expect('ETag', 'W/"c-5aee35d8"')350+ .expect(200, done);351+ });352 368- it('should send ETag for empty string response', function(done){369- var app = express()353+ methods.forEach(function (method) {354+ if (method === 'connect') return;355 356+ it('should send ETag in response to ' + method.toUpperCase() + ' request', function (done) {357+ var app = express();358+359+ app[method]('/', function (req, res) {360+ res.send('kajdslfkasdf');361+ });362+363+ request(app)364+ [method]('/')365+ .expect('ETag', 'W/"c-5aee35d8"')366+ .expect(200, done);367+ })368+ });369+370+ it('should send ETag for empty string response', function (done) {371+ var app = express();372+371- app.use(function(req, res){372- res.send('')373+ app.use(function (req, res) {374+ res.send('');375 });376 375- app.enable('etag')377+ app.enable('etag');378 379 request(app)380 .get('/')379- .expect('etag', 'W/"0-0"', done)381+ .expect('ETag', 'W/"0-0"')382+ .expect(200, done);383 })384 382- it('should send ETag for long response', function(done){385+ it('should send ETag for long response', function (done) {386 var app = express();387 385- app.use(function(req, res){388+ app.use(function (req, res) {389 var str = Array(1000).join('-');390 res.send(str);391 });392 393 app.enable('etag');394 395 request(app)396 .get('/')394- .expect('etag', 'W/"3e7-8084ccd1"', done)397+ .expect('ETag', 'W/"3e7-8084ccd1"')398+ .expect(200, done);399 });400 397- it('should not override ETag when manually set', function(done){401+ it('should not override ETag when manually set', function (done) {402 var app = express();403 400- app.use(function(req, res){404+ app.use(function (req, res) {405 res.set('etag', '"asdf"');406 res.send('hello!');407 });408 409 app.enable('etag');410 411 request(app)412 .get('/')409- .expect('etag', '"asdf"', done)413+ .expect('ETag', '"asdf"')414+ .expect(200, done);415 });416 412- it('should not send ETag for res.send()', function(done){413- var app = express()417+ it('should not send ETag for res.send()', function (done) {418+ var app = express();419 415- app.use(function(req, res){416- res.send()420+ app.use(function (req, res) {421+ res.send();422 });423 419- app.enable('etag')424+ app.enable('etag');425 426 request(app)427 .get('/')423- .end(function(err, res){424- res.headers.should.not.have.property('etag');425- done();426- })428+ .expect(shouldNotHaveHeader('ETag'))429+ .expect(200, done);430 })431 });432 430- describe('when disabled', function(){431- it('should send no ETag', function(done){433+ describe('when disabled', function () {434+ it('should send no ETag', function (done) {435 var app = express();436 434- app.use(function(req, res){437+ app.use(function (req, res) {438 var str = Array(1000).join('-');439 res.send(str);440 });441 442 app.disable('etag');443 444 request(app)445 .get('/')443- .end(function(err, res){444- res.headers.should.not.have.property('etag');445- done();446- });446+ .expect(shouldNotHaveHeader('ETag'))447+ .expect(200, done);448 });449 449- it('should send ETag when manually set', function(done){450+ it('should send ETag when manually set', function (done) {451 var app = express();452 453 app.disable('etag');454 454- app.use(function(req, res){455+ app.use(function (req, res) {456 res.set('etag', '"asdf"');457 res.send('hello!');458 });459 460 request(app)461 .get('/')461- .expect('etag', '"asdf"', done)462+ .expect('ETag', '"asdf"')463+ .expect(200, done);464 });465 });466 465- describe('when "strong"', function(){466- it('should send strong ETag', function(done){467- var app = express()467+ describe('when "strong"', function () {468+ it('should send strong ETag', function (done) {469+ var app = express();470 471 app.set('etag', 'strong');472 471- app.use(function(req, res){473+ app.use(function (req, res) {474 res.send('hello, world!');475 });476 477 request(app)478 .get('/')477- .expect('etag', '"Otu60XkfuuPskIiUxJY4cA=="', done)479+ .expect('ETag', '"Otu60XkfuuPskIiUxJY4cA=="')480+ .expect(200, done);481 })482 })483 481- describe('when "weak"', function(){482- it('should send weak ETag', function(done){483- var app = express()484+ describe('when "weak"', function () {485+ it('should send weak ETag', function (done) {486+ var app = express();487 488 app.set('etag', 'weak');489 487- app.use(function(req, res){490+ app.use(function (req, res) {491 res.send('hello, world!');492 });493 494 request(app)495 .get('/')493- .expect('etag', 'W/"d-58988d13"', done)496+ .expect('ETag', 'W/"d-58988d13"')497+ .expect(200, done)498 })499 })500 497- describe('when a function', function(){498- it('should send custom ETag', function(done){499- var app = express()501+ describe('when a function', function () {502+ it('should send custom ETag', function (done) {503+ var app = express();504 501- app.set('etag', function(body, encoding){505+ app.set('etag', function (body, encoding) {506 var chunk = !Buffer.isBuffer(body)507 ? new Buffer(body, encoding)508 : body;505- chunk.toString().should.equal('hello, world!')506- return '"custom"'509+ chunk.toString().should.equal('hello, world!');510+ return '"custom"';511 });512 509- app.use(function(req, res){513+ app.use(function (req, res) {514 res.send('hello, world!');515 });516 517 request(app)518 .get('/')515- .expect('etag', '"custom"', done)519+ .expect('ETag', '"custom"')520+ .expect(200, done);521 })522 518- it('should not send falsy ETag', function(done){519- var app = express()523+ it('should not send falsy ETag', function (done) {524+ var app = express();525 521- app.set('etag', function(body, encoding){522- return undefined526+ app.set('etag', function (body, encoding) {527+ return undefined;528 });529 525- app.use(function(req, res){530+ app.use(function (req, res) {531 res.send('hello, world!');532 });533 534 request(app)535 .get('/')531- .end(function(err, res){532- res.headers.should.not.have.property('etag')533- done();534- })536+ .expect(shouldNotHaveHeader('ETag'))537+ .expect(200, done);538 })539 })540 })541 })542+543+function shouldNotHaveHeader(header) {544+ return function (res) {545+ assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header)546+ }547+}modified:test/utils.js+24 added-2 removed
1 2-var utils = require('../lib/utils')3- , assert = require('assert');2+var assert = require('assert');3+var utils = require('../lib/utils');4 5 describe('utils.etag(body, encoding)', function(){6 it('should support strings', function(){7 utils.etag('express!')16 unmodified lines24 .should.eql('"1B2M2Y8AsgTpgAmY7PhCfg=="');25 })26 })27 28+describe('utils.setCharset(type, charset)', function () {29+ it('should do anything without type', function () {30+ assert.strictEqual(utils.setCharset(), undefined);31+ });32+33+ it('should return type if not given charset', function () {34+ assert.strictEqual(utils.setCharset('text/html'), 'text/html');35+ });36+37+ it('should keep charset if not given charset', function () {38+ assert.strictEqual(utils.setCharset('text/html; charset=utf-8'), 'text/html; charset=utf-8');39+ });40+41+ it('should set charset', function () {42+ assert.strictEqual(utils.setCharset('text/html', 'utf-8'), 'text/html; charset=utf-8');43+ });44+45+ it('should override charset', function () {46+ assert.strictEqual(utils.setCharset('text/html; charset=iso-8859-1', 'utf-8'), 'text/html; charset=utf-8');47+ });48+});49+50 describe('utils.wetag(body, encoding)', function(){51 it('should support strings', function(){52 utils.wetag('express!')53 .should.eql('W/"8-b8aabac7"')42 unmodified linesmodified:.travis.yml+3 added-6 removed
1 language: node_js2 node_js:3 - "0.10"4- - "0.11"5-matrix:6- allow_failures:7- - node_js: "0.11"8- fast_finish: true9-script: "npm run-script test-travis"4+ - "0.12"5+sudo: false6+script: "npm run-script test-ci"7 after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"added:appveyor.yml+13 added
1+environment:2+ matrix:3+ - nodejs_version: "0.10"4+ - nodejs_version: "0.12"5+install:6+ - ps: Install-Product node $env:nodejs_version7+ - npm install8+build: off9+test_script:10+ - node --version11+ - npm --version12+ - npm run test-ci13+version: "{build}"modified:History.md+53 added-1 removed
1 5.x2 ===3 4-This incorporates all changes after 4.10.1 up to 4.11.2.4+This incorporates all changes after 4.10.1 up to 4.12.0.5 6 5.0.0-alpha.1 / 2014-11-067 ==========================8 15 unmodified lines24 - `req.query` is now a getter instead of a plain property25 * add:26 - `app.router` is a reference to the base router27 28+4.12.0 / 2015-02-2329+===================30+31+ * Fix `"trust proxy"` setting to inherit when app is mounted32+ * Generate `ETag`s for all request responses33+ - No longer restricted to only responses for `GET` and `HEAD` requests34+ * Use `content-type` to parse `Content-Type` headers35+ * deps: accepts@~1.2.436+ - Fix preference sorting to be stable for long acceptable lists37+ - deps: mime-types@~2.0.938+ - deps: negotiator@0.5.139+ * deps: cookie-signature@1.0.640+ * deps: send@0.12.141+ - Always read the stat size from the file42+ - Fix mutating passed-in `options`43+ - deps: mime@1.3.444+ * deps: serve-static@~1.9.145+ - deps: send@0.12.146+ * deps: type-is@~1.6.047+ - fix argument reassignment48+ - fix false-positives in `hasBody` `Transfer-Encoding` check49+ - support wildcard for both type and subtype (`*/*`)50+ - deps: mime-types@~2.0.951+52 4.11.2 / 2015-02-0153 ===================54 55 * Fix `res.redirect` double-calling `res.end` for `HEAD` requests672 unmodified lines728 - `app.router()` - returns the app Router instance729 - `app.route()` - Proxy to the app's `Router#route()` method to create a new route730 - Router & Route - public API731 732+3.20.0 / 2015-02-18733+===================734+735+ * Fix `"trust proxy"` setting to inherit when app is mounted736+ * Generate `ETag`s for all request responses737+ - No longer restricted to only responses for `GET` and `HEAD` requests738+ * Use `content-type` to parse `Content-Type` headers739+ * deps: connect@2.29.0740+ - Use `content-type` to parse `Content-Type` headers741+ - deps: body-parser@~1.12.0742+ - deps: compression@~1.4.1743+ - deps: connect-timeout@~1.6.0744+ - deps: cookie-parser@~1.3.4745+ - deps: cookie-signature@1.0.6746+ - deps: csurf@~1.7.0747+ - deps: errorhandler@~1.3.4748+ - deps: express-session@~1.10.3749+ - deps: http-errors@~1.3.1750+ - deps: response-time@~2.3.0751+ - deps: serve-index@~1.6.2752+ - deps: serve-static@~1.9.1753+ - deps: type-is@~1.6.0754+ * deps: cookie-signature@1.0.6755+ * deps: send@0.12.1756+ - Always read the stat size from the file757+ - Fix mutating passed-in `options`758+ - deps: mime@1.3.4759+760 3.19.2 / 2015-02-01761 ===================762 763 * deps: connect@2.28.31960 unmodified linesmodified:LICENSE+2 added
1 (The MIT License)2 3 Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>4+Copyright (c) 2013-2014 Roman Shtylman <shtylman+expressjs@gmail.com>5+Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>6 7 Permission is hereby granted, free of charge, to any person obtaining8 a copy of this software and associated documentation files (the9 'Software'), to deal in the Software without restriction, including15 unmodified linesmodified:package.json+15 added-15 removed
25 unmodified lines26 "app",27 "api"28 ],29 "dependencies": {30- "accepts": "~1.2.3",30+ "accepts": "~1.2.4",31 "content-disposition": "0.5.0",32+ "content-type": "~1.0.1",32- "cookie-signature": "1.0.5",33+ "cookie-signature": "1.0.6",34 "debug": "~2.1.1",35 "depd": "~1.0.0",36 "escape-html": "1.0.1",37 "etag": "~1.5.1",38 "finalhandler": "0.3.3",39 "fresh": "0.2.4",39- "media-typer": "0.3.0",40 "methods": "~1.1.1",41 "on-finished": "~2.2.0",42 "parseurl": "~1.3.0",43 "path-to-regexp": "0.1.3",44 "proxy-addr": "~1.0.6",45 "qs": "2.3.3",46 "range-parser": "~1.0.2",47- "send": "0.11.1",48- "serve-static": "~1.8.1",49- "type-is": "~1.5.6",47+ "send": "0.12.1",48+ "serve-static": "~1.9.1",49+ "type-is": "~1.6.0",50 "vary": "~1.0.0",51 "cookie": "0.1.2",52 "merge-descriptors": "0.0.2",53 "utils-merge": "1.0.0"54 },55 "devDependencies": {56 "after": "0.8.1",57- "ejs": "2.1.4",58- "istanbul": "0.3.5",57+ "ejs": "2.3.1",58+ "istanbul": "0.3.6",59 "marked": "0.3.3",60 "mocha": "~2.1.0",61- "should": "~4.6.2",61+ "should": "~5.0.1",62 "supertest": "~0.15.0",63 "hjs": "~0.0.6",64- "body-parser": "~1.11.0",64+ "body-parser": "~1.12.0",65 "connect-redis": "~2.2.0",66- "cookie-parser": "~1.3.3",67- "express-session": "~1.10.2",68- "jade": "~1.9.1",66+ "cookie-parser": "~1.3.4",67+ "express-session": "~1.10.3",68+ "jade": "~1.9.2",69 "method-override": "~2.3.1",70 "morgan": "~1.5.1",71 "multiparty": "~4.1.1",72 "vhost": "~3.0.0"9 unmodified lines82 "lib/"83 ],84 "scripts": {85 "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",86+ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",87 "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",87- "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/",88- "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/"88+ "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"89 }90 }modified:Readme.md+10 added-7 removed
2 unmodified lines3 Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).4 5 [![NPM Version][npm-image]][npm-url]6 [![NPM Downloads][downloads-image]][downloads-url]7- [![Build Status][travis-image]][travis-url]7+ [![Linux Build][travis-image]][travis-url]8+ [![Windows Build][appveyor-image]][appveyor-url]9 [![Test Coverage][coveralls-image]][coveralls-url]10 11 ```js12 var express = require('express')108 unmodified lines121 ## License122 123 [MIT](LICENSE)124 124-[npm-image]: https://img.shields.io/npm/v/express.svg?style=flat125+[npm-image]: https://img.shields.io/npm/v/express.svg126 [npm-url]: https://npmjs.org/package/express126-[downloads-image]: https://img.shields.io/npm/dm/express.svg?style=flat127+[downloads-image]: https://img.shields.io/npm/dm/express.svg128 [downloads-url]: https://npmjs.org/package/express128-[travis-image]: https://img.shields.io/travis/strongloop/express.svg?style=flat129+[travis-image]: https://img.shields.io/travis/strongloop/express/master.svg?label=linux130 [travis-url]: https://travis-ci.org/strongloop/express131+[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows132+[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express130-[coveralls-image]: https://img.shields.io/coveralls/strongloop/express.svg?style=flat133+[coveralls-image]: https://img.shields.io/coveralls/strongloop/express/master.svg134 [coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master132-[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg?style=flat135+[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg136 [gratipay-url-visionmedia]: https://gratipay.com/visionmedia/134-[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg?style=flat137+[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg138 [gratipay-url-dougwilson]: https://gratipay.com/dougwilson/