Better URL parsing

This commit is contained in:
Fred Nicolson
2019-06-26 13:50:01 +01:00
parent a515cf7c92
commit a4adac8bf7
2 changed files with 30 additions and 3 deletions
+24
View File
@@ -88,4 +88,28 @@ TEST(URLTest, test_modify_url)
fr::URL url("https://example.com:2020");
url.set_host("example.co.uk");
ASSERT_EQ(url.get_url(), "https://example.co.uk:2020");
}
TEST(URLTest, test_path_only_parse)
{
{
fr::URL url("/bob");
ASSERT_TRUE(url.get_host().empty());
ASSERT_EQ(url.get_path(), "/bob");
}
{
fr::URL url("bob");
ASSERT_TRUE(url.get_host().empty());
ASSERT_EQ(url.get_path(), "/bob");
}
{
fr::URL url("http://bob");
ASSERT_EQ(url.get_host(), "bob");
ASSERT_TRUE(url.get_path().empty());
}
{
fr::URL url("bob.com/trob");
ASSERT_EQ(url.get_host(), "bob.com");
ASSERT_EQ(url.get_path(), "/trob");
}
}