Skip to content

Commit 1618829

Browse files
authored
fix(Util): splitMessage throws an error if a chunk is too large (#3060)
1 parent a0ff72b commit 1618829

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/util/Util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class Util {
1919
static splitMessage(text, { maxLength = 1950, char = '\n', prepend = '', append = '' } = {}) {
2020
if (text.length <= maxLength) return text;
2121
const splitText = text.split(char);
22-
if (splitText.length === 1) throw new Error('Message exceeds the max length and contains no split characters.');
22+
if (splitText.some(chunk => chunk.length > maxLength)) {
23+
throw new Error('Message exceeds the max length and contains no split characters.');
24+
}
2325
const messages = [''];
2426
let msg = 0;
2527
for (let i = 0; i < splitText.length; i++) {

0 commit comments

Comments
 (0)