Skip to content
Myr

Merge tag '4.15.4'

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 21f725e, a4bd437 · Browse files · 92 files+495 added−266 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

92 files+495 added−266 removed

  • tests:+126 added−69 removed
  • other:+369 added−197 removed

92 files+495 added−266 removed

modified:benchmarks/middleware.js-1 removed
modified:examples/content-negotiation/db.js+1 added-1 removed
modified:examples/cookie-sessions/index.js+2 added-3 removed
modified:examples/ejs/index.js+1 added-1 removed
modified:examples/mvc/controllers/main/index.js+1 added-1 removed
added:examples/mvc/controllers/user/views/edit.hbs+25 added
1<!DOCTYPE html>2<html>3<head>4 <link rel="stylesheet" href="/style.css">5 <title>Edit {{user.name}}</title>6</head>7<body>8 <h1>{{user.name}}</h1>9 <form action="/user/{{user.id}}?_method=put" method="post">10 <label for="user[name]">Name:11 <input type="text" name="user[name]" value="{{user.name}}">12 </label>1314 <input type="submit" name="submit" value="Update">15 </form>1617 <form action="/user/{{user.id}}/pet" method="post">18 <label for="pet[name]">Pet:19 <input type="text" name="pet[name]" placeholder="Pet Name">20 </label>2122 <input type="submit" name="submit" value="Add">23 </form>24</body>25</html>
deleted:examples/mvc/controllers/user/views/edit.jade-11 removed
1link(rel='stylesheet', href='/style.css')2h1= user.name3form(action='/user/#{user.id}?_method=put', method='post')4 label= 'Name: '5 input(type='text', name='user[name]', value='#{user.name}')6 input(type='submit', value='Update')78form(action='/user/#{user.id}/pet', method='post')9 label= 'Pet: '10 input(type='text', name='pet[name]', placeholder='Name')11 input(type='submit', value='Add')
added:examples/mvc/controllers/user/views/list.hbs+16 added
1<!DOCTYPE html>2<html>3<head>4 <link rel="stylesheet" href="/style.css">5 <title>Users</title>6</head>7<body>8 <h1>Users</h1>9 <p>Click a user below to view their pets.</p>10 <ul>11 {{#each users}}12 <li><a href="/user/{{id}}">{{name}}</a></li>13 {{/each}}14 </ul>15</body>16</html>
deleted:examples/mvc/controllers/user/views/list.jade-7 removed
1link(rel='stylesheet', href='/style.css')2h1 Users3p Click a user below to view their pets.4ul5 each user in users6 li7 a(href='/user/#{user.id}')= user.name
added:examples/mvc/controllers/user/views/show.hbs+29 added
1<!DOCTYPE html>2<html>3<head>4 <link rel="stylesheet" href="/style.css">5 <title>{{user.name}}</title>6</head>7<body>8<h1>{{user.name}} <a href="/user/{{user.id}}/edit">edit</a></h1>910{{#if hasMessages}}11 <ul>12 {{#each messages}}13 <li>{{this}}</li>14 {{/each}}15 </ul>16{{/if}}1718{{#if user.pets.length}}19 <p>View {{user.name}}'s pets:</p>20 <ul>21 {{#each user.pets}}22 <li><a href="/pet/{{id}}">{{name}}</a></li>23 {{/each}}24 </ul>25{{else}}26 <p>No pets!</p>27{{/if}}28</body>29</html>
deleted:examples/mvc/controllers/user/views/show.jade-17 removed
1link(rel='stylesheet', href='/style.css')2h1= user.name + ' '3 a(href='/user/#{user.id}/edit') edit45if (hasMessages)6 ul#messages7 each msg in messages8 li= msg910if (user.pets.length)11 p View #{user.name}'s pets:12 ul13 each pet in user.pets14 li15 a(href='/pet/#{pet.id}')= pet.name16else17 p No pets!
modified:examples/mvc/controllers/user/index.js+2 added
2 unmodified lines
3 */45var db = require('../../db');67exports.engine = 'hbs';89exports.before = function(req, res, next){10 var id = req.params.user_id;11 if (!id) return next();12 // pretend to query a database...
27 unmodified lines
added:examples/mvc/views/404.ejs+12 added
1<!DOCTYPE html>2<html>3 <head>4 <meta charset="utf-8">5 <title>Not Found</title>6 <link rel="stylesheet" href="/style.css">7 </head>8 <body>9 <h1>404: Not Found</h1>10 <p>Sorry we can't find <%= url %></p>11 </body>12</html>
deleted:examples/mvc/views/404.jade-3 removed
1link(rel='stylesheet', href='/style.css')2h1 404: Not Found3p Sorry we can't find #{url}
added:examples/mvc/views/5xx.ejs+12 added
1<!DOCTYPE html>2<html>3 <head>4 <meta charset="utf-8">5 <title>Internal Server Error</title>6 <link rel="stylesheet" href="/style.css">7 </head>8 <body>9 <h1>500: Internal Server Error</h1>10 <p>Looks like something blew up!</p>11 </body>12</html>
deleted:examples/mvc/views/5xx.jade-3 removed
1link(rel='stylesheet', href='/style.css')2h1 500: Internal Server Error3p Looks like something blew up!
modified:examples/mvc/db.js+1 added-1 removed
9 unmodified lines
10var users = exports.users = [];1112users.push({ name: 'TJ', pets: [pets[0], pets[1], pets[2]], id: 0 });13users.push({ name: 'Guillermo', pets: [pets[3]], id: 1 });14users.push({ name: 'Nathan', pets: [], id: 2 });14users.push({ name: 'Nathan', pets: [], id: 2 });
modified:examples/mvc/index.js+3 added-5 removed
9 unmodified lines
10var methodOverride = require('method-override');1112var app = module.exports = express();1314// settings14// set our default template engine to "ejs"15// which prevents the need for using file extensions16app.set('view engine', 'ejs');1716// set our default template engine to "jade"17// which prevents the need for extensions18app.set('view engine', 'jade');1918// set views for error and 404 pages19app.set('views', path.join(__dirname, 'views'));2021// define a custom res.message() method
73 unmodified lines
modified:examples/online/index.js+5 added-1 removed
1// first:12// install redis first:3// https://redis.io/45// then:6// $ npm install redis online7// $ redis-server89/**
51 unmodified lines
modified:examples/params/index.js+1 added-1 removed
66 unmodified lines
67app.get('/users/:from-:to', function(req, res, next){68 var from = req.params.from;69 var to = req.params.to;70 var names = users.map(function(user){ return user.name; });71 res.send('users ' + names.slice(from, to).join(', '));71 res.send('users ' + names.slice(from, to + 1).join(', '));72});7374/* istanbul ignore next */75if (!module.parent) {
3 unmodified lines
modified:examples/resource/index.js+1 added-1 removed
73 unmodified lines
74app.resource('/users', User);7576app.get('/', function(req, res){77 res.send([78 '<h1>Examples:</h1> <ul>'78 '<h1>Examples:</h1> <ul>'79 , '<li>GET /users</li>'80 , '<li>GET /users/1</li>'81 , '<li>GET /users/3</li>'82 , '<li>GET /users/1..3</li>'
11 unmodified lines
added:examples/route-separation/views/posts/index.ejs+12 added
1<% include ../header %>23<h1>Posts</h1>45<dl id="posts">6 <% posts.forEach(function(post) { %>7 <dt><%= post.title %></dt>8 <dd><%= post.body %></dd>9 <% }) %>10</dl>1112<% include ../footer %>
deleted:examples/route-separation/views/posts/index.jade-8 removed
1extends ../layout23block content4 h1 Posts5 dl#posts6 for post in posts7 dt= post.title8 dd= post.body
added:examples/route-separation/views/users/edit.ejs+23 added
1<% include ../header %>23<h1>Editing <%= user.name %></h1>45<div id="user">6 <form action="?_method=put", method="post">7 <p>8 Name:9 <input type="text" value="<%= user.name %>" name="user[name]" />10 </p>1112 <p>13 Email:14 <input type="email" value="<%= user.email %>" name="user[email]" />15 </p>1617 <p>18 <input type="submit" value="Save" />19 </p>20 </form>21</div>2223<% include ../footer %>
deleted:examples/route-separation/views/users/edit.jade-12 removed
1extends ../layout23block content4 h1 Editing #{user.name}5 #user6 form(action="?_method=put", method="post")7 p Name: 8 input(type="text", value= user.name, name="user[name]")9 p Email: 10 input(type="text", value= user.email, name="user[email]")11 p 12 input(type="submit", value="Save")
added:examples/route-separation/views/users/index.ejs+14 added
1<% include ../header %>23<h1><%= title %></h1>45<div id="users">6 <% users.forEach(function(user, index) { %>7 <li>8 <a href="/user/<%= index %>"><%= user.name %></a>9 <a href="/user/<%= index %>/edit">edit</a>10 </li>11 <% }) %>12</div>1314<% include ../footer %>
deleted:examples/route-separation/views/users/index.jade-9 removed
1extends ../layout23block content4 h1 Users5 #users6 for user, i in users7 li8 a(href="/user/#{i}")= user.name9 a.edit(href="/user/#{i}/edit") edit
added:examples/route-separation/views/users/view.ejs+9 added
1<% include ../header %>23<h1><%= user.name %></h1>45<div id="user">6 <p>Email: <%= user.email %></p>7</div>89<% include ../footer %>
deleted:examples/route-separation/views/users/view.jade-6 removed
1extends ../layout23block content4 h1= user.name5 #user6 p Email: #{user.email}
added:examples/route-separation/views/footer.ejs+2 added
1</body>2</html>
added:examples/route-separation/views/header.ejs+8 added
1<!DOCTYPE html>2<html lang="en">3<head>4 <meta charset="utf-8">5 <title><%= title %></title>6 <link rel="stylesheet" href="/style.css">7</head>8<body>
added:examples/route-separation/views/index.ejs+10 added
1<% include header %>23<h1><%= title %></h1>45<ul>6 <li>Visit the <a href="/users">users</a> page.</li>7 <li>Visit the <a href="/posts">posts</a> page.</li>8</ul>910<% include footer %>
deleted:examples/route-separation/views/index.jade-6 removed
1extends layout23block content4 ul5 li Visit the <a href="/users">users</a> page6 li Visit the <a href="/posts">posts</a> page
deleted:examples/route-separation/views/layout.jade-6 removed
1html2 head3 title= title4 link(href="/style.css", rel="stylesheet")5 body6 block content
modified:examples/route-separation/index.js+1 added-1 removed
15 unmodified lines
16module.exports = app;1718// Config1920app.set('view engine', 'jade');20app.set('view engine', 'ejs');21app.set('views', path.join(__dirname, 'views'));2223/* istanbul ignore next */24if (!module.parent) {
30 unmodified lines
modified:examples/route-separation/site.js+1 added-1 removed
1exports.index = function(req, res){2 res.render('index', { title: 'Route Separation Example' });3};3};
modified:examples/search/public/client.js+1 added-1 removed
8 unmodified lines
9 code.textContent = xhr.responseText;10 }11 };12 xhr.send();13}, false);13}, false);
modified:examples/search/index.js+5 added-1 removed
1// first:12// install redis first:3// https://redis.io/45// then:6// $ npm install redis7// $ redis-server89/**
51 unmodified lines
modified:examples/session/index.js+5 added-1 removed
1// first:12// install redis first:3// https://redis.io/45// then:6// $ npm install redis7// $ redis-server89var express = require('../..');
27 unmodified lines
modified:examples/static-files/public/js/app.js+1 added-1 removed
1foo1foo
modified:examples/view-constructor/github-view.js+1 added-1 removed
1/**2 * Module dependencies.3 */45var http = require('http');5var https = require('https');6var path = require('path');7var extname = path.extname;89/**
42 unmodified lines
modified:examples/view-constructor/index.js-1 removed
1 unmodified line
2 * Module dependencies.3 */45var express = require('../../');6var http = require('http');6var GithubView = require('./github-view');7var md = require('marked').parse;89var app = module.exports = express();
37 unmodified lines
added:examples/view-locals/views/index.ejs+19 added
1<!DOCTYPE html>2<html>3 <head>4 <meta charset="utf-8">5 <title><%= title %></title>6 <style media="screen">7 body {8 padding: 50px;9 font: 16px Helvetica, Arial;10 }11 </style>12 </head>13 <body>14 <h2><%= title %></h2>15 <% users.forEach(function(user) { %>16 <li><strong><%= user.name %></strong> is a <% user.age %> year old <%= user.species %></li>17 <% }); %>18 </body>19</html>
modified:examples/view-locals/index.js+6 added-5 removed
1 unmodified line
2 * Module dependencies.3 */45var express = require('../..');6var path = require('path');7var User = require('./user');8var app = express();99app.set('views', __dirname);10app.set('view engine', 'jade');10app.set('views', path.join(__dirname, 'views'));11app.set('view engine', 'ejs');1213// filter ferrets only1415function ferrets(user) {
9 unmodified lines
25 User.count(function(err, count){26 if (err) return next(err);27 User.all(function(err, users){28 if (err) return next(err);28 res.render('user', {29 res.render('index', {30 title: 'Users',31 count: count,32 users: users.filter(ferrets)33 });
25 unmodified lines
59 })60}6162app.get('/middleware', count, users, function(req, res, next){62 res.render('user', {63 res.render('index', {64 title: 'Users',65 count: req.count,66 users: req.users.filter(ferrets)67 });
33 unmodified lines
101 // you can see now how we have much less102 // to pass to res.render(). If we have103 // several routes related to users this104 // can be a great productivity booster104 res.render('user', { title: 'Users' });105 res.render('index', { title: 'Users' });106});107108// keep in mind that middleware may be placed anywhere109// and in various combinations, so if you have locals
44 unmodified lines
deleted:examples/view-locals/layout.jade-12 removed
1doctype html2html3 head4 title= title5 style.6 body {7 padding: 50px;8 font: 16px Helvetica, Arial;9 }10 body11 h2= title12 block content
deleted:examples/view-locals/user.jade-8 removed
12extends layout34block content5 for user in users6 .user7 h3= user.name8 p #{user.name} is a #{user.age} year old #{user.species}.
modified:examples/web-service/index.js+1 added-1 removed
59 unmodified lines
60 , { name: 'jane' }61];6263var userRepos = {64 tobi: [repos[0], repos[1]]64 tobi: [repos[0], repos[1]]65 , loki: [repos[1]]66 , jane: [repos[2]]67};68
44 unmodified lines
modified:lib/application.js+9 added-9 removed
23 unmodified lines
24var flatten = require('array-flatten');25var merge = require('utils-merge');26var resolve = require('path').resolve;27var Router = require('router');28var setPrototyeOf = require('setprototypeof')28var setPrototypeOf = require('setprototypeof')29var slice = Array.prototype.slice;3031/**32 * Application prototype.
76 unmodified lines
109 delete this.settings['trust proxy fn'];110 }111112 // inherit protos113 setPrototyeOf(this.request, parent.request)114 setPrototyeOf(this.response, parent.response)115 setPrototyeOf(this.engines, parent.engines)116 setPrototyeOf(this.settings, parent.settings)113 setPrototypeOf(this.request, parent.request)114 setPrototypeOf(this.response, parent.response)115 setPrototypeOf(this.engines, parent.engines)116 setPrototypeOf(this.settings, parent.settings)117 });118119 // setup locals120 this.locals = Object.create(null);
39 unmodified lines
160 req.res = res;161 res.req = req;162163 // alter the prototypes164 setPrototyeOf(req, this.request)165 setPrototyeOf(res, this.response)164 setPrototypeOf(req, this.request)165 setPrototypeOf(res, this.response)166167 // setup locals168 if (!res.locals) {169 res.locals = Object.create(null);
54 unmodified lines
224 // restore .app property on req and res225 router.use(path, function mounted_app(req, res, next) {226 var orig = req.app;227 fn.handle(req, res, function (err) {228 setPrototyeOf(req, orig.request)229 setPrototyeOf(res, orig.response)228 setPrototypeOf(req, orig.request)229 setPrototypeOf(res, orig.response)230 next(err);231 });232 });233
397 unmodified lines
modified:lib/response.js+9 added-4 removed
595 unmodified lines
596 ? val.map(String)597 : String(val);598599 // add charset to content-type600 if (field.toLowerCase() === 'content-type') {601 if (Array.isArray(value)) {602 throw new TypeError('Content-Type cannot be set to an Array');603 }600 if (field.toLowerCase() === 'content-type' && !charsetRegExp.test(value)) {601 var charset = mime.charsets.lookup(value.split(';')[0]);602 if (charset) value += '; charset=' + charset.toLowerCase();604 if (!charsetRegExp.test(value)) {605 var charset = mime.charsets.lookup(value.split(';')[0]);606 if (charset) value += '; charset=' + charset.toLowerCase();607 }608 }609610 this.setHeader(field, value);611 } else {
49 unmodified lines
661 * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })662 *663 * @param {String} name664 * @param {String|Object} value660 * @param {Options} options665 * @param {Object} [options]666 * @return {ServerResponse} for chaining667 * @public668 */669
281 unmodified lines
modified:lib/utils.js-1 removed
13 unmodified lines
1415var mime = require('send').mime;16var contentType = require('content-type');17var etag = require('etag');18var flatten = require('array-flatten');18var proxyaddr = require('proxy-addr');19var qs = require('qs');20var querystring = require('querystring');21
225 unmodified lines
modified:lib/view.js-1 removed
14 unmodified lines
1516var debug = require('debug')('express:view');17var path = require('path');18var fs = require('fs');19var utils = require('./utils');1920/**21 * Module variables.22 * @private
175 unmodified lines
modified:test/acceptance/cookie-sessions.js+3 added-3 removed
5 unmodified lines
6 describe('GET /', function () {7 it('should display no views', function (done) {8 request(app)9 .get('/')10 .expect(200, 'viewed 0 times\n', done)10 .expect(200, 'viewed 1 times\n', done)11 })1213 it('should set a session cookie', function (done) {14 request(app)
4 unmodified lines
1920 it('should display 1 view on revisit', function (done) {21 request(app)22 .get('/')23 .expect(200, 'viewed 0 times\n', function (err, res) {23 .expect(200, 'viewed 1 times\n', function (err, res) {24 if (err) return done(err)25 request(app)26 .get('/')27 .set('Cookie', getCookies(res))28 .expect(200, 'viewed 1 times\n', done)28 .expect(200, 'viewed 2 times\n', done)29 })30 })31 })32})
6 unmodified lines
modified:test/acceptance/error-pages.js+1 added-1 removed
97 unmodified lines
98 .expect(500, done)99 })100 })101 })102})102})
modified:test/acceptance/error.js+1 added-1 removed
24 unmodified lines
25 .get('/missing')26 .expect(404,done)27 })28 })29})29})
modified:test/acceptance/params.js+2 added-2 removed
27 unmodified lines
2829 describe('GET /users/0-2', function(){30 it('should respond with three users', function(done){31 request(app)32 .get('/users/0-2')33 .expect(/users tj, tobi/,done)32 .get('/users/0-2')33 .expect(/users tj, tobi, loki/, done)34 })35 })3637 describe('GET /users/foo-bar', function(){
7 unmodified lines
modified:test/acceptance/route-map.js+1 added-1 removed
40 unmodified lines
41 .del('/users/12/pets/2')42 .expect('delete 12\'s pet 2', done);43 })44 })45})45})
modified:test/app.engine.js+2 added-2 removed
45 unmodified lines
46 str.should.equal('<p>tobi</p>');47 done();48 })49 })50 5051 it('should work "view engine" setting', function(done){52 var app = express();5354 app.set('views', path.join(__dirname, 'fixtures'))
6 unmodified lines
61 str.should.equal('<p>tobi</p>');62 done();63 })64 })65 6566 it('should work "view engine" with leading "."', function(done){67 var app = express();6869 app.set('views', path.join(__dirname, 'fixtures'))
12 unmodified lines
modified:test/app.js+2 added-2 removed
72 unmodified lines
73describe('in development', function(){74 it('should disable "view cache"', function(){75 process.env.NODE_ENV = 'development';76 var app = express();77 app.enabled('view cache').should.be.false;77 app.enabled('view cache').should.be.false()78 process.env.NODE_ENV = 'test';79 })80})8182describe('in production', function(){83 it('should enable "view cache"', function(){84 process.env.NODE_ENV = 'production';85 var app = express();86 app.enabled('view cache').should.be.true;86 app.enabled('view cache').should.be.true()87 process.env.NODE_ENV = 'test';88 })89})90
8 unmodified lines
modified:test/app.listen.js-1 removed
12var express = require('../')3 , request = require('supertest');34describe('app.listen()', function(){5 it('should wrap with an HTTP server', function(done){6 var app = express();
11 unmodified lines
modified:test/app.locals.js-1 removed
12var express = require('../')3 , request = require('supertest');34describe('app', function(){5 describe('.locals(obj)', function(){6 it('should merge locals', function(){
20 unmodified lines
modified:test/app.param.js+3 added-3 removed
14 unmodified lines
15 });1617 app.get('/post/:id', function(req, res){18 var id = req.params.id;19 id.should.be.a.Number;19 id.should.be.a.Number()20 res.send('' + id);21 });2223 app.get('/user/:uid', function(req, res){24 var id = req.params.id;25 id.should.be.a.Number;25 id.should.be.a.Number()26 res.send('' + id);27 });2829 request(app)
19 unmodified lines
49 });5051 app.get('/user/:id', function(req, res){52 var id = req.params.id;53 id.should.be.a.Number;53 id.should.be.a.Number()54 res.send('' + id);55 });5657 request(app)
268 unmodified lines
modified:test/app.render.js+1 added-1 removed
70 unmodified lines
7172 app.set('view', View);7374 app.render('something', function(err, str){75 err.should.be.ok;75 err.should.be.ok()76 err.message.should.equal('err!');77 done();78 })79 })
296 unmodified lines
modified:test/app.router.js-1 removed
37 unmodified lines
38 if (method === 'connect') return;3940 it('should include ' + method.toUpperCase(), function(done){41 var app = express();42 var calls = [];4243 app[method]('/foo', function(req, res){44 if ('head' == method) {45 res.end();
1043 unmodified lines
modified:test/app.routes.error.js+4 added-4 removed
42 unmodified lines
43 }, function(err, req, res, next){44 d = true;45 next();46 }, function(req, res){47 a.should.be.false;48 b.should.be.true;49 c.should.be.true;50 d.should.be.false;47 a.should.be.false()48 b.should.be.true()49 c.should.be.true()50 d.should.be.false()51 res.sendStatus(204);52 });5354 request(app)
5 unmodified lines
modified:test/config.js+6 added-6 removed
47 unmodified lines
48 it('should return undefined when unset', function(){49 var app = express();50 assert.strictEqual(app.get('foo'), undefined);51 })52 5253 it('should otherwise return the value', function(){54 var app = express();55 app.set('foo', 'bar');56 assert.equal(app.get('foo'), 'bar');
67 unmodified lines
124 assert.equal(app.enable('tobi'), app);125 assert.strictEqual(app.get('tobi'), true);126 })127 })128 128129 describe('.disable()', function(){130 it('should set the value to false', function(){131 var app = express();132 assert.equal(app.disable('tobi'), app);133 assert.strictEqual(app.get('tobi'), false);134 })135 })136 136137 describe('.enabled()', function(){138 it('should default to false', function(){139 var app = express();140 assert.strictEqual(app.enabled('foo'), false);141 })142 142143 it('should return true when set', function(){144 var app = express();145 app.set('foo', 'bar');146 assert.strictEqual(app.enabled('foo'), true);147 })148 })149 149150 describe('.disabled()', function(){151 it('should default to true', function(){152 var app = express();153 assert.strictEqual(app.disabled('foo'), true);154 })155 155156 it('should return false when set', function(){157 var app = express();158 app.set('foo', 'bar');159 assert.strictEqual(app.disabled('foo'), false);
3 unmodified lines
modified:test/exports.js+4 added-5 removed
12var express = require('../');3var request = require('supertest');4var should = require('should');45describe('exports', function(){6 it('should expose Router', function(){8 express.Router.should.be.a.Function;7 express.Router.should.be.a.Function()8 })910 it('should expose the application prototype', function(){12 express.application.set.should.be.a.Function;11 express.application.set.should.be.a.Function()12 })1314 it('should expose the request prototype', function(){16 express.request.accepts.should.be.a.Function;15 express.request.accepts.should.be.a.Function()16 })1718 it('should expose the response prototype', function(){20 express.response.send.should.be.a.Function;19 express.response.send.should.be.a.Function()20 })2122 it('should permit modifying the .application prototype', function(){23 express.application.foo = function(){ return 'bar'; };
29 unmodified lines
modified:test/req.acceptsEncodings.js+3 added-3 removed
6 unmodified lines
7 it('should be true if encoding accepted', function(done){8 var app = express();910 app.use(function(req, res){11 req.acceptsEncodings('gzip').should.be.ok;12 req.acceptsEncodings('deflate').should.be.ok;11 req.acceptsEncodings('gzip').should.be.ok()12 req.acceptsEncodings('deflate').should.be.ok()13 res.end();14 });1516 request(app)
5 unmodified lines
22 it('should be false if encoding not accepted', function(done){23 var app = express();2425 app.use(function(req, res){26 req.acceptsEncodings('bogus').should.not.be.ok;26 req.acceptsEncodings('bogus').should.not.be.ok()27 res.end();28 });2930 request(app)
6 unmodified lines
modified:test/req.acceptsLanguages.js+6 added-6 removed
6 unmodified lines
7 it('should be true if language accepted', function(done){8 var app = express();910 app.use(function(req, res){11 req.acceptsLanguages('en-us').should.be.ok;12 req.acceptsLanguages('en').should.be.ok;11 req.acceptsLanguages('en-us').should.be.ok()12 req.acceptsLanguages('en').should.be.ok()13 res.end();14 });1516 request(app)
5 unmodified lines
22 it('should be false if language not accepted', function(done){23 var app = express();2425 app.use(function(req, res){26 req.acceptsLanguages('es').should.not.be.ok;26 req.acceptsLanguages('es').should.not.be.ok()27 res.end();28 });2930 request(app)
6 unmodified lines
37 it('should always return true', function(done){38 var app = express();3940 app.use(function(req, res){41 req.acceptsLanguages('en').should.be.ok;42 req.acceptsLanguages('es').should.be.ok;43 req.acceptsLanguages('jp').should.be.ok;41 req.acceptsLanguages('en').should.be.ok()42 req.acceptsLanguages('es').should.be.ok()43 req.acceptsLanguages('jp').should.be.ok()44 res.end();45 });4647 request(app)
6 unmodified lines
modified:test/req.host.js-1 removed
12var express = require('../')3 , request = require('supertest')4 , assert = require('assert');45describe('req', function(){6 describe('.host', function(){7 it('should return the Host when present', function(done){
148 unmodified lines
modified:test/req.hostname.js-1 removed
12var express = require('../')3 , request = require('supertest')4 , assert = require('assert');45describe('req', function(){6 describe('.hostname', function(){7 it('should return the Host when present', function(done){
130 unmodified lines
modified:test/req.range.js-1 removed
12var assert = require('assert');2var express = require('..');3var request = require('supertest')45describe('req', function(){
98 unmodified lines
modified:test/req.xhr.js+4 added-4 removed
6 unmodified lines
7 it('should return true when X-Requested-With is xmlhttprequest', function(done){8 var app = express();910 app.use(function(req, res){11 req.xhr.should.be.true;11 req.xhr.should.be.true()12 res.end();13 });1415 request(app)
8 unmodified lines
24 it('should case-insensitive', function(done){25 var app = express();2627 app.use(function(req, res){28 req.xhr.should.be.true;28 req.xhr.should.be.true()29 res.end();30 });3132 request(app)
8 unmodified lines
41 it('should return false otherwise', function(done){42 var app = express();4344 app.use(function(req, res){45 req.xhr.should.be.false;45 req.xhr.should.be.false()46 res.end();47 });4849 request(app)
8 unmodified lines
58 it('should return false when not present', function(done){59 var app = express();6061 app.use(function(req, res){62 req.xhr.should.be.false;62 req.xhr.should.be.false()63 res.end();64 });6566 request(app)
8 unmodified lines
modified:test/res.download.js-1 removed
87 unmodified lines
88 })8990 it('should remove Content-Disposition', function(done){91 var app = express()92 , calls = 0;9293 app.use(function (req, res, next) {94 res.download('test/fixtures/foobar.html', function(err){95 if (!err) return next(new Error('expected error'));
17 unmodified lines
modified:test/res.format.js-1 removed
12var express = require('../')3 , request = require('supertest')4 , utils = require('../lib/utils')4 , assert = require('assert');56var app1 = express();7
205 unmodified lines
modified:test/res.location.js+58 added
40 unmodified lines
41 .get('/')42 .expect('Location', 'https://google.com?q=%A710')43 .expect(200, done)44 })4546 describe('when url is "back"', function () {47 it('should set location from "Referer" header', function (done) {48 var app = express()4950 app.use(function (req, res) {51 res.location('back').end()52 })5354 request(app)55 .get('/')56 .set('Referer', '/some/page.html')57 .expect('Location', '/some/page.html')58 .expect(200, done)59 })6061 it('should set location from "Referrer" header', function (done) {62 var app = express()6364 app.use(function (req, res) {65 res.location('back').end()66 })6768 request(app)69 .get('/')70 .set('Referrer', '/some/page.html')71 .expect('Location', '/some/page.html')72 .expect(200, done)73 })7475 it('should prefer "Referrer" header', function (done) {76 var app = express()7778 app.use(function (req, res) {79 res.location('back').end()80 })8182 request(app)83 .get('/')84 .set('Referer', '/some/page1.html')85 .set('Referrer', '/some/page2.html')86 .expect('Location', '/some/page2.html')87 .expect(200, done)88 })8990 it('should set the header to "/" without referrer', function (done) {91 var app = express()9293 app.use(function (req, res) {94 res.location('back').end()95 })9697 request(app)98 .get('/')99 .expect('Location', '/')100 .expect(200, done)101 })102 })103 })104})
modified:test/res.send.js-1 removed
12var assert = require('assert');2var express = require('..');3var methods = require('methods');4var request = require('supertest');5var utils = require('./support/utils');
529 unmodified lines
modified:test/res.sendFile.js+4 added-5 removed
12var after = require('after');3var express = require('../')4 , request = require('supertest')5 , assert = require('assert');5var onFinished = require('on-finished');6var path = require('path');7var should = require('should');8var fixtures = path.join(__dirname, 'fixtures');
97 unmodified lines
106 test.abort();107 });108109 app.use(function (err, req, res, next) {111 err.code.should.be.empty;110 err.code.should.be.empty()111 cb();112 });113114 var test = request(app).get('/');
107 unmodified lines
222223 app.use(function (req, res) {224 setImmediate(function () {225 res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {227 should(err).be.ok;226 should(err).be.ok()227 err.code.should.equal('ECONNABORTED');228 cb();229 });230 });
10 unmodified lines
241242 app.use(function (req, res) {243 onFinished(res, function () {244 res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {246 should(err).be.ok;245 should(err).be.ok()246 err.code.should.equal('ECONNABORTED');247 cb();248 });249 });
42 unmodified lines
292 var app = express();293294 app.use(function (req, res) {295 res.sendFile(path.resolve(fixtures, 'does-not-exist'), function (err) {297 should(err).be.ok;296 should(err).be.ok()297 err.status.should.equal(404);298 res.send('got it');299 });300 });
25 unmodified lines
modified:test/res.sendStatus.js-1 removed
12var assert = require('assert')2var express = require('..')3var request = require('supertest')45describe('res', function () {
26 unmodified lines
modified:test/res.set.js+13 added
71 unmodified lines
72 .get('/')73 .expect('Content-Type', 'text/html; charset=lol')74 .expect(200, done);75 })7677 it('should throw when Content-Type is an array', function (done) {78 var app = express()7980 app.use(function (req, res) {81 res.set('Content-Type', ['text/html'])82 res.end()83 });8485 request(app)86 .get('/')87 .expect(500, /TypeError: Content-Type cannot be set to an Array/, done)88 })89 })9091 describe('.set(object)', function(){92 it('should set multiple fields', function(done){
31 unmodified lines
modified:test/res.vary.js-1 removed
12var assert = require('assert');2var express = require('..');3var request = require('supertest');4var utils = require('./support/utils');5
84 unmodified lines
modified:test/Route.js+7 added-8 removed
2 unmodified lines
3var should = require('should');4var express = require('../')5 , Route = express.Route6 , methods = require('methods')7 , assert = require('assert');78describe('Route', function(){9 it('should work without handlers', function(done) {10 var req = { method: 'GET', url: '/' }
12 unmodified lines
23 });2425 route.dispatch(req, {}, function (err) {26 if (err) return done(err);28 should(req.called).be.ok;27 should(req.called).be.ok()28 done();29 });30 })31
50 unmodified lines
82 })8384 route.dispatch(req, {}, function (err) {85 if (err) return done(err);87 should(req.called).be.ok;86 should(req.called).be.ok()87 done();88 });89 })90
11 unmodified lines
102 })103104 route.dispatch(req, {}, function (err) {105 if (err) return done(err);107 should(req.called).be.true;106 should(req.called).be.true()107 done();108 });109 })110
43 unmodified lines
154 next(err);155 });156157 route.dispatch(req, {}, function (err) {159 should(err).be.ok;158 should(err).be.ok()159 should(err.message).equal('foobar');160 req.order.should.equal('a');161 done();162 });
17 unmodified lines
180 next(err);181 });182183 route.dispatch(req, {}, function (err) {185 should(err).be.ok;184 should(err).be.ok()185 should(err.message).equal('foobar');186 req.order.should.equal('a');187 done();188 });
31 unmodified lines
220 throw new Error('boom!');221 });222223 route.dispatch(req, {}, function(err){225 should(err).be.ok;224 should(err).be.ok()225 err.message.should.equal('boom!');226 done();227 });228 });
3 unmodified lines
232 var route = new Route('');233234 route.all(function(err, req, res, next){235 // this should not execute237 true.should.be.false;236 true.should.be.false()237 });238239 route.dispatch(req, {}, done);240 });
2 unmodified lines
modified:test/Router.js+1 added-1 removed
45 unmodified lines
46 it('should handle blank URL', function(done){47 var router = new Router();4849 router.use(function (req, res) {50 false.should.be.true;50 false.should.be.true()51 });5253 router.handle({ url: '', method: 'GET' }, {}, done);54 });
507 unmodified lines
added:.editorconfig+11 added
1# http://editorconfig.org2root = true34[*]5charset = utf-86insert_final_newline = true7trim_trailing_whitespace = true89[{*.js,*.json,*.yml}]10indent_size = 211indent_style = space
added:.eslintignore+2 added
1coverage2node_modules
added:.eslintrc+8 added
1{2 "rules": {3 "eol-last": "error",4 "indent": ["error", 2, { "SwitchCase": 1 }],5 "no-trailing-spaces": "error",6 "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }]7 }8}
modified:.travis.yml+5 added-3 removed
5 unmodified lines
6 - "2.5"7 - "3.3"8 - "4.8"9 - "5.12"10 - "6.10"11 - "7.6"10 - "6.11"11 - "7.10"12matrix:13 include:14 - node_js: "8.0"15 env: "NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly"
10 unmodified lines
2627 # Update Node.js modules28 - "test ! -d node_modules || npm prune"29 - "test ! -d node_modules || npm rebuild"30script: "npm run-script test-ci"30script:31 - "npm run test-ci"32 - "npm run lint"33after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"
modified:appveyor.yml+3 added-2 removed
5 unmodified lines
6 - nodejs_version: "2.5"7 - nodejs_version: "3.3"8 - nodejs_version: "4.8"9 - nodejs_version: "5.12"10 - nodejs_version: "6.10"11 - nodejs_version: "7.6"10 - nodejs_version: "6.11"11 - nodejs_version: "7.10"12cache:13 - node_modules14install:15 - ps: Install-Product node $env:nodejs_version
5 unmodified lines
21test_script:22 - node --version23 - npm --version24 - npm run test-ci25 - npm run lint26version: "{build}"
modified:Collaborator-Guide.md+4 added-2 removed
4 unmodified lines
56## PRs and Code contributions78* Tests must pass.9* Follow the [JavaScript Standard Style](http://standardjs.com/).9* Follow the [JavaScript Standard Style](http://standardjs.com/) and `npm run lint`.10* If you fix a bug, add a test.1112## Branches13
12 unmodified lines
263. Write your code in your local copy. It's good practice to create a branch for27 each new issue you work on, although not compulsory.284. To run the test suite, first install the dependencies by running `npm install`,29 then run `npm test`.305. Ensure your code is linted by running `npm run lint` -- fix any issue you31 see listed.305. If the tests pass, you can commit your changes to your fork and then create326. If the tests pass, you can commit your changes to your fork and then create33 a pull request from there. Make sure to reference your issue from the pull34 request comments by including the issue number e.g. `#123`.3536## Issues which are questions
14 unmodified lines
modified:Contributing.md+15 added-15 removed
10 unmodified lines
11## Vocabulary1213* A **Contributor** is any individual creating or commenting on an issue or pull request.14* A **Committer** is a subset of contributors who have been given write access to the repository.15* A **TC (Technical Committee)** is a group of committers representing the required technical 15* A **TC (Technical Committee)** is a group of committers representing the required technical16expertise to resolve rare disputes.1718# Logging Issues19
15 unmodified lines
3536No pull request can be merged without being reviewed.3738For non-trivial contributions, pull requests should sit for at least 36 hours to ensure that39contributors in other timezones have time to review. Consideration should also be given to 40weekends and other holiday periods to ensure active committers all have reasonable time to 39contributors in other timezones have time to review. Consideration should also be given to40weekends and other holiday periods to ensure active committers all have reasonable time to41become involved in the discussion and review process if they wish.4243The default for each contribution is that it is accepted once no committer has an objection.44During review committers may also request that a specific contributor who is most versed in a 45particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off" 46process for contributions to land. Once all issues brought by committers are addressed it can 44During review committers may also request that a specific contributor who is most versed in a45particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off"46process for contributions to land. Once all issues brought by committers are addressed it can47be landed by any committer.4849In the case of an objection being raised in a pull request by another committer, all involved 50committers should seek to arrive at a consensus by way of addressing concerns being expressed 49In the case of an objection being raised in a pull request by another committer, all involved50committers should seek to arrive at a consensus by way of addressing concerns being expressed51by discussion, compromise on the proposed change, or withdrawal of the proposed change.5253If a contribution is controversial and committers cannot agree about how to get it to land54or if it should land then it should be escalated to the TC. TC members should regularly55discuss pending contributions in order to find a resolution. It is expected that only a 56small minority of issues be brought to the TC for resolution and that discussion and 55discuss pending contributions in order to find a resolution. It is expected that only a56small minority of issues be brought to the TC for resolution and that discussion and57compromise among committers be the default resolution mechanism.5859# Becoming a Committer60
4 unmodified lines
65proper review, and have other committers merge their pull requests.6667# TC Process6869The TC uses a "consensus seeking" process for issues that are escalated to the TC. 69The TC uses a "consensus seeking" process for issues that are escalated to the TC.70The group tries to find a resolution that has no open objections among TC members.71If a consensus cannot be reached that has no objections then a majority wins vote72is called. It is also expected that the majority of decisions made by the TC are via 72is called. It is also expected that the majority of decisions made by the TC are via73a consensus seeking process and that voting is only used as a last-resort.7475Resolution may involve returning the issue to committers with suggestions on how to 76move forward towards a consensus. It is not expected that a meeting of the TC 75Resolution may involve returning the issue to committers with suggestions on how to76move forward towards a consensus. It is not expected that a meeting of the TC77will resolve all issues on its agenda during that meeting and may prefer to continue78the discussion happening among the committers.7980Members can be added to the TC at any time. Any committer can nominate another committer81to the TC and the TC uses its standard consensus seeking process to evaluate whether or82not to add this new member. Members who do not participate consistently at the level of 82not to add this new member. Members who do not participate consistently at the level of83a majority of the other members are expected to resign.8485
modified:History.md+49 added
15.x2===34This incorporates all changes after 4.15.2 up to 4.15.4.56 * deps: router@~1.3.17 - deps: debug@2.6.8895.0.0-alpha.5 / 2017-03-0610==========================1112This is the fifth Express 5.0 alpha release, based off 4.15.2 and includes
70 unmodified lines
83 - `req.query` is now a getter instead of a plain property84 * add:85 - `app.router` is a reference to the base router86874.15.4 / 2017-08-0688===================8990 * deps: debug@2.6.891 * deps: depd@~1.1.192 - Remove unnecessary `Buffer` loading93 * deps: finalhandler@~1.0.494 - deps: debug@2.6.895 * deps: proxy-addr@~1.1.596 - Fix array argument being altered97 - deps: ipaddr.js@1.4.098 * deps: qs@6.5.099 * deps: send@0.15.4100 - deps: debug@2.6.8101 - deps: depd@~1.1.1102 - deps: http-errors@~1.6.2103 * deps: serve-static@1.12.4104 - deps: send@0.15.41051064.15.3 / 2017-05-16107===================108109 * Fix error when `res.set` cannot add charset to `Content-Type`110 * deps: debug@2.6.7111 - Fix `DEBUG_MAX_ARRAY_LENGTH`112 - deps: ms@2.0.0113 * deps: finalhandler@~1.0.3114 - Fix missing `</html>` in HTML document115 - deps: debug@2.6.7116 * deps: proxy-addr@~1.1.4117 - deps: ipaddr.js@1.3.0118 * deps: send@0.15.3119 - deps: debug@2.6.7120 - deps: ms@2.0.0121 * deps: serve-static@1.12.3122 - deps: send@0.15.3123 * deps: type-is@~1.6.15124 - deps: mime-types@~2.1.15125 * deps: vary@~1.1.1126 - perf: hoist regular expression1271284.15.2 / 2017-03-06129===================130131 * deps: qs@6.4.0
3244 unmodified lines
modified:package.json+21 added-19 removed
31 unmodified lines
32 "content-disposition": "0.5.2",33 "content-type": "~1.0.2",34 "cookie": "0.3.1",35 "cookie-signature": "1.0.6",36 "debug": "2.6.1",37 "depd": "~1.1.0",36 "debug": "2.6.8",37 "depd": "~1.1.1",38 "encodeurl": "~1.0.1",39 "escape-html": "~1.0.3",40 "etag": "~1.8.0",41 "finalhandler": "~1.0.0",41 "finalhandler": "~1.0.4",42 "fresh": "0.5.0",43 "merge-descriptors": "1.0.1",44 "methods": "~1.1.2",45 "on-finished": "~2.3.0",46 "parseurl": "~1.3.1",47 "path-is-absolute": "1.0.1",48 "path-to-regexp": "0.1.7",49 "proxy-addr": "~1.1.3",50 "qs": "6.4.0",49 "proxy-addr": "~1.1.5",50 "qs": "6.5.0",51 "range-parser": "~1.2.0",52 "router": "~1.3.0",53 "send": "0.15.1",54 "serve-static": "1.12.1",52 "router": "~1.3.1",53 "send": "0.15.4",54 "serve-static": "1.12.4",55 "setprototypeof": "1.0.3",56 "statuses": "~1.3.1",57 "type-is": "~1.6.14",57 "type-is": "~1.6.15",58 "utils-merge": "1.0.0",59 "vary": "~1.1.0"59 "vary": "~1.1.1"60 },61 "devDependencies": {62 "after": "0.8.2",63 "body-parser": "1.17.1",63 "body-parser": "1.17.2",64 "cookie-parser": "~1.4.3",65 "ejs": "2.5.6",66 "express-session": "1.15.1",65 "cookie-session": "1.3.0",66 "ejs": "2.5.7",67 "eslint": "2.13.1",68 "express-session": "1.15.5",69 "hbs": "4.0.1",70 "istanbul": "0.4.5",71 "marked": "0.3.6",69 "method-override": "2.3.7",70 "mocha": "3.2.0",71 "morgan": "1.8.1",72 "method-override": "2.3.9",73 "mocha": "3.5.0",74 "morgan": "1.8.2",75 "multiparty": "4.1.3",76 "pbkdf2-password": "1.2.1",74 "should": "11.2.0",77 "should": "11.2.1",78 "supertest": "1.2.0",79 "connect-redis": "~2.4.1",77 "cookie-session": "~1.2.0",78 "jade": "~1.11.0",80 "vhost": "~3.0.2"81 },82 "engines": {83 "node": ">= 0.10.0"
5 unmodified lines
89 "index.js",90 "lib/"91 ],92 "scripts": {93 "lint": "eslint .",94 "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",95 "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",96 "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",97 "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
2 unmodified lines
modified:Readme.md+2 added-3 removed
37 unmodified lines
38## Docs & Community3940 * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]41 * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC42 * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules42 * [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules43 * Visit the [Wiki](https://github.com/expressjs/express/wiki)44 * [Google Group](https://groups.google.com/group/express-js) for discussion45 * [Gitter](https://gitter.im/expressjs/express) for support and discussion46 * [Русскоязычная документация](http://jsman.ru/express/)4647**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).4850###Security Issues49### Security Issues5051If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md).5253## Quick Start
88 unmodified lines