mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
AK: Unbreak parsing of file:// URLs with no host
We should still accept file:/// in the URL parser. :^)
This commit is contained in:
parent
27d1e7f432
commit
3422019e35
Notes:
sideshowbarker
2024-07-19 06:48:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3422019e35a
2 changed files with 25 additions and 1 deletions
|
@ -130,4 +130,22 @@ TEST_CASE(serialization)
|
||||||
EXPECT_EQ(URL("https://www.serenityos.org:443/foo/bar.html?query#fragment").to_string(), "https://www.serenityos.org/foo/bar.html?query#fragment");
|
EXPECT_EQ(URL("https://www.serenityos.org:443/foo/bar.html?query#fragment").to_string(), "https://www.serenityos.org/foo/bar.html?query#fragment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE(file_url_with_hostname)
|
||||||
|
{
|
||||||
|
URL url("file://localhost/my/file");
|
||||||
|
EXPECT_EQ(url.is_valid(), true);
|
||||||
|
EXPECT_EQ(url.host(), "localhost");
|
||||||
|
EXPECT_EQ(url.path(), "/my/file");
|
||||||
|
EXPECT_EQ(url.to_string(), "file://localhost/my/file");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE(file_url_without_hostname)
|
||||||
|
{
|
||||||
|
URL url("file:///my/file");
|
||||||
|
EXPECT_EQ(url.is_valid(), true);
|
||||||
|
EXPECT_EQ(url.host(), "");
|
||||||
|
EXPECT_EQ(url.path(), "/my/file");
|
||||||
|
EXPECT_EQ(url.to_string(), "file:///my/file");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_MAIN(URL)
|
TEST_MAIN(URL)
|
||||||
|
|
|
@ -112,8 +112,14 @@ bool URL::parse(const StringView& string)
|
||||||
buffer.append(consume());
|
buffer.append(consume());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (buffer.is_empty())
|
if (buffer.is_empty()) {
|
||||||
|
if (m_protocol == "file") {
|
||||||
|
m_host = "";
|
||||||
|
state = State::InPath;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
m_host = String::copy(buffer);
|
m_host = String::copy(buffer);
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
if (peek() == ':') {
|
if (peek() == ':') {
|
||||||
|
|
Loading…
Reference in a new issue