diff options
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 |
commit | a951e0b0b51415f7d8be23d69b2f8aaace11141d (patch) | |
tree | b7f4fe68cdfeaad010d279e26920973e1d353856 /src/data | |
parent | 4d4f858a698b1276a4d5bdbb61f26c0c269f1079 (diff) |
validators: isCommentary: better past-end-of-heading detection
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/validators.js | 7 |
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( |