Socket
Socket
Sign inDemoInstall

fresh

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.0 to 0.5.1

6

HISTORY.md

@@ -0,1 +1,7 @@

0.5.1 / 2017-09-11
==================
* Fix handling of modified headers with invalid dates
* perf: improve ETag match loop
0.5.0 / 2017-02-21

@@ -2,0 +8,0 @@ ==================

31

index.js

@@ -61,9 +61,14 @@ /*!

var etag = resHeaders['etag']
var etagStale = !etag || noneMatch.split(TOKEN_LIST_REGEXP).every(function (match) {
return match !== etag && match !== 'W/' + etag && 'W/' + match !== etag
})
if (etagStale) {
if (!etag) {
return false
}
var matches = noneMatch.split(TOKEN_LIST_REGEXP)
for (var i = 0; i < matches.length; i++) {
var match = matches[i]
if (match !== etag && match !== 'W/' + etag && 'W/' + match !== etag) {
return false
}
}
}

@@ -74,3 +79,3 @@

var lastModified = resHeaders['last-modified']
var modifiedStale = !lastModified || Date.parse(lastModified) > Date.parse(modifiedSince)
var modifiedStale = !lastModified || !(parseHttpDate(lastModified) <= parseHttpDate(modifiedSince))

@@ -84,1 +89,17 @@ if (modifiedStale) {

}
/**
* Parse an HTTP Date into a number.
*
* @param {string} date
* @private
*/
function parseHttpDate (date) {
var timestamp = date && Date.parse(date)
// istanbul ignore next: guard against date.js Date.parse patching
return typeof timestamp === 'number'
? timestamp
: NaN
}

18

package.json
{
"name": "fresh",
"description": "HTTP response freshness testing",
"version": "0.5.0",
"version": "0.5.1",
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",

@@ -19,6 +19,11 @@ "contributors": [

"devDependencies": {
"eslint": "3.16.0",
"eslint-config-standard": "6.2.1",
"eslint-plugin-promise": "3.4.2",
"eslint-plugin-standard": "2.0.1",
"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",

@@ -36,3 +41,4 @@ "mocha": "1.21.5"

"scripts": {
"lint": "eslint .",
"bench": "node benchmark/index.js",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",

@@ -39,0 +45,0 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",

@@ -23,2 +23,4 @@ # fresh

<!-- eslint-disable no-unused-vars -->
```js

@@ -59,2 +61,4 @@ var fresh = require('fresh')

<!-- eslint-disable no-redeclare, no-undef -->
```js

@@ -90,2 +94,4 @@ var reqHeaders = { 'if-none-match': '"foo"' }

// send the resource
res.statusCode = 200
res.end('hello, world!')
})

@@ -92,0 +98,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc