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: align url format behavior with browsers · nodejs/node@d13fc6e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • url.js
  • test/parallel
    • test-whatwg-url-override-hostname.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
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ ObjectDefineProperties(URL.prototype, {
416416
ret += '@';
417417
}
418418
ret += options.unicode ?
419-
domainToUnicode(this.hostname) : this.hostname;
419+
domainToUnicode(ctx.host) : ctx.host;
420420
if (ctx.port !== null)
421421
ret += `:${ctx.port}`;
422422
} else if (ctx.scheme === 'file:') {
Collapse file

‎test/parallel/test-whatwg-url-override-hostname.js‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
{
7+
const url = new (class extends URL { get hostname() { return 'bar.com'; } })('http://foo.com/');
8+
assert.strictEqual(url.href, 'http://foo.com/');
9+
assert.strictEqual(url.toString(), 'http://foo.com/');
10+
assert.strictEqual(url.toJSON(), 'http://foo.com/');
11+
assert.strictEqual(url.hash, '');
12+
assert.strictEqual(url.host, 'foo.com');
13+
assert.strictEqual(url.hostname, 'bar.com');
14+
assert.strictEqual(url.origin, 'http://foo.com');
15+
assert.strictEqual(url.password, '');
16+
assert.strictEqual(url.protocol, 'http:');
17+
assert.strictEqual(url.username, '');
18+
assert.strictEqual(url.search, '');
19+
assert.strictEqual(url.searchParams.toString(), '');
20+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.