diff --git a/include/jsoncons/utility/uri.hpp b/include/jsoncons/utility/uri.hpp index 5d903cb23..4953b6f40 100644 --- a/include/jsoncons/utility/uri.hpp +++ b/include/jsoncons/utility/uri.hpp @@ -817,7 +817,7 @@ namespace jsoncons { namespace utility { if (!base.encoded_authority().empty() && base.encoded_path().empty()) { result = "/"; - result.append(relative.encoded_path().data(), relative.encoded_path().length()); + //result.append(relative.encoded_path().data(), relative.encoded_path().length()); } else { diff --git a/test/corelib/src/utility/uri_tests.cpp b/test/corelib/src/utility/uri_tests.cpp index 358a1d20d..c584e6821 100644 --- a/test/corelib/src/utility/uri_tests.cpp +++ b/test/corelib/src/utility/uri_tests.cpp @@ -216,6 +216,33 @@ TEST_CASE("uri base tests") TEST_CASE("uri resolve tests") { + SECTION("empty base") + { + jsoncons::uri base{ "" }; + jsoncons::uri rel{"dir1/other.schema.json"}; + jsoncons::uri uri = rel.resolve(base); + CHECK(uri.base().string() == "dir1/other.schema.json"); + CHECK(uri.path() == "dir1/other.schema.json"); + } + + SECTION("base has no authority and no path") + { + jsoncons::uri base{ "https" }; + jsoncons::uri rel{ "dir1/other.schema.json" }; + jsoncons::uri uri = rel.resolve(base); + CHECK(uri.base().string() == "dir1/other.schema.json"); + CHECK(uri.path() == "dir1/other.schema.json"); + } + + SECTION("base has authority and path") + { + jsoncons::uri base{ "https://root" }; + jsoncons::uri rel{"dir1/other.schema.json"}; + jsoncons::uri uri = rel.resolve(base); + CHECK(uri.base().string() == "https://root/dir1/other.schema.json"); + CHECK(uri.path() == "/dir1/other.schema.json"); + } + SECTION("folder/") { jsoncons::uri base_uri("http://localhost:1234/scope_change_defs2.json");