GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — util: fix inspecting URL subclass prototypes · nodejs/node@3f5f257

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/util
    • inspect.js
  • test/parallel
    • test-util-inspect-url.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/util/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function pathToFileUrlHref(filepath) {
205205

206206
function isURL(value) {
207207
internalUrl ??= require('internal/url');
208-
return typeof value.href === 'string' && value instanceof internalUrl.URL;
208+
return internalUrl.isURLInstance(value) && typeof value.href === 'string';
209209
}
210210

211211
const builtInObjects = new SafeSet(
Collapse file

‎test/parallel/test-util-inspect-url.js‎

Copy file name to clipboard
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const { format, inspect } = require('util');
6+
7+
class TestURL extends URL {}
8+
9+
assert.strictEqual(inspect(TestURL.prototype), 'URL {}');
10+
assert.strictEqual(
11+
inspect(TestURL.prototype, { customInspect: false }),
12+
'URL {}',
13+
);
14+
15+
// Inspecting hidden properties must not throw when reaching the prototype.
16+
inspect(TestURL, { showHidden: true });
17+
inspect({ TestURL }, { showHidden: true });
18+
format('%o', { TestURL });
19+
20+
const url = new TestURL('https://example.org/');
21+
assert.strictEqual(
22+
inspect(url, { customInspect: false }),
23+
'https://example.org/',
24+
);
25+
26+
class NonStringURL extends URL {
27+
get href() {
28+
return undefined;
29+
}
30+
}
31+
32+
assert.strictEqual(
33+
inspect(new NonStringURL('https://example.org/'), { customInspect: false }),
34+
'NonStringURL [URL] {}',
35+
);

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.