mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Fix a bug with time comparison on if-modified-since support for treatments
This commit is contained in:
@@ -86,7 +86,7 @@ function configure (app, wares, ctx) {
|
||||
var ifModifiedSince = req.get('If-Modified-Since');
|
||||
if (!ifModifiedSince) { return next(); }
|
||||
|
||||
if (lastEntryDate <= new Date(ifModifiedSince)) {
|
||||
if (lastEntryDate.getTime() <= new Date(ifModifiedSince).getTime()) {
|
||||
res.status(304).send({status:304, message: 'Not modified', type:'internal'});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
var _ = require('lodash');
|
||||
var consts = require('../../constants');
|
||||
var moment = require('moment');
|
||||
|
||||
function configure(app, wares, ctx) {
|
||||
var express = require('express')
|
||||
@@ -41,14 +42,14 @@ function configure(app, wares, ctx) {
|
||||
|
||||
var d2 = new Date(t.timestamp);
|
||||
|
||||
if (d1 == null || d2 > d1) {
|
||||
if (d1 == null || d2.getTime() > d1.getTime()) {
|
||||
d1 = d2;
|
||||
}
|
||||
});
|
||||
|
||||
if (!_.isNil(d1)) res.setHeader('Last-Modified', d1.toUTCString());
|
||||
|
||||
if (ifModifiedSince && d1 <= new Date(ifModifiedSince)) {
|
||||
if (ifModifiedSince && d1.getTime() <= moment(ifModifiedSince).valueOf()) {
|
||||
res.status(304).send({
|
||||
status: 304
|
||||
, message: 'Not modified'
|
||||
|
||||
Reference in New Issue
Block a user