Fix word count in ember.

This commit is contained in:
Fabian Becker 2014-06-22 17:46:29 +00:00
parent 3fc9075383
commit 8b3e2c636f

View File

@ -1,6 +1,7 @@
export default function (s) { export default function (s) {
s = s.replace(/(^\s*)|(\s*$)/gi, ''); // exclude start and end white-space 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(/[ ]{2,}/gi, ' '); // 2 or more space to 1
s = s.replace(/\n /, '\n'); // exclude newline with a start spacing s = s.replace(/\n /gi, '\n'); // exclude newline with a start spacing
return s.split(' ').length; s = s.replace(/\n+/gi, '\n');
return s.split(/ |\n/).length;
} }