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 — url: validate href setter receiver first · nodejs/node@c8ee016

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • url.js
  • test/parallel
    • test-whatwg-url-custom-href-side-effect.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/url.js‎

Copy file name to clipboardExpand all lines: lib/internal/url.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,9 @@ class URL {
10221022
}
10231023

10241024
set href(value) {
1025+
const context = this.#context;
10251026
value = `${value}`;
1026-
const href = bindingUrl.update(this.#context.href, updateActions.kHref, value);
1027+
const href = bindingUrl.update(context.href, updateActions.kHref, value);
10271028
if (!href) { throw new ERR_INVALID_URL(value); }
10281029
this.#updateContext(href, true);
10291030
}
Collapse file

‎test/parallel/test-whatwg-url-custom-href-side-effect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-url-custom-href-side-effect.js
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,19 @@ assert.throws(() => {
1313
});
1414

1515
assert.deepStrictEqual(url, ref);
16+
17+
const setHref = Object.getOwnPropertyDescriptor(URL.prototype, 'href').set;
18+
let calls = 0;
19+
20+
assert.throws(() => {
21+
setHref.call({}, {
22+
toString() {
23+
calls++;
24+
return 'https://example.com/';
25+
},
26+
});
27+
}, {
28+
name: 'TypeError',
29+
});
30+
31+
assert.strictEqual(calls, 0);

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.