From 2f11ad8be4cd28a5b8d6aef79dfdfa001bc3027c Mon Sep 17 00:00:00 2001 From: Clive Date: Tue, 4 Sep 2018 14:50:28 +0100 Subject: [PATCH 1/3] stop old commit dates being parsed out of promise URLs - fixes issue 239 --- lib/parse/promise.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/parse/promise.js b/lib/parse/promise.js index f21afac9..546067ae 100644 --- a/lib/parse/promise.js +++ b/lib/parse/promise.js @@ -30,7 +30,11 @@ export const parsePromise = ({ const { tini, tdue: dueDate, tfin } = promise const text = parseText({ text: urtext }) - const { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone }) + let { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone }) + + if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) { + startDate = null; // clear startDate if more than a year ago + } const tdue = dueDate || (startDate && moment(startDate) .add(+isAllDay, 'days') // turn boolean into 1 or 0 From 9cc7fb723ff8ffe9392ad605ffe3ae22362c6d63 Mon Sep 17 00:00:00 2001 From: clivemeister Date: Tue, 4 Sep 2018 18:17:41 +0100 Subject: [PATCH 2/3] Candidate fix for issue 239 --- lib/parse/promise.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/parse/promise.js b/lib/parse/promise.js index 546067ae..89c43648 100644 --- a/lib/parse/promise.js +++ b/lib/parse/promise.js @@ -33,6 +33,7 @@ export const parsePromise = ({ let { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone }) if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) { + log.debug('Caught and fixed promise with old parsed start date of:', startDate) startDate = null; // clear startDate if more than a year ago } From ab7b75acecb5c9efcd4002858712c0387bbd58a2 Mon Sep 17 00:00:00 2001 From: clivemeister Date: Tue, 4 Sep 2018 18:17:41 +0100 Subject: [PATCH 3/3] Candidate fix for issue 239, with fixed-up lint warnings. Also added package-lock.json to .gitignore --- .gitignore | 1 + lib/parse/promise.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a0825f7b..118ccc89 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ tmp/ # css is compiled from scss in /styles public/main.css +package-lock.json diff --git a/lib/parse/promise.js b/lib/parse/promise.js index 546067ae..31a5e3b1 100644 --- a/lib/parse/promise.js +++ b/lib/parse/promise.js @@ -33,7 +33,8 @@ export const parsePromise = ({ let { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone }) if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) { - startDate = null; // clear startDate if more than a year ago + log.warn('parsePromise rejected, past due date:', startDate) + startDate = null // clear startDate if more than a year ago } const tdue = dueDate || (startDate && moment(startDate)