Skip to content

Commit

Permalink
src: accept single argument in getProxyDetails
Browse files Browse the repository at this point in the history
This makes sure this function stays backwards compatible in case
it's accessed through the binding directly.

Refs: nodejs#29947 (comment)

PR-URL: nodejs#30858
Refs: nodejs#30767
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
BridgeAR authored and Trott committed Dec 11, 2019
1 parent 9c32b24 commit fb14ed4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) {
if (!args[0]->IsProxy())
return;

CHECK(args[1]->IsBoolean());

Local<Proxy> proxy = args[0].As<Proxy>();

if (args[1]->IsTrue()) {
// TODO(BridgeAR): Remove the length check as soon as we prohibit access to
// the util binding layer. It's accessed in the wild and `esm` would break in
// case the check is removed.
if (args.Length() == 1 || args[1]->IsTrue()) {
Local<Value> ret[] = {
proxy->GetTarget(),
proxy->GetHandler()
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-util-inspect-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ let details = processUtil.getProxyDetails(proxyObj, true);
assert.strictEqual(target, details[0]);
assert.strictEqual(handler, details[1]);

details = processUtil.getProxyDetails(proxyObj);
assert.strictEqual(target, details[0]);
assert.strictEqual(handler, details[1]);

details = processUtil.getProxyDetails(proxyObj, false);
assert.strictEqual(target, details);

Expand Down

0 comments on commit fb14ed4

Please sign in to comment.