Skip to content

Commit

Permalink
trim user's sentence
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Dec 21, 2015
1 parent 5d2435b commit 8397393
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/brain.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

##
Expand Down
9 changes: 9 additions & 0 deletions src/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8397393

Please sign in to comment.