fresh 0.5.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +10 -0
- package/README.md +8 -10
- package/index.js +8 -9
- package/package.json +15 -15
package/HISTORY.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2.0.0 - 2024-09-04
|
|
2
|
+
==========
|
|
3
|
+
* Drop support for Node.js <18
|
|
4
|
+
|
|
5
|
+
1.0.0 - 2024-09-04
|
|
6
|
+
==========
|
|
7
|
+
|
|
8
|
+
* Drop support for Node.js below 0.8
|
|
9
|
+
* 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)
|
|
10
|
+
|
|
1
11
|
0.5.2 / 2017-09-13
|
|
2
12
|
==================
|
|
3
13
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[![NPM Version][npm-image]][npm-url]
|
|
4
4
|
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
5
|
[![Node.js Version][node-version-image]][node-version-url]
|
|
6
|
-
[![Build Status][
|
|
6
|
+
[![Build Status][ci-image]][ci-url]
|
|
7
7
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
8
8
|
|
|
9
9
|
HTTP response freshness testing
|
|
@@ -20,8 +20,6 @@ $ npm install fresh
|
|
|
20
20
|
|
|
21
21
|
## API
|
|
22
22
|
|
|
23
|
-
<!-- eslint-disable no-unused-vars -->
|
|
24
|
-
|
|
25
23
|
```js
|
|
26
24
|
var fresh = require('fresh')
|
|
27
25
|
```
|
|
@@ -42,7 +40,7 @@ to make handling these requests transparent.
|
|
|
42
40
|
|
|
43
41
|
This module is designed to only follow the HTTP specifications, not
|
|
44
42
|
to work-around all kinda of client bugs (especially since this module
|
|
45
|
-
typically does not
|
|
43
|
+
typically does not receive enough information to understand what the
|
|
46
44
|
client actually is).
|
|
47
45
|
|
|
48
46
|
There is a known issue that in certain versions of Safari, Safari
|
|
@@ -57,16 +55,16 @@ links to further reading on this Safari bug.
|
|
|
57
55
|
|
|
58
56
|
### API usage
|
|
59
57
|
|
|
60
|
-
<!-- eslint-disable no-redeclare
|
|
58
|
+
<!-- eslint-disable no-redeclare -->
|
|
61
59
|
|
|
62
60
|
```js
|
|
63
61
|
var reqHeaders = { 'if-none-match': '"foo"' }
|
|
64
|
-
var resHeaders = {
|
|
62
|
+
var resHeaders = { etag: '"bar"' }
|
|
65
63
|
fresh(reqHeaders, resHeaders)
|
|
66
64
|
// => false
|
|
67
65
|
|
|
68
66
|
var reqHeaders = { 'if-none-match': '"foo"' }
|
|
69
|
-
var resHeaders = {
|
|
67
|
+
var resHeaders = { etag: '"foo"' }
|
|
70
68
|
fresh(reqHeaders, resHeaders)
|
|
71
69
|
// => true
|
|
72
70
|
```
|
|
@@ -95,7 +93,7 @@ var server = http.createServer(function (req, res) {
|
|
|
95
93
|
|
|
96
94
|
function isFresh (req, res) {
|
|
97
95
|
return fresh(req.headers, {
|
|
98
|
-
|
|
96
|
+
etag: res.getHeader('ETag'),
|
|
99
97
|
'last-modified': res.getHeader('Last-Modified')
|
|
100
98
|
})
|
|
101
99
|
}
|
|
@@ -107,12 +105,12 @@ server.listen(3000)
|
|
|
107
105
|
|
|
108
106
|
[MIT](LICENSE)
|
|
109
107
|
|
|
108
|
+
[ci-image]: https://img.shields.io/github/workflow/status/jshttp/fresh/ci/master?label=ci
|
|
109
|
+
[ci-url]: https://github.com/jshttp/fresh/actions/workflows/ci.yml
|
|
110
110
|
[npm-image]: https://img.shields.io/npm/v/fresh.svg
|
|
111
111
|
[npm-url]: https://npmjs.org/package/fresh
|
|
112
112
|
[node-version-image]: https://img.shields.io/node/v/fresh.svg
|
|
113
113
|
[node-version-url]: https://nodejs.org/en/
|
|
114
|
-
[travis-image]: https://img.shields.io/travis/jshttp/fresh/master.svg
|
|
115
|
-
[travis-url]: https://travis-ci.org/jshttp/fresh
|
|
116
114
|
[coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh/master.svg
|
|
117
115
|
[coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master
|
|
118
116
|
[downloads-image]: https://img.shields.io/npm/dm/fresh.svg
|
package/index.js
CHANGED
|
@@ -48,27 +48,26 @@ function fresh (reqHeaders, resHeaders) {
|
|
|
48
48
|
return false
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// if-none-match
|
|
52
|
-
if (noneMatch
|
|
53
|
-
|
|
51
|
+
// if-none-match takes precedent over if-modified-since
|
|
52
|
+
if (noneMatch) {
|
|
53
|
+
if (noneMatch === '*') {
|
|
54
|
+
return true
|
|
55
|
+
}
|
|
56
|
+
var etag = resHeaders.etag
|
|
54
57
|
|
|
55
58
|
if (!etag) {
|
|
56
59
|
return false
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
var etagStale = true
|
|
60
62
|
var matches = parseTokenList(noneMatch)
|
|
61
63
|
for (var i = 0; i < matches.length; i++) {
|
|
62
64
|
var match = matches[i]
|
|
63
65
|
if (match === etag || match === 'W/' + etag || 'W/' + match === etag) {
|
|
64
|
-
|
|
65
|
-
break
|
|
66
|
+
return true
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
70
|
+
return false
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
// if-modified-since
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fresh",
|
|
3
3
|
"description": "HTTP response freshness testing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"beautify-benchmark": "0.2.4",
|
|
20
20
|
"benchmark": "2.1.4",
|
|
21
|
-
"eslint": "
|
|
22
|
-
"eslint-config-standard": "
|
|
23
|
-
"eslint-plugin-import": "2.
|
|
24
|
-
"eslint-plugin-markdown": "
|
|
25
|
-
"eslint-plugin-node": "
|
|
26
|
-
"eslint-plugin-promise": "
|
|
27
|
-
"eslint-plugin-standard": "
|
|
28
|
-
"
|
|
29
|
-
"
|
|
21
|
+
"eslint": "8.12.0",
|
|
22
|
+
"eslint-config-standard": "14.1.1",
|
|
23
|
+
"eslint-plugin-import": "2.25.4",
|
|
24
|
+
"eslint-plugin-markdown": "2.2.1",
|
|
25
|
+
"eslint-plugin-node": "11.1.0",
|
|
26
|
+
"eslint-plugin-promise": "6.0.0",
|
|
27
|
+
"eslint-plugin-standard": "4.1.0",
|
|
28
|
+
"mocha": "9.2.0",
|
|
29
|
+
"nyc": "15.1.0"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"HISTORY.md",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"index.js"
|
|
35
35
|
],
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": ">= 0.
|
|
37
|
+
"node": ">= 0.8"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"bench": "node benchmark/index.js",
|
|
41
|
-
"lint": "eslint
|
|
42
|
-
"test": "mocha --reporter spec --
|
|
43
|
-
"test-
|
|
44
|
-
"test-
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"test": "mocha --reporter spec --check-leaks --bail test/",
|
|
43
|
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
|
44
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
|
45
45
|
}
|
|
46
46
|
}
|