Merge pull request #3033 from halfdan/fix-word-count

Fix word count in ember.
This commit is contained in:
Hannah Wolfe 2014-06-23 12:11:19 +01:00
commit 79c2132905

View File

@ -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;
}