« get me outta code hell

validators: isCommentary: better past-end-of-heading detection - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-02 10:55:01 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-02 10:55:34 -0300
commita951e0b0b51415f7d8be23d69b2f8aaace11141d (patch)
treeb7f4fe68cdfeaad010d279e26920973e1d353856 /src
parent4d4f858a698b1276a4d5bdbb61f26c0c269f1079 (diff)
validators: isCommentary: better past-end-of-heading detection
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(