Skip to content

Comments

URL: add host setter tests for empty host with port#53458

Merged
anonrig merged 1 commit intoweb-platform-tests:masterfrom
watilde:test/url-port-host-setter
Jun 29, 2025
Merged

URL: add host setter tests for empty host with port#53458
anonrig merged 1 commit intoweb-platform-tests:masterfrom
watilde:test/url-port-host-setter

Conversation

@watilde
Copy link
Contributor

@watilde watilde commented Jun 28, 2025

This PR adds tests to capture the following difference in host setter behavior:

const NodeURL = require("url").URL;
const WhatwgURL = require("whatwg-url").URL;
const newHost = ':80';

const url = new NodeURL("foo://path/to");  
url.host = newHost;
console.log(url.href); // => foo://:80/to

const url2 = new WhatwgURL("foo://path/to");
url2.host = newHost;
console.log(url2.href); // => foo://path/to

According to the WHATWG URL Standard, setting host = ":80" when the host is missing should fail, rather than produce an empty host with a port.

Refs: ada-url/ada#963

@anonrig anonrig merged commit fee00f9 into web-platform-tests:master Jun 29, 2025
25 checks passed
@watilde watilde deleted the test/url-port-host-setter branch June 29, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants