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

LibWeb: Make the URL.port setter return after assigning the empty string

This matches the spec ("3. Otherwise, ...")
This commit is contained in:
Andreas Kling 2021-10-03 20:18:34 +02:00
parent a7a3f41f67
commit ba0c907a6f

View file

@ -186,9 +186,13 @@ void URL::set_port(String const& port)
// 1. If thiss URL cannot have a username/password/port, then return.
if (m_url.cannot_have_a_username_or_password_or_port())
return;
// 2. If the given value is the empty string, then set thiss URLs port to null.
if (port.is_empty())
if (port.is_empty()) {
m_url.set_port({});
return;
}
// 3. Otherwise, basic URL parse the given value with thiss URL as url and port state as state override.
auto result_url = URLParser::parse(port, nullptr, m_url, URLParser::State::Port);
if (result_url.is_valid())