diff --git a/lib/internal/blob.js b/lib/internal/blob.js index 6a526de7bfeb73..f27992eb2dcdfd 100644 --- a/lib/internal/blob.js +++ b/lib/internal/blob.js @@ -360,7 +360,7 @@ function resolveObjectURL(url) { try { const parsed = new URL(url); - const split = StringPrototypeSplit(parsed.pathname, ':'); + const split = StringPrototypeSplit(parsed.pathname, ':', 3); if (split.length !== 2) return; diff --git a/lib/internal/debugger/inspect.js b/lib/internal/debugger/inspect.js index 5e93699f8ba078..75636b159ede2e 100644 --- a/lib/internal/debugger/inspect.js +++ b/lib/internal/debugger/inspect.js @@ -160,7 +160,7 @@ class NodeInspector { this[domain] = createAgentProxy(domain, this.client); }); this.handleDebugEvent = (fullName, params) => { - const { 0: domain, 1: name } = StringPrototypeSplit(fullName, '.'); + const { 0: domain, 1: name } = StringPrototypeSplit(fullName, '.', 2); if (domain in this) { this[domain].emit(name, params); } diff --git a/lib/internal/errors.js b/lib/internal/errors.js index a0a39de45b2a59..87200b40d45bdc 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -907,7 +907,7 @@ const fatalExceptionStackEnhancers = { // ANSI escape sequences is not reliable. if (isWindows) { const info = internalBinding('os').getOSInformation(); - const ver = ArrayPrototypeMap(StringPrototypeSplit(info[2], '.'), + const ver = ArrayPrototypeMap(StringPrototypeSplit(info[2], '.', 3), Number); if (ver[0] !== 10 || ver[2] < 14393) { useColors = false; diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 96455306f3696d..be4bedeb12a535 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -1833,7 +1833,7 @@ function reconstructErrorStack(err, parentPath, parentSource) { const { 1: line, 2: col } = RegExpPrototypeExec(/(\d+):(\d+)\)/, errLine) || []; if (line && col) { - const srcLine = StringPrototypeSplit(parentSource, '\n')[line - 1]; + const srcLine = StringPrototypeSplit(parentSource, '\n', line)[line - 1]; const frame = `${parentPath}:${line}\n${srcLine}\n${StringPrototypeRepeat(' ', col - 1)}^\n`; setArrowMessage(err, frame); } diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index 7c83e58f7b7ee6..f33dc937102dc2 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -218,7 +218,7 @@ class ModuleJob extends ModuleJobBase { if (!getSourceMapsSupport().enabled && StringPrototypeIncludes(e.message, ' does not provide an export named')) { - const splitStack = StringPrototypeSplit(e.stack, '\n'); + const splitStack = StringPrototypeSplit(e.stack, '\n', 2); const parentFileUrl = RegExpPrototypeSymbolReplace( /:\d+$/, splitStack[0], diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js index 9bdb834ff84fd7..1252df343334f5 100644 --- a/lib/internal/repl/await.js +++ b/lib/internal/repl/await.js @@ -178,7 +178,7 @@ function processTopLevelAwait(src) { return null; const line = e.loc.line; const column = line === 1 ? e.loc.column - wrapPrefix.length : e.loc.column; - let message = '\n' + StringPrototypeSplit(src, '\n')[line - 1] + '\n' + + let message = '\n' + StringPrototypeSplit(src, '\n', line)[line - 1] + '\n' + StringPrototypeRepeat(' ', column) + '^\n\n' + RegExpPrototypeSymbolReplace(/ \([^)]+\)/, e.message, ''); // V8 unexpected token errors include the token string. diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index bdef338e3dd086..639051ec10fe61 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -292,7 +292,7 @@ function sourceMapFromFile(mapURL) { // data:[][;base64], see: // https://tools.ietf.org/html/rfc2397#section-2 function sourceMapFromDataUrl(sourceURL, url) { - const { 0: format, 1: data } = StringPrototypeSplit(url, ','); + const { 0: format, 1: data } = StringPrototypeSplit(url, ',', 2); const splitFormat = StringPrototypeSplit(format, ';'); const contentType = splitFormat[0]; const base64 = splitFormat[splitFormat.length - 1] === 'base64'; diff --git a/lib/internal/test_runner/utils.js b/lib/internal/test_runner/utils.js index 6a2ded4cd53b30..0fdd858fd94e28 100644 --- a/lib/internal/test_runner/utils.js +++ b/lib/internal/test_runner/utils.js @@ -263,7 +263,7 @@ function parseCommandLine() { ); } - const indexAndTotal = StringPrototypeSplit(shardOption, '/'); + const indexAndTotal = StringPrototypeSplit(shardOption, '/', 2); shard = { __proto__: null, index: NumberParseInt(indexAndTotal[0], 10), diff --git a/lib/internal/tty.js b/lib/internal/tty.js index b0bfac122781cc..486c2d06e7e9b8 100644 --- a/lib/internal/tty.js +++ b/lib/internal/tty.js @@ -138,7 +138,7 @@ function getColorDepth(env = process.env) { // Lazy load for startup performance. if (OSRelease === undefined) { const { release } = require('os'); - OSRelease = StringPrototypeSplit(release(), '.'); + OSRelease = StringPrototypeSplit(release(), '.', 3); } // Windows 10 build 10586 is the first Windows release that supports 256 // colors. Windows 10 build 14931 is the first release that supports diff --git a/lib/internal/util/debuglog.js b/lib/internal/util/debuglog.js index 96b10c4bbac767..919ab97f11547e 100644 --- a/lib/internal/util/debuglog.js +++ b/lib/internal/util/debuglog.js @@ -160,6 +160,7 @@ function formatTime(ms) { ({ 0: seconds, 1: ms } = StringPrototypeSplit( NumberPrototypeToFixed(seconds, 3), '.', + 2, )); const res = hours !== 0 ? `${hours}:${pad(minutes)}` : minutes; return `${res}:${pad(seconds)}.${ms} (${hours !== 0 ? 'h:m' : ''}m:ss.mmm)`; diff --git a/lib/internal/worker/js_transferable.js b/lib/internal/worker/js_transferable.js index 592d43d2152e0a..b830c161bbf556 100644 --- a/lib/internal/worker/js_transferable.js +++ b/lib/internal/worker/js_transferable.js @@ -35,7 +35,7 @@ function setup() { // from .postMessage() calls. The format of `deserializeInfo` is generally // 'module:Constructor', e.g. 'internal/fs/promises:FileHandle'. setDeserializerCreateObjectFunction((deserializeInfo) => { - const { 0: module, 1: ctor } = StringPrototypeSplit(deserializeInfo, ':'); + const { 0: module, 1: ctor } = StringPrototypeSplit(deserializeInfo, ':', 2); const Ctor = require(module)[ctor]; if (typeof Ctor !== 'function' || typeof Ctor.prototype[messaging_deserialize_symbol] !== 'function') { diff --git a/lib/tls.js b/lib/tls.js index 06a6695034d8a0..91ea8ad65a395c 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -254,7 +254,7 @@ function check(hostParts, pattern, wildcards) { const hostSubdomain = hostParts[0]; const patternSubdomain = patternParts[0]; - const patternSubdomainParts = patternSubdomain.split('*'); + const patternSubdomainParts = patternSubdomain.split('*', 3); // Short-circuit when the subdomain does not contain a wildcard. // RFC 6125 does not allow wildcard substitution for components