Skip to content

Commit 55d49eb

Browse files
TrottBridgeAR
authored andcommitted
errors: replace .split() with .replace()
Replace a somewhat idiosyncratic use of `split()` to remove a prefix with `replace()`. (A case could be made for `slice()` as well but I think this is more readable.) PR-URL: #15545 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent cef6e1c commit 55d49eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ function invalidArgType(name, expected, actual) {
311311
let determiner;
312312
if (typeof expected === 'string' && expected.startsWith('not ')) {
313313
determiner = 'must not be';
314-
expected = expected.split('not ')[1];
314+
expected = expected.replace(/^not /, '');
315315
} else {
316316
determiner = 'must be';
317317
}

0 commit comments

Comments
 (0)