Skip to content

Commit 4d713d2

Browse files
authored
update to fresh@2.0.0 (#5916)
fixes handling of If-Modified-Since in combination with If-None-Match
1 parent accafc6 commit 4d713d2

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

History.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
unreleased
22
=========================
3-
* remove:
3+
* remove:
44
- `path-is-absolute` dependency - use `path.isAbsolute` instead
55
* breaking:
66
* `res.status()` accepts only integers, and input must be greater than 99 and less than 1000
@@ -20,6 +20,7 @@ unreleased
2020
* deps: type-is@^2.0.0
2121
* deps: content-disposition@^1.0.0
2222
* deps: finalhandler@^2.0.0
23+
* deps: fresh@^2.0.0
2324

2425
5.0.0-beta.3 / 2024-03-25
2526
=========================

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}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"escape-html": "~1.0.3",
4141
"etag": "~1.8.1",
4242
"finalhandler": "^2.0.0",
43-
"fresh": "0.5.2",
43+
"fresh": "2.0.0",
4444
"http-errors": "2.0.0",
4545
"merge-descriptors": "^2.0.0",
4646
"methods": "~1.1.2",

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
})

0 commit comments

Comments
 (0)