File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -91,16 +91,17 @@ interface Block {
91
91
const CHANGELOG_LINE = / ^ \s * • / ;
92
92
type Messages = [ Block [ ] , ...Array < Block [ ] | FileUpload > ] ;
93
93
94
- /** Split a long spring into chunks by character limit */
94
+ /** Split a long string into chunks by character limit */
95
95
const splitCharacterLimitAtNewline = ( line : string , charLimit : number ) => {
96
96
const splitLines = [ ] ;
97
97
let buffer = line ;
98
98
99
99
while ( buffer ) {
100
100
// get the \n closest to the char limit
101
- const newlineIndex = buffer . lastIndexOf ( "\n" , charLimit ) || charLimit ;
102
- splitLines . push ( buffer . slice ( 0 , newlineIndex ) ) ;
103
- buffer = buffer . slice ( newlineIndex ) ;
101
+ const newlineIndex = buffer . indexOf ( "\n" , charLimit ) ;
102
+ const endOfLine = newlineIndex >= 0 ? newlineIndex : charLimit ;
103
+ splitLines . push ( buffer . slice ( 0 , endOfLine ) ) ;
104
+ buffer = buffer . slice ( endOfLine ) ;
104
105
}
105
106
106
107
return splitLines ;
You can’t perform that action at this time.
0 commit comments