Skip to content

Commit a57dce7

Browse files
committed
fix: Exclude line slicing by zero.
1 parent d33e11c commit a57dce7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bin/readme-assertions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const trimCode = (code) => {
1616
const lastIndentSize = lastLineIndentation ? lastLineIndentation[0].length : 0;
1717

1818
lines = lines.map((line, index) => {
19-
if (index === 0) {
20-
return line.slice(Math.min(firstIndentSize, lastIndentSize));
21-
}
19+
const lineIndentSize = firstIndentSize !== 0 || index === 0 ?
20+
Math.min(firstIndentSize, lastIndentSize) :
21+
lastIndentSize;
2222

23-
return line.slice(lastIndentSize);
23+
return line.slice(lineIndentSize);
2424
});
2525

2626
return lines.join('\n');

0 commit comments

Comments
 (0)