update to fresh@2.0.0 (#5916)

fixes handling of If-Modified-Since in combination with If-None-Match
This commit is contained in:
Jon Church 2024-09-09 18:03:32 -04:00 committed by GitHub
parent accafc652e
commit 4d713d2b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 3 deletions

View File

@ -1,6 +1,6 @@
unreleased
=========================
* remove:
* remove:
- `path-is-absolute` dependency - use `path.isAbsolute` instead
* breaking:
* `res.status()` accepts only integers, and input must be greater than 99 and less than 1000
@ -20,6 +20,7 @@ unreleased
* deps: type-is@^2.0.0
* deps: content-disposition@^1.0.0
* deps: finalhandler@^2.0.0
* deps: fresh@^2.0.0
5.0.0-beta.3 / 2024-03-25
=========================

View File

@ -447,7 +447,7 @@ defineGetter(req, 'hostname', function hostname(){
/**
* Check if the request is fresh, aka
* Last-Modified and/or the ETag
* Last-Modified or the ETag
* still match.
*
* @return {Boolean}

View File

@ -40,7 +40,7 @@
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "^2.0.0",
"fresh": "0.5.2",
"fresh": "2.0.0",
"http-errors": "2.0.0",
"merge-descriptors": "^2.0.0",
"methods": "~1.1.2",

View File

@ -46,5 +46,25 @@ describe('req', function(){
.get('/')
.expect(200, 'false', done);
})
it('should ignore "If-Modified-Since" when "If-None-Match" is present', function(done) {
var app = express();
const etag = '"FooBar"'
const now = Date.now()
app.disable('x-powered-by')
app.use(function(req, res) {
res.set('Etag', etag)
res.set('Last-Modified', new Date(now).toUTCString())
res.send(req.fresh);
});
request(app)
.get('/')
.set('If-Modified-Since', new Date(now - 1000).toUTCString)
.set('If-None-Match', etag)
.expect(304, done);
})
})
})