Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: word count is always +1 than the original value (#97)

Ammar Ahmed4a2156ec8b39
diff --git a/apps/web/src/utils/string.js b/apps/web/src/utils/string.js
index d2e7f4752..f9a077735 100644
--- a/apps/web/src/utils/string.js
+++ b/apps/web/src/utils/string.js
@@ -9,5 +9,7 @@ export function toTitleCase(str) {
export function countWords(str) {
str = str.trim();
if (!str.length) return 0;
- return str.split(/\W+\S/).length + (str[str.length] === " " ? 0 : 1);
+
+ return str.split(/\W+\S/).length;
}
+