Merge pull request #694 from KLayout/issue-693

Fixed #693: URI relative path resolution if the first URI is empty.
This commit is contained in:
Matthias Köfferlein 2020-12-27 21:23:40 +01:00 committed by GitHub
commit 70dcc92640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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>:");