Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions plugins/slack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ interface Block {
const CHANGELOG_LINE = /^\s*•/;
type Messages = [Block[], ...Array<Block[] | FileUpload>];

/** Split a long spring into chunks by character limit */
/** Split a long string into chunks by character limit */
const splitCharacterLimitAtNewline = (line: string, charLimit: number) => {
const splitLines = [];
let buffer = line;

while (buffer) {
// get the \n closest to the char limit
const newlineIndex = buffer.lastIndexOf("\n", charLimit) || charLimit;
splitLines.push(buffer.slice(0, newlineIndex));
buffer = buffer.slice(newlineIndex);
const newlineIndex = buffer.indexOf("\n", charLimit);
const endOfLine = newlineIndex >= 0 ? newlineIndex : charLimit;
splitLines.push(buffer.slice(0, endOfLine));
buffer = buffer.slice(endOfLine);
}

return splitLines;
Expand Down