From d10727b87ddc6bbd29e5bee9598c35ff3ca53d84 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Mon, 25 May 2026 12:46:18 -0400 Subject: [PATCH] Enhance due date parsing by validating word boundaries to prevent partial matches --- src/views/components/CustomParsers.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/views/components/CustomParsers.js b/src/views/components/CustomParsers.js index 0a45e2d..7d5d689 100644 --- a/src/views/components/CustomParsers.js +++ b/src/views/components/CustomParsers.js @@ -672,7 +672,29 @@ export const parseDueDate = (inputSentence, chrono) => { } } - const dueDateMatch = parsedDueDate[0] + let dueDateMatch = parsedDueDate[0] + + // Validate word boundaries for the matched date text + // This prevents matching partial words like "wed" in "wedding", fri in "friend", etc. + const matchStart = dueDateMatch.index + const matchEnd = matchStart + dueDateMatch.text.length + + const charBefore = matchStart > 0 ? inputSentence[matchStart - 1] : ' ' + const charAfter = + matchEnd < inputSentence.length ? inputSentence[matchEnd] : ' ' + + // Check if the match is part of a larger word + // If alphanumeric characters exist before/after, it's not a word boundary + const isValidWordBoundary = + !/[a-zA-Z0-9]/.test(charBefore) && !/[a-zA-Z0-9]/.test(charAfter) + + if (!isValidWordBoundary) { + return { + result: null, + highlight: [], + cleanedSentence: inputSentence, + } + } const dueDateText = dueDateMatch.text const dueDateStartIndex = dueDateMatch.index const dueDateEndIndex = dueDateStartIndex + dueDateText.length