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: #29947 (comment)

PR-URL: #30858
Refs: #30767
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • 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.