LibURL: Remove default port handling for the IRC schemes

LibURL previously assigned a default port to the IRC schemes,
a carryover from SerenityOS where IRC is supported.

This behavior deviates from the URL Standard and affects URL parsing by
eliding an explicitly specified port when it matches the default (this
is considered a legacy behaviour of the web URL schemes). Remove the IRC
default port to restore spec-compliant behavior.
This commit is contained in:
Shannon Booth
2026-01-22 11:44:04 +01:00
committed by Shannon Booth
parent 5af269913e
commit b6969fb82d
Notes: github-actions[bot] 2026-02-06 11:04:44 +00:00
3 changed files with 28 additions and 13 deletions

View File

@@ -106,24 +106,16 @@ bool URL::cannot_have_a_username_or_password_or_port() const
// https://url.spec.whatwg.org/#default-port
Optional<u16> default_port_for_scheme(StringView scheme)
{
// Spec defined mappings with port:
if (scheme == "ftp")
if (scheme == "ftp"sv)
return 21;
if (scheme == "http")
if (scheme == "http"sv)
return 80;
if (scheme == "https")
if (scheme == "https"sv)
return 443;
if (scheme == "ws")
if (scheme == "ws"sv)
return 80;
if (scheme == "wss")
if (scheme == "wss"sv)
return 443;
// NOTE: not in spec, but we support these too
if (scheme == "irc")
return 6667;
if (scheme == "ircs")
return 6697;
return {};
}