Skip to content

Commit

Permalink
fixup! assert: refactor to avoid unsafe array iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Feb 13, 2021
1 parent 5157b25 commit bbde06d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/internal/assert/assertion_error.js
Expand Up @@ -314,13 +314,14 @@ function createErrDiff(actual, expected, operator) {
}

function addEllipsis(string) {
const lines = StringPrototypeSplit(string, '\n');
const lines = StringPrototypeSplit(string, '\n', 11);
if (lines.length > 10) {
lines.length = 10;
return `${ArrayPrototypeJoin(lines, '\n')}\n...`;
} else if (string.length > 512) {
return `${StringPrototypeSlice(string, 512)}...`;
}
return string;
}

class AssertionError extends Error {
Expand Down

0 comments on commit bbde06d

Please sign in to comment.