diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index a28a561f179f03..97ba51959d81cc 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1939,9 +1939,12 @@ function reduceToSingleString( braces[0].length + base.length + 10; if (isBelowBreakLength(ctx, output, start, base)) { const joinedOutput = join(output, ', '); + const space = joinedOutput.length > 0 ? ' ' : ''; if (!joinedOutput.includes('\n')) { - return `${base ? `${base} ` : ''}${braces[0]} ${joinedOutput}` + - ` ${braces[1]}`; + return ( + `${base ? `${base} ` : ''}${braces[0]}${space}${joinedOutput}` + + `${space}${braces[1]}` + ); } } } diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js index fe69409a63a980..45b8449aac2fac 100644 --- a/test/parallel/test-util-inspect-proxy.js +++ b/test/parallel/test-util-inspect-proxy.js @@ -70,7 +70,7 @@ assert.strictEqual(details[1], null); details = processUtil.getProxyDetails(r.proxy, false); assert.strictEqual(details, null); -assert.strictEqual(util.inspect(r.proxy), 'Proxy [ ]'); +assert.strictEqual(util.inspect(r.proxy), 'Proxy []'); assert.strictEqual( util.inspect(r, { showProxy: true }), '{ proxy: Proxy [ null, null ], revoke: [Function (anonymous)] }',