mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib: refactor to avoid unsafe regex primordials
PR-URL: https://github.com/nodejs/node/pull/43475 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
parent
411fb21723
commit
a055337a02
39 changed files with 206 additions and 208 deletions
|
@ -37,8 +37,8 @@ const {
|
|||
ObjectDefineProperties,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
RegExpPrototypeSymbolReplace,
|
||||
StringPrototypeCharCodeAt,
|
||||
StringPrototypeReplace,
|
||||
StringPrototypeSlice,
|
||||
StringPrototypeToLowerCase,
|
||||
StringPrototypeTrim,
|
||||
|
@ -837,8 +837,8 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
|
|||
const max = INSPECT_MAX_BYTES;
|
||||
const actualMax = MathMin(max, this.length);
|
||||
const remaining = this.length - max;
|
||||
let str = StringPrototypeTrim(StringPrototypeReplace(
|
||||
this.hexSlice(0, actualMax), /(.{2})/g, '$1 '));
|
||||
let str = StringPrototypeTrim(RegExpPrototypeSymbolReplace(
|
||||
/(.{2})/g, this.hexSlice(0, actualMax), '$1 '));
|
||||
if (remaining > 0)
|
||||
str += ` ... ${remaining} more byte${remaining > 1 ? 's' : ''}`;
|
||||
// Inspect special properties as well, if possible.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue