mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: URL should support file:// URL's
Also add some setters since this class was very setter-less.
This commit is contained in:
13
AK/URL.cpp
13
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user