Skip to content

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

core: fix crash if note title only contains whitespace

Abdullah Atta088c6670a9ff
diff --git a/packages/core/src/utils/grouping.js b/packages/core/src/utils/grouping.js
index 0e8d4affa..900a59c56 100644
--- a/packages/core/src/utils/grouping.js
+++ b/packages/core/src/utils/grouping.js
@@ -163,7 +163,9 @@ function addToGroup(groups, groupTitle, item) {
const REGEX = /\S/;
function getFirstCharacter(str) {
if (!str) return "-";
- return REGEX.exec(str)[0].toUpperCase();
+ const matches = REGEX.exec(str);
+ if (!matches || !matches.length) return "-";
+ return matches[0].toUpperCase();
}
function flattenGroups(groups) {