From 4e5dfb581c85bacaf3d5d37e7e00649fefc3122c Mon Sep 17 00:00:00 2001 From: Tom Boutell Date: Tue, 3 Jan 2017 16:30:04 -0500 Subject: [PATCH] return null rather than empty string when the query does not contain valid data. so the filter correctly declines to apply itself. Validate full dates. Sort full dates. --- lib/cursor.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cursor.js b/lib/cursor.js index 6adb65a..d116c2c 100644 --- a/lib/cursor.js +++ b/lib/cursor.js @@ -50,7 +50,7 @@ module.exports = { s = self.apos.launder.string(s); if (!s.match(/^\d\d\d\d$/)) { - return ''; + return null; } return s; @@ -84,7 +84,7 @@ module.exports = { s = self.apos.launder.string(s); if (!s.match(/^\d\d\d\d\-\d\d$/)) { - return ''; + return null; } return s; @@ -115,14 +115,18 @@ module.exports = { }); }, launder: function(s) { - return self.apos.launder.string(s); + s = self.apos.launder.string(s); + if (!s.match(/^\d\d\d\d\-\d\d\-\d\d$/)) { + return null; + } + return s; }, choices: function(callback) { return self.toDistinct('publishedAt', function(err, results) { if (err) { return callback(err); } - + results.sort(); return callback(null, results); }); }