Skip to content

Commit f9256ef

Browse files
authored
Merge branch '5.0' into 5-merge
2 parents e5feb9f + 0264908 commit f9256ef

File tree

12 files changed

+85
-55
lines changed

12 files changed

+85
-55
lines changed

History.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
unreleased
22
=========================
3+
* remove:
4+
- `path-is-absolute` dependency - use `path.isAbsolute` instead
35
* breaking:
46
* `res.status()` accepts only integers, and input must be greater than 99 and less than 1000
57
* will throw a `RangeError: Invalid status code: ${code}. Status code must be greater than 99 and less than 1000.` for inputs outside this range
68
* will throw a `TypeError: Invalid status code: ${code}. Status code must be an integer.` for non integer inputs
9+
710
* change:
811
- `res.clearCookie` will ignore user provided `maxAge` and `expires` options
12+
* deps: cookie-signature@^1.2.1
13+
14+
* deps: merge-descriptors@^2.0.0
15+
* deps: serve-static@^2.0.0
16+
17+
* deps: accepts@^2.0.0
18+
* deps: mime-types@^3.0.0
19+
- `application/javascript` => `text/javascript`
20+
* deps: type-is@^2.0.0
21+
* deps: content-disposition@^1.0.0
22+
* deps: finalhandler@^2.0.0
23+
* deps: fresh@^2.0.0
924

1025
5.0.0-beta.3 / 2024-03-25
1126
=========================

