From d65904bc6a340d67c10efdcb9fa083b3bf20d234 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Thu, 19 Jan 2017 17:19:41 -0800 Subject: [PATCH] url: do not public expose inspect methods on URL PR-URL: https://github.com/nodejs/node/pull/10906 Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/internal/url.js | 4 ++-- test/parallel/test-whatwg-url-parsing.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index c976e950076eaf..9ab469c9ffa570 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -77,7 +77,7 @@ class TupleOrigin { return result; } - inspect() { + [util.inspect.custom]() { return `TupleOrigin { scheme: ${this[kScheme]}, host: ${this[kHost]}, @@ -235,7 +235,7 @@ class URL { return (this[context].flags & binding.URL_FLAGS_CANNOT_BE_BASE) !== 0; } - inspect(depth, opts) { + [util.inspect.custom](depth, opts) { const ctx = this[context]; var ret = 'URL {\n'; ret += ` href: ${this.href}\n`; diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index 9ea6cc74bff5e6..f1fd2ae9051533 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -1,6 +1,7 @@ 'use strict'; const common = require('../common'); +const util = require('util'); if (!common.hasIntl) { // A handful of the tests fail when ICU is not included. @@ -144,8 +145,8 @@ for (const test of allTests) { const url = test.url ? new URL(test.url) : new URL(test.input, test.base); for (const showHidden of [true, false]) { - const res = url.inspect(null, { - showHidden: showHidden + const res = util.inspect(url, { + showHidden }); const lines = res.split('\n');