From 83973937cdc380622e758ae7966a657911b91d6a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Dec 2015 22:02:47 +0100 Subject: [PATCH 1/4] trim user's sentence --- src/brain.coffee | 3 ++- src/utils.coffee | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/brain.coffee b/src/brain.coffee index d7110cf..6d57545 100644 --- a/src/brain.coffee +++ b/src/brain.coffee @@ -398,7 +398,8 @@ class Brain else # For everything else, strip all non-alphanumerics msg = utils.stripNasties(msg, @utf8) - + # cut leading and trailing blanks + msg = utils.trimWhitespace(msg); return msg ## diff --git a/src/utils.coffee b/src/utils.coffee index a9643a3..c175d7f 100644 --- a/src/utils.coffee +++ b/src/utils.coffee @@ -130,3 +130,12 @@ exports.clone = (obj) -> copy[key] = exports.clone(obj[key]) return copy + +# cut leading and trailings blanks + +exports.trimWhitespace = (value) -> + result = value.match(/^\s*(.*\S)\s*$/); + if (result != null && result.length == 2) + return result[1] + else + return value From ec4554b881a4cba72f5b949cea617b5a3c183bea Mon Sep 17 00:00:00 2001 From: pirelaurent Date: Tue, 22 Dec 2015 17:09:07 +0100 Subject: [PATCH 2/4] Revert "trim user's sentence" This reverts commit 83973937cdc380622e758ae7966a657911b91d6a. --- src/brain.coffee | 3 +-- src/utils.coffee | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/brain.coffee b/src/brain.coffee index 6d57545..d7110cf 100644 --- a/src/brain.coffee +++ b/src/brain.coffee @@ -398,8 +398,7 @@ class Brain else # For everything else, strip all non-alphanumerics msg = utils.stripNasties(msg, @utf8) - # cut leading and trailing blanks - msg = utils.trimWhitespace(msg); + return msg ## diff --git a/src/utils.coffee b/src/utils.coffee index c175d7f..a9643a3 100644 --- a/src/utils.coffee +++ b/src/utils.coffee @@ -130,12 +130,3 @@ exports.clone = (obj) -> copy[key] = exports.clone(obj[key]) return copy - -# cut leading and trailings blanks - -exports.trimWhitespace = (value) -> - result = value.match(/^\s*(.*\S)\s*$/); - if (result != null && result.length == 2) - return result[1] - else - return value From 0450804c81f64f3098f37a3b59ef409e479abd1f Mon Sep 17 00:00:00 2001 From: pirelaurent Date: Tue, 22 Dec 2015 21:12:03 +0100 Subject: [PATCH 3/4] trim user's sentence after punctuation removal --- src/brain.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/brain.coffee b/src/brain.coffee index d7110cf..d081908 100644 --- a/src/brain.coffee +++ b/src/brain.coffee @@ -398,7 +398,9 @@ class Brain else # For everything else, strip all non-alphanumerics msg = utils.stripNasties(msg, @utf8) - + + # cut leading and trailing blanks once punctuation dropped office + msg = msg.trim() return msg ## From 9acf05304c7b587a264e47df14956b088d20ed3e Mon Sep 17 00:00:00 2001 From: pirelaurent Date: Tue, 22 Dec 2015 21:57:04 +0100 Subject: [PATCH 4/4] tab changed to spaces in comment --- src/brain.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brain.coffee b/src/brain.coffee index d081908..1dadcb9 100644 --- a/src/brain.coffee +++ b/src/brain.coffee @@ -398,8 +398,8 @@ class Brain else # For everything else, strip all non-alphanumerics msg = utils.stripNasties(msg, @utf8) - - # cut leading and trailing blanks once punctuation dropped office + + # cut leading and trailing blanks once punctuation dropped office msg = msg.trim() return msg