From 835496375f59701486b9cdd666f43d9aa56d1788 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 21 Oct 2019 17:19:17 +0200 Subject: URL: https:// URLs should default to port 443 --- AK/URL.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'AK/URL.cpp') diff --git a/AK/URL.cpp b/AK/URL.cpp index 81fda73dd7..a110936302 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -60,6 +60,10 @@ bool URL::parse(const StringView& string) if (buffer.is_empty()) return false; m_protocol = String::copy(buffer); + if (m_protocol == "http") + m_port = 80; + else if (m_protocol == "https") + m_port = 443; buffer.clear(); if (m_protocol == "file") state = State::InPath; @@ -133,7 +137,7 @@ String URL::to_string() const builder.append("://"); if (protocol() != "file") { builder.append(m_host); - if (protocol() != "http" || port() != 80) { + if (!(protocol() == "http" && port() == 80) && !(protocol() == "https" && port() == 443)) { builder.append(':'); builder.append(String::number(m_port)); } -- cgit v1.2.3