From 0fbfa4dfde34dfff529d9c047cfa89c9aaed0ad9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 23 Dec 2020 23:33:11 +0100 Subject: [PATCH] Fixed URI relative path resolution if the first URI is empty. --- src/tl/tl/tlUri.cc | 4 +++- src/tl/unit_tests/tlUriTests.cc | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tl/tl/tlUri.cc b/src/tl/tl/tlUri.cc index 21c9f0ece..5eb43d39b 100644 --- a/src/tl/tl/tlUri.cc +++ b/src/tl/tl/tlUri.cc @@ -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 (); } } diff --git a/src/tl/unit_tests/tlUriTests.cc b/src/tl/unit_tests/tlUriTests.cc index b240afb37..562c0280b 100644 --- a/src/tl/unit_tests/tlUriTests.cc +++ b/src/tl/unit_tests/tlUriTests.cc @@ -78,6 +78,8 @@ TEST(1) { tl::URI uri; EXPECT_EQ (uri2string (uri), ""); + EXPECT_EQ (uri2string (uri.resolved (tl::URI ("http://www.klayout.de"))), "://"); + EXPECT_EQ (uri2string (uri.resolved (tl::URI ("anyfile.txt"))), ""); uri = tl::URI ("scheme:"); EXPECT_EQ (uri2string (uri), ":");