From ba0c907a6f4501d467cc3c7f0dc5059cfccd61ac Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Oct 2021 20:18:34 +0200 Subject: [PATCH] LibWeb: Make the URL.port setter return after assigning the empty string This matches the spec ("3. Otherwise, ...") --- Userland/Libraries/LibWeb/URL/URL.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index 814d1a78f4..dff06d367c 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -186,9 +186,13 @@ void URL::set_port(String const& port) // 1. If this’s 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 this’s URL’s 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 this’s 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())