« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/validators.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/data/validators.js b/src/data/validators.js
index b27dd68f..d89c23bb 100644
--- a/src/data/validators.js
+++ b/src/data/validators.js
@@ -311,8 +311,11 @@ export function isCommentary(commentaryText) {
 
     const ownInput = commentaryText.slice(position, position + length);
     const restOfInput = commentaryText.slice(position + length);
-    const nextLineBreak = restOfInput.indexOf('\n');
-    const upToNextLineBreak = restOfInput.slice(0, nextLineBreak);
+
+    const upToNextLineBreak =
+      (restOfInput.includes('\n')
+        ? restOfInput.slice(0, restOfInput.indexOf('\n'))
+        : restOfInput);
 
     if (/\S/.test(upToNextLineBreak)) {
       throw new TypeError(