Skip to content

Commit bbde06d

Browse files
committed
fixup! assert: refactor to avoid unsafe array iteration
1 parent 5157b25 commit bbde06d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/assert/assertion_error.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,14 @@ function createErrDiff(actual, expected, operator) {
314314
}
315315

316316
function addEllipsis(string) {
317-
const lines = StringPrototypeSplit(string, '\n');
317+
const lines = StringPrototypeSplit(string, '\n', 11);
318318
if (lines.length > 10) {
319319
lines.length = 10;
320320
return `${ArrayPrototypeJoin(lines, '\n')}\n...`;
321321
} else if (string.length > 512) {
322322
return `${StringPrototypeSlice(string, 512)}...`;
323323
}
324+
return string;
324325
}
325326

326327
class AssertionError extends Error {

0 commit comments

Comments
 (0)