summaryrefslogtreecommitdiff
path: root/AK/URL.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-05 10:14:42 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-05 10:14:42 +0200
commitd64c054d25417db7905e5be0d7d69d146b030be3 (patch)
tree49ba3c99e6bf9473344632d3b6a2d320e91b366b /AK/URL.cpp
parent4f47146433fb668bbbb67634a1dc936e53830279 (diff)
downloadserenity-d64c054d25417db7905e5be0d7d69d146b030be3.zip
AK: URL should support file:// URL's
Also add some setters since this class was very setter-less.
Diffstat (limited to 'AK/URL.cpp')
-rw-r--r--AK/URL.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/AK/URL.cpp b/AK/URL.cpp
index 1a026d9e5f..0ddcecd170 100644
--- a/AK/URL.cpp
+++ b/AK/URL.cpp
@@ -61,7 +61,10 @@ bool URL::parse(const StringView& string)
return false;
m_protocol = String::copy(buffer);
buffer.clear();
- state = State::InHostname;
+ if (m_protocol == "file")
+ state = State::InPath;
+ else
+ state = State::InHostname;
continue;
case State::InHostname:
if (is_valid_hostname_character(peek())) {
@@ -120,9 +123,11 @@ String URL::to_string() const
StringBuilder builder;
builder.append(m_protocol);
builder.append("://");
- builder.append(m_host);
- builder.append(':');
- builder.append(String::number(m_port));
+ if (protocol() != "file") {
+ builder.append(m_host);
+ builder.append(':');
+ builder.append(String::number(m_port));
+ }
builder.append(m_path);
return builder.to_string();
}