examples/downloads/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ app.get('/', function(req, res){
2323

2424
// /files/* is accessed via req.params[0]
2525
// but here we name it :file
26-
app.get('/files/:file+', function (req, res, next) {
27-
res.download(req.params.file, { root: FILES_DIR }, function (err) {
26+
app.get('/files/*file', function (req, res, next) {
27+
res.download(req.params.file.join('/'), { root: FILES_DIR }, function (err) {
2828
if (!err) return; // file sent
2929
if (err.status !== 404) return next(err); // non-404 error
3030
// file for download not found

examples/resource/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var app = module.exports = express();
1212

1313
app.resource = function(path, obj) {
1414
this.get(path, obj.index);
15-
this.get(path + '/:a..:b.:format?', function(req, res){
15+
this.get(path + '/:a..:b{.:format}', function(req, res){
1616
var a = parseInt(req.params.a, 10);
1717
var b = parseInt(req.params.b, 10);
1818
var format = req.params.format;

examples/route-separation/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ app.get('/', site.index);
3838
// User
3939

4040
app.get('/users', user.list);
41-
app.all('/user/:id/:op?', user.load);
41+
app.all('/user/:id{/:op}', user.load);
4242
app.get('/user/:id', user.view);
4343
app.get('/user/:id/view', user.view);
4444
app.get('/user/:id/edit', user.edit);

lib/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ defineGetter(req, 'hostname', function hostname(){
447447

448448
/**
449449
* Check if the request is fresh, aka
450-
* Last-Modified and/or the ETag
450+
* Last-Modified or the ETag
451451
* still match.
452452
*
453453
* @return {Boolean}

lib/response.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var http = require('http');
2121
var onFinished = require('on-finished');
2222
var mime = require('mime-types')
2323
var path = require('path');
24-
var pathIsAbsolute = require('path-is-absolute');
24+
var pathIsAbsolute = require('path').isAbsolute;
2525
var statuses = require('statuses')
2626
var merge = require('utils-merge');
2727
var sign = require('cookie-signature').sign;

package.json

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"name": "express",
33
"description": "Fast, unopinionated, minimalist web framework",
4-
<<<<<<< HEAD
54
"version": "5.0.0-beta.3",
6-
=======
7-
"version": "4.20.0",
8-
>>>>>>> master
95
"author": "TJ Holowaychuk <[email protected]>",
106
"contributors": [
117
"Aaron Heckmann <[email protected]>",
@@ -32,37 +28,36 @@
3228
"api"
3329
],
3430
"dependencies": {
35-
"accepts": "~1.3.8",
31+
"accepts": "^2.0.0",
3632
"body-parser": "2.0.0-beta.2",
37-
"content-disposition": "0.5.4",
33+
"content-disposition": "^1.0.0",
3834
"content-type": "~1.0.4",
3935
"cookie": "0.6.0",
40-
"cookie-signature": "1.0.6",
41-
"debug": "3.1.0",
36+
"cookie-signature": "^1.2.1",
37+
"debug": "4.3.6",
4238
"depd": "2.0.0",
4339
"encodeurl": "~2.0.0",
4440
"escape-html": "~1.0.3",
4541
"etag": "~1.8.1",
46-
"finalhandler": "1.2.0",
47-
"fresh": "0.5.2",
42+
"finalhandler": "^2.0.0",
43+
"fresh": "2.0.0",
4844
"http-errors": "2.0.0",
49-
"merge-descriptors": "1.0.3",
45+
"merge-descriptors": "^2.0.0",
5046
"methods": "~1.1.2",
51-
"mime-types": "~2.1.34",
47+
"mime-types": "^3.0.0",
5248
"on-finished": "2.4.1",
5349
"once": "1.4.0",
5450
"parseurl": "~1.3.3",
55-
"path-is-absolute": "1.0.1",
5651
"proxy-addr": "~2.0.7",
57-
"qs": "6.11.0",
52+
"qs": "6.13.0",
5853
"range-parser": "~1.2.1",
59-
"router": "2.0.0-beta.2",
54+
"router": "^2.0.0",
6055
"safe-buffer": "5.2.1",
61-
"send": "1.0.0-beta.2",
62-
"serve-static": "2.0.0-beta.2",
56+
"send": "^1.0.0",
57+
"serve-static": "^2.0.0",
6358
"setprototypeof": "1.2.0",
6459
"statuses": "2.0.1",
65-
"type-is": "~1.6.18",
60+
"type-is": "^2.0.0",
6661
"utils-merge": "1.0.1",
6762
"vary": "~1.1.2"
6863
},

test/app.all.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('app.all()', function(){
2626
var app = express()
2727
, n = 0;
2828

29-
app.all('/*', function(req, res, next){
29+
app.all('/*splat', function(req, res, next){
3030
if (n++) return done(new Error('DELETE called several times'));
3131
next();
3232
});

test/app.router.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@ describe('app.router', function(){
337337
var app = express();
338338
var router = new express.Router({ mergeParams: true });
339339

340-
router.get('/(.*).(.*)', function (req, res) {
340+
router.get(/^\/(.*)\.(.*)/, function (req, res) {
341341
var keys = Object.keys(req.params).sort();
342342
res.send(keys.map(function(k){ return [k, req.params[k]] }));
343343
});
344344

345-
app.use('/user/id:(\\d+)', router);
345+
app.use(/^\/user\/id:(\d+)/, router);
346346

347347
request(app)
348348
.get('/user/id:10/profile.json')
@@ -353,12 +353,12 @@ describe('app.router', function(){
353353
var app = express();
354354
var router = new express.Router({ mergeParams: true });
355355

356-
router.get('/(.*)', function (req, res) {
356+
router.get(/\/(.*)/, function (req, res) {
357357
var keys = Object.keys(req.params).sort();
358358
res.send(keys.map(function(k){ return [k, req.params[k]] }));
359359
});
360360

361-
app.use('/user/id:(\\d+)/name:(\\w+)', router);
361+
app.use(/^\/user\/id:(\d+)\/name:(\w+)/, router);
362362

363363
request(app)
364364
.get('/user/id:10/name:tj/profile')
@@ -369,12 +369,12 @@ describe('app.router', function(){
369369
var app = express();
370370
var router = new express.Router({ mergeParams: true });
371371

372-
router.get('/name:(\\w+)', function(req, res){
372+
router.get(/\/name:(\w+)/, function(req, res){
373373
var keys = Object.keys(req.params).sort();
374374
res.send(keys.map(function(k){ return [k, req.params[k]] }));
375375
});
376376

377-
app.use('/user/id:(\\d+)', router);
377+
app.use(/\/user\/id:(\d+)/, router);
378378

379379
request(app)
380380
.get('/user/id:10/name:tj')
@@ -404,11 +404,11 @@ describe('app.router', function(){
404404
var app = express();
405405
var router = new express.Router({ mergeParams: true });
406406

407-
router.get('/user:(\\w+)/*', function (req, res, next) {
407+
router.get(/\/user:(\w+)\//, function (req, res, next) {
408408
next();
409409
});
410410

411-
app.use('/user/id:(\\d+)', function (req, res, next) {
411+
app.use(/\/user\/id:(\d+)/, function (req, res, next) {
412412
router(req, res, function (err) {
413413
var keys = Object.keys(req.params).sort();
414414
res.send(keys.map(function(k){ return [k, req.params[k]] }));
@@ -631,8 +631,8 @@ describe('app.router', function(){
631631
var app = express();
632632
var cb = after(2, done);
633633

634-
app.get('/user(s?)/:user/:op', function(req, res){
635-
res.end(req.params.op + 'ing ' + req.params.user + (req.params[0] ? ' (old)' : ''));
634+
app.get('/user{s}/:user/:op', function(req, res){
635+
res.end(req.params.op + 'ing ' + req.params.user + (req.url.startsWith('/users') ? ' (old)' : ''));
636636
});
637637

638638
request(app)
@@ -678,7 +678,7 @@ describe('app.router', function(){
678678
it('should denote an optional capture group', function(done){
679679
var app = express();
680680

681-
app.get('/user/:user/:op?', function(req, res){
681+
app.get('/user/:user{/:op}', function(req, res){
682682
var op = req.params.op || 'view';
683683
res.end(op + 'ing ' + req.params.user);
684684
});
@@ -691,7 +691,7 @@ describe('app.router', function(){
691691
it('should populate the capture group', function(done){
692692
var app = express();
693693

694-
app.get('/user/:user/:op?', function(req, res){
694+
app.get('/user/:user{/:op}', function(req, res){
695695
var op = req.params.op || 'view';
696696
res.end(op + 'ing ' + req.params.user);
697697
});
@@ -706,8 +706,8 @@ describe('app.router', function(){
706706
it('should match one segment', function (done) {
707707
var app = express()
708708

709-
app.get('/user/:user*', function (req, res) {
710-
res.end(req.params.user)
709+
app.get('/user/*user', function (req, res) {
710+
res.end(req.params.user[0])
711711
})
712712

713713
request(app)
@@ -718,8 +718,8 @@ describe('app.router', function(){
718718
it('should match many segments', function (done) {
719719
var app = express()
720720

721-
app.get('/user/:user*', function (req, res) {
722-
res.end(req.params.user)
721+
app.get('/user/*user', function (req, res) {
722+
res.end(req.params.user.join('/'))
723723
})
724724

725725
request(app)
@@ -730,7 +730,7 @@ describe('app.router', function(){
730730
it('should match zero segments', function (done) {
731731
var app = express()
732732

733-
app.get('/user/:user*', function (req, res) {
733+
app.get('/user{/*user}', function (req, res) {
734734
res.end(req.params.user)
735735
})
736736

@@ -744,8 +744,8 @@ describe('app.router', function(){
744744
it('should match one segment', function (done) {
745745
var app = express()
746746

747-
app.get('/user/:user+', function (req, res) {
748-
res.end(req.params.user)
747+
app.get('/user/*user', function (req, res) {
748+
res.end(req.params.user[0])
749749
})
750750

751751
request(app)
@@ -756,8 +756,8 @@ describe('app.router', function(){
756756
it('should match many segments', function (done) {
757757
var app = express()
758758

759-
app.get('/user/:user+', function (req, res) {
760-
res.end(req.params.user)
759+
app.get('/user/*user', function (req, res) {
760+
res.end(req.params.user.join('/'))
761761
})
762762

763763
request(app)
@@ -768,7 +768,7 @@ describe('app.router', function(){
768768
it('should not match zero segments', function (done) {
769769
var app = express()
770770

771-
app.get('/user/:user+', function (req, res) {
771+
app.get('/user/*user', function (req, res) {
772772
res.end(req.params.user)
773773
})
774774

@@ -802,7 +802,7 @@ describe('app.router', function(){
802802
var app = express();
803803
var cb = after(2, done)
804804

805-
app.get('/:name.:format?', function(req, res){
805+
app.get('/:name{.:format}', function(req, res){
806806
res.end(req.params.name + ' as ' + (req.params.format || 'html'));
807807
});
808808

@@ -821,7 +821,7 @@ describe('app.router', function(){
821821
var app = express()
822822
, calls = [];
823823

824-
app.get('/foo/:bar?', function(req, res, next){
824+
app.get('/foo{/:bar}', function(req, res, next){
825825
calls.push('/foo/:bar?');
826826
next();
827827
});
@@ -906,7 +906,7 @@ describe('app.router', function(){
906906
var app = express()
907907
, calls = [];
908908

909-
app.get('/foo/:bar?', function(req, res, next){
909+
app.get('/foo{/:bar}', function(req, res, next){
910910
calls.push('/foo/:bar?');
911911
next();
912912
});
@@ -1117,7 +1117,7 @@ describe('app.router', function(){
11171117
var app = express();
11181118
var path = [];
11191119

1120-
app.get('/:path+', function (req, res, next) {
1120+
app.get('/*path', function (req, res, next) {
11211121
path.push(0);
11221122
next();
11231123
});
@@ -1137,7 +1137,7 @@ describe('app.router', function(){
11371137
next();
11381138
});
11391139

1140-
app.get('/(.*)', function (req, res, next) {
1140+
app.get('/*splat', function (req, res, next) {
11411141
path.push(4);
11421142
next();
11431143
});

test/req.fresh.js

+20
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,25 @@ describe('req', function(){
4646
.get('/')
4747
.expect(200, 'false', done);
4848
})
49+
50+
it('should ignore "If-Modified-Since" when "If-None-Match" is present', function(done) {
51+
var app = express();
52+
const etag = '"FooBar"'
53+
const now = Date.now()
54+
55+
app.disable('x-powered-by')
56+
app.use(function(req, res) {
57+
res.set('Etag', etag)
58+
res.set('Last-Modified', new Date(now).toUTCString())
59+
res.send(req.fresh);
60+
});
61+
62+
request(app)
63+
.get('/')
64+
.set('If-Modified-Since', new Date(now - 1000).toUTCString)
65+
.set('If-None-Match', etag)
66+
.expect(304, done);
67+
})
68+
4969
})
5070
})

test/req.route.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('req', function(){
88
it('should be the executed Route', function(done){
99
var app = express();
1010

11-
app.get('/user/:id/:op?', function(req, res, next){
11+
app.get('/user/:id{/:op}', function(req, res, next){
1212
res.header('path-1', req.route.path)
1313
next();
1414
});
@@ -20,7 +20,7 @@ describe('req', function(){
2020

2121
request(app)
2222
.get('/user/12/edit')
23-
.expect('path-1', '/user/:id/:op?')
23+
.expect('path-1', '/user/:id{/:op}')
2424
.expect('path-2', '/user/:id/edit')
2525
.expect(200, done)
2626
})

test/res.type.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('res', function(){
1414

1515
request(app)
1616
.get('/')
17-
.expect('Content-Type', 'application/javascript; charset=utf-8')
17+
.expect('Content-Type', 'text/javascript; charset=utf-8')
1818
.end(done)
1919
})
2020

0 commit comments

Comments
 (0)