1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

AK: Add missing default port definitions for FTP scheme URLs

This is defined in the spec, but was missing in our table. Fix this, and
add a spec comment for what is missing. Also begin a basic text based
test for URL, so we can get some coverage of LibWeb's usage of URL too.
This commit is contained in:
Shannon Booth 2023-07-31 20:23:53 +12:00 committed by Andreas Kling
parent 25153703c9
commit 4fdd4dd979
3 changed files with 43 additions and 4 deletions

View file

@ -204,22 +204,29 @@ bool URL::compute_validity() const
return true;
}
// https://url.spec.whatwg.org/#default-port
u16 URL::default_port_for_scheme(StringView scheme)
{
// Spec defined mappings with port:
if (scheme == "ftp")
return 21;
if (scheme == "http")
return 80;
if (scheme == "https")
return 443;
if (scheme == "ws")
return 80;
if (scheme == "wss")
return 443;
// NOTE: not in spec, but we support these too
if (scheme == "gemini")
return 1965;
if (scheme == "irc")
return 6667;
if (scheme == "ircs")
return 6697;
if (scheme == "ws")
return 80;
if (scheme == "wss")
return 443;
return 0;
}