Browse Source

url: do not public expose inspect methods on URL

PR-URL: https://github.com/nodejs/node/pull/10906
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
v6
Timothy Gu 8 years ago
parent
commit
d65904bc6a
  1. 4
      lib/internal/url.js
  2. 5
      test/parallel/test-whatwg-url-parsing.js

4
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`;

5
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');

Loading…
Cancel
Save