Fixed URI relative path resolution if the first URI is empty.

This commit is contained in:
Matthias Koefferlein 2020-12-23 23:33:11 +01:00
parent ca1ec353fb
commit 0fbfa4dfde
2 changed files with 5 additions and 1 deletions

View File

@ -227,7 +227,9 @@ URI::resolved (const URI &other) const
if (other.path ()[0] == '/') {
res.m_path = other.path ();
} else {
res.m_path += "/";
if (! res.m_path.empty ()) {
res.m_path += "/";
}
res.m_path += other.path ();
}
}

View File

@ -78,6 +78,8 @@ TEST(1)
{
tl::URI uri;
EXPECT_EQ (uri2string (uri), "");
EXPECT_EQ (uri2string (uri.resolved (tl::URI ("http://www.klayout.de"))), "<http>://<www.klayout.de>");
EXPECT_EQ (uri2string (uri.resolved (tl::URI ("anyfile.txt"))), "<anyfile.txt>");
uri = tl::URI ("scheme:");
EXPECT_EQ (uri2string (uri), "<scheme>:");