From 8b3e2c636fbdf357b66ceef2191ab9abdd19b8df Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sun, 22 Jun 2014 17:46:29 +0000 Subject: [PATCH] Fix word count in ember. --- core/client/utils/word-count.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/client/utils/word-count.js b/core/client/utils/word-count.js index 67542c44a0..52de247015 100644 --- a/core/client/utils/word-count.js +++ b/core/client/utils/word-count.js @@ -1,6 +1,7 @@ export default function (s) { s = s.replace(/(^\s*)|(\s*$)/gi, ''); // exclude start and end white-space s = s.replace(/[ ]{2,}/gi, ' '); // 2 or more space to 1 - s = s.replace(/\n /, '\n'); // exclude newline with a start spacing - return s.split(' ').length; + s = s.replace(/\n /gi, '\n'); // exclude newline with a start spacing + s = s.replace(/\n+/gi, '\n'); + return s.split(/ |\n/).length; } \ No newline at end of file