From 57b2b18bae02691f91114d6290a4cec9947ce28f Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Sun, 1 Dec 2024 12:33:53 -0500 Subject: [PATCH] 0.179.0 -> 1.0.0 --- include/jsoncons/utility/uri.hpp | 2 +- test/corelib/src/utility/uri_tests.cpp | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/jsoncons/utility/uri.hpp b/include/jsoncons/utility/uri.hpp index 5d903cb239..4953b6f40d 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 358a1d20d1..c584e6821d 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");