mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
AK: Add support for about: URLs
This commit is contained in:
parent
6b674db855
commit
56dbe58bbb
2 changed files with 21 additions and 0 deletions
|
@ -148,4 +148,13 @@ TEST_CASE(file_url_without_hostname)
|
||||||
EXPECT_EQ(url.to_string(), "file:///my/file");
|
EXPECT_EQ(url.to_string(), "file:///my/file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE(about_url)
|
||||||
|
{
|
||||||
|
URL url("about:blank");
|
||||||
|
EXPECT_EQ(url.is_valid(), true);
|
||||||
|
EXPECT_EQ(url.protocol(), "about");
|
||||||
|
EXPECT_EQ(url.path(), "blank");
|
||||||
|
EXPECT_EQ(url.to_string(), "about:blank");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_MAIN(URL)
|
TEST_MAIN(URL)
|
||||||
|
|
12
AK/URL.cpp
12
AK/URL.cpp
|
@ -93,6 +93,12 @@ bool URL::parse(const StringView& string)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_protocol == "about") {
|
||||||
|
buffer.clear();
|
||||||
|
state = State::InPath;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (consume() != '/')
|
if (consume() != '/')
|
||||||
return false;
|
return false;
|
||||||
if (consume() != '/')
|
if (consume() != '/')
|
||||||
|
@ -245,6 +251,12 @@ String URL::to_string() const
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.append(m_protocol);
|
builder.append(m_protocol);
|
||||||
|
|
||||||
|
if (m_protocol == "about") {
|
||||||
|
builder.append(':');
|
||||||
|
builder.append(m_path);
|
||||||
|
return builder.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
if (m_protocol == "data") {
|
if (m_protocol == "data") {
|
||||||
builder.append(':');
|
builder.append(':');
|
||||||
builder.append(m_data_mime_type);
|
builder.append(m_data_mime_type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue