summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-21 17:19:17 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-21 17:19:17 +0200
commit835496375f59701486b9cdd666f43d9aa56d1788 (patch)
tree45f4ed514eb46f75c6b0d9046d7ae23afa2ab2b0 /AK
parent9c434d8c6a3244bde1fdd48a653d73e7867ab3e4 (diff)
downloadserenity-835496375f59701486b9cdd666f43d9aa56d1788.zip
URL: https:// URLs should default to port 443
Diffstat (limited to 'AK')
-rw-r--r--AK/URL.cpp6
1 files changed, 5 insertions, 1 deletions
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));
}