send
Advanced tools
Comparing version 0.15.0 to 0.15.1
@@ -0,1 +1,7 @@ | ||
0.15.1 / 2017-03-04 | ||
=================== | ||
* Fix issue when `Date.parse` does not return `NaN` on invalid date | ||
* Fix strict violation in broken environments | ||
0.15.0 / 2017-02-25 | ||
@@ -2,0 +8,0 @@ =================== |
31
index.js
@@ -275,10 +275,10 @@ /*! | ||
* @param {number} status | ||
* @param {Error} [error] | ||
* @param {Error} [err] | ||
* @private | ||
*/ | ||
SendStream.prototype.error = function error (status, error) { | ||
SendStream.prototype.error = function error (status, err) { | ||
// emit if listeners instead of responding | ||
if (listenerCount(this, 'error') !== 0) { | ||
return this.emit('error', createError(status, error, { | ||
return this.emit('error', createError(status, err, { | ||
expose: false | ||
@@ -296,4 +296,4 @@ })) | ||
// add error headers | ||
if (error && error.headers) { | ||
setHeaders(res, error.headers) | ||
if (err && err.headers) { | ||
setHeaders(res, err.headers) | ||
} | ||
@@ -356,5 +356,5 @@ | ||
// if-unmodified-since | ||
var unmodifiedSince = Date.parse(req.headers['if-unmodified-since']) | ||
var unmodifiedSince = parseHttpDate(req.headers['if-unmodified-since']) | ||
if (!isNaN(unmodifiedSince)) { | ||
var lastModified = Date.parse(res.getHeader('Last-Modified')) | ||
var lastModified = parseHttpDate(res.getHeader('Last-Modified')) | ||
return isNaN(lastModified) || lastModified > unmodifiedSince | ||
@@ -480,3 +480,3 @@ } | ||
var lastModified = this.res.getHeader('Last-Modified') | ||
return Boolean(lastModified && Date.parse(lastModified) <= Date.parse(ifRange)) | ||
return parseHttpDate(lastModified) <= parseHttpDate(ifRange) | ||
} | ||
@@ -1049,2 +1049,17 @@ | ||
/** | ||
* Parse an HTTP Date into a number. | ||
* | ||
* @param {string} date | ||
* @private | ||
*/ | ||
function parseHttpDate (date) { | ||
var timestamp = date && Date.parse(date) | ||
return typeof timestamp === 'number' | ||
? timestamp | ||
: NaN | ||
} | ||
/** | ||
* Set an object of headers on a response. | ||
@@ -1051,0 +1066,0 @@ * |
{ | ||
"name": "send", | ||
"description": "Better streaming static file server with Range and conditional-GET support", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -35,7 +35,7 @@ "contributors": [ | ||
"after": "0.8.2", | ||
"eslint": "3.16.0", | ||
"eslint-config-standard": "6.2.1", | ||
"eslint-plugin-markdown": "1.0.0-beta.3", | ||
"eslint-plugin-promise": "3.4.2", | ||
"eslint-plugin-standard": "2.0.1", | ||
"eslint": "3.17.0", | ||
"eslint-config-standard": "7.0.0", | ||
"eslint-plugin-markdown": "1.0.0-beta.4", | ||
"eslint-plugin-promise": "3.5.0", | ||
"eslint-plugin-standard": "2.1.1", | ||
"istanbul": "0.4.5", | ||
@@ -42,0 +42,0 @@ "mocha": "2.5.3", |
43785
887