Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2988 from hapijs/v11.1.x
Handle invalid date exceptions
  • Loading branch information
hueniverse committed Dec 23, 2015
2 parents 1ad65ba + ef2a0f8 commit aab2496
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/transmit.js
Expand Up @@ -82,8 +82,8 @@ internals.marshal = function (request, next) {

// Weak verifier

const ifModifiedSince = Date.parse(ifModifiedSinceHeader);
const lastModified = Date.parse(lastModifiedHeader);
const ifModifiedSince = internals.parseDate(ifModifiedSinceHeader);
const lastModified = internals.parseDate(lastModifiedHeader);

if (ifModifiedSince &&
lastModified &&
Expand Down Expand Up @@ -147,6 +147,15 @@ internals.marshal = function (request, next) {
};


internals.parseDate = function (string) {

try {
return Date.parse(string);
}
catch (errIgnore) { }
};


internals.fail = function (request, boom, callback) {

const error = boom.output;
Expand Down

0 comments on commit aab2496

Please sign in to comment.