https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
+10
View File
@@ -1,3 +1,13 @@
2.0.0 - 2024-09-04
==========
* Drop support for Node.js <18
1.0.0 - 2024-09-04
==========
* Drop support for Node.js below 0.8
* Fix: Ignore `If-Modified-Since` in the presence of `If-None-Match`, according to [spec](https://www.rfc-editor.org/rfc/rfc9110.html#section-13.1.3-5). Fixes [#35](https://github.com/jshttp/fresh/issues/35)
0.5.2 / 2017-09-13
==================
+8 -10
View File
@@ -3,7 +3,7 @@
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][travis-image]][travis-url]
[![Build Status][ci-image]][ci-url]
[![Test Coverage][coveralls-image]][coveralls-url]
HTTP response freshness testing
@@ -20,8 +20,6 @@ $ npm install fresh
## API
<!-- eslint-disable no-unused-vars -->
```js
var fresh = require('fresh')
```
@@ -42,7 +40,7 @@ to make handling these requests transparent.
This module is designed to only follow the HTTP specifications, not
to work-around all kinda of client bugs (especially since this module
typically does not recieve enough information to understand what the
typically does not receive enough information to understand what the
client actually is).
There is a known issue that in certain versions of Safari, Safari
@@ -57,16 +55,16 @@ links to further reading on this Safari bug.
### API usage
<!-- eslint-disable no-redeclare, no-undef -->
<!-- eslint-disable no-redeclare -->
```js
var reqHeaders = { 'if-none-match': '"foo"' }
var resHeaders = { 'etag': '"bar"' }
var resHeaders = { etag: '"bar"' }
fresh(reqHeaders, resHeaders)
// => false
var reqHeaders = { 'if-none-match': '"foo"' }
var resHeaders = { 'etag': '"foo"' }
var resHeaders = { etag: '"foo"' }
fresh(reqHeaders, resHeaders)
// => true
```
@@ -95,7 +93,7 @@ var server = http.createServer(function (req, res) {
function isFresh (req, res) {
return fresh(req.headers, {
'etag': res.getHeader('ETag'),
etag: res.getHeader('ETag'),
'last-modified': res.getHeader('Last-Modified')
})
}
@@ -107,12 +105,12 @@ server.listen(3000)
[MIT](LICENSE)
[ci-image]: https://img.shields.io/github/workflow/status/jshttp/fresh/ci/master?label=ci
[ci-url]: https://github.com/jshttp/fresh/actions/workflows/ci.yml
[npm-image]: https://img.shields.io/npm/v/fresh.svg
[npm-url]: https://npmjs.org/package/fresh
[node-version-image]: https://img.shields.io/node/v/fresh.svg
[node-version-url]: https://nodejs.org/en/
[travis-image]: https://img.shields.io/travis/jshttp/fresh/master.svg
[travis-url]: https://travis-ci.org/jshttp/fresh
[coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh/master.svg
[coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master
[downloads-image]: https://img.shields.io/npm/dm/fresh.svg
+8 -9
View File
@@ -48,27 +48,26 @@ function fresh (reqHeaders, resHeaders) {
return false
}
// if-none-match
if (noneMatch && noneMatch !== '*') {
var etag = resHeaders['etag']
// if-none-match takes precedent over if-modified-since
if (noneMatch) {
if (noneMatch === '*') {
return true
}
var etag = resHeaders.etag
if (!etag) {
return false
}
var etagStale = true
var matches = parseTokenList(noneMatch)
for (var i = 0; i < matches.length; i++) {
var match = matches[i]
if (match === etag || match === 'W/' + etag || 'W/' + match === etag) {
etagStale = false
break
return true
}
}
if (etagStale) {
return false
}
return false
}
// if-modified-since
+15 -15
View File
@@ -1,7 +1,7 @@
{
"name": "fresh",
"description": "HTTP response freshness testing",
"version": "0.5.2",
"version": "2.0.0",
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
"contributors": [
"Douglas Christopher Wilson <doug@somethingdoug.com>",
@@ -18,15 +18,15 @@
"devDependencies": {
"beautify-benchmark": "0.2.4",
"benchmark": "2.1.4",
"eslint": "3.19.0",
"eslint-config-standard": "10.2.1",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-markdown": "1.0.0-beta.6",
"eslint-plugin-node": "5.1.1",
"eslint-plugin-promise": "3.5.0",
"eslint-plugin-standard": "3.0.1",
"istanbul": "0.4.5",
"mocha": "1.21.5"
"eslint": "8.12.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-markdown": "2.2.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.0.0",
"eslint-plugin-standard": "4.1.0",
"mocha": "9.2.0",
"nyc": "15.1.0"
},
"files": [
"HISTORY.md",
@@ -34,13 +34,13 @@
"index.js"
],
"engines": {
"node": ">= 0.6"
"node": ">= 0.8"
},
"scripts": {
"bench": "node benchmark/index.js",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
"lint": "eslint .",
"test": "mocha --reporter spec --check-leaks --bail test/",
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}