- resolver |
- A function object with the signature of resolver being equivalent to
+ | resolve |
+ A function object with the signature of resolve being equivalent to
Json fun(const jsoncons::uri& uri)
diff --git a/doc/ref/jsonschema/make_schema.md b/doc/ref/jsonschema/make_schema.md
index 750f82a21..2413c8f9c 100644
--- a/doc/ref/jsonschema/make_schema.md
+++ b/doc/ref/jsonschema/make_schema.md
@@ -10,13 +10,13 @@ template
std::shared_ptr> make_schema(const Json& schema,
const std::string& retrieval_uri); (2) (since 0.173.0)
-template
+template
std::shared_ptr> make_schema(const Json& schema,
- const std::string& retrieval_uri, const URIResolver& resolver); (3) (since 0.173.0)
+ const std::string& retrieval_uri, const ResolveURI& resolver); (3) (since 0.173.0)
-template
+template
std::shared_ptr> make_schema(const Json& schema,
- const URIResolver& resolver); (4)
+ const ResolveURI& resolver); (4)
```
Returns a `shared_ptr` to a `json_schema`.
diff --git a/include/jsoncons/uri.hpp b/include/jsoncons/utility/uri.hpp
similarity index 97%
rename from include/jsoncons/uri.hpp
rename to include/jsoncons/utility/uri.hpp
index 79f662d84..5d903cb23 100644
--- a/include/jsoncons/uri.hpp
+++ b/include/jsoncons/utility/uri.hpp
@@ -4,8 +4,8 @@
// See https://github.com/danielaparker/jsoncons for latest version
-#ifndef JSONCONS_JSONSCHEMA_URI_HPP
-#define JSONCONS_JSONSCHEMA_URI_HPP
+#ifndef JSONCONS_UTILITY_URI_HPP
+#define JSONCONS_UTILITY_URI_HPP
#include // std::string
#include
@@ -16,17 +16,18 @@
#include
#include
-namespace jsoncons {
+namespace jsoncons { namespace utility {
- enum class uri_errc
+ enum class uri_errc
{
success = 0,
invalid_uri = 1,
+ invalid_characters_in_path = 2
};
class uri_error_category_impl
- : public std::error_category
+ : public std::error_category
{
public:
const char* name() const noexcept override
@@ -39,6 +40,8 @@ namespace jsoncons {
{
case uri_errc::invalid_uri:
return "Invalid URI";
+ case uri_errc::invalid_characters_in_path:
+ return "Invalid characters in path";
default:
return "Unknown uri error";
}
@@ -46,27 +49,29 @@ namespace jsoncons {
};
inline
- const std::error_category& uri_error_category()
+ const std::error_category& uri_error_category()
{
- static uri_error_category_impl instance;
- return instance;
+ static uri_error_category_impl instance;
+ return instance;
}
-
- inline
- std::error_code make_error_code(uri_errc result)
+
+ inline
+ std::error_code make_error_code(uri_errc result)
{
- return std::error_code(static_cast(result),uri_error_category());
+ return std::error_code(static_cast(result), uri_error_category());
}
-}
+
+} // namespace utility
+} // namespace jsoncons
namespace std {
template<>
- struct is_error_code_enum : public true_type
+ struct is_error_code_enum : public true_type
{
};
-}
+} // namespace std
-namespace jsoncons {
+namespace jsoncons { namespace utility {
struct uri_fragment_part_t
{
@@ -687,9 +692,9 @@ namespace jsoncons {
default:
if (!(is_pchar(c,s.data()+i, s.size() - i) || c == '/'))
{
- ec = uri_errc::invalid_uri;
+ ec = uri_errc::invalid_characters_in_path;
return uri{};
- }
+ }
break;
}
break;
@@ -808,10 +813,11 @@ namespace jsoncons {
static std::string merge_paths(const uri& base, const uri& relative)
{
std::string result;
-
- if (base.encoded_path().empty())
+
+ if (!base.encoded_authority().empty() && base.encoded_path().empty())
{
result = "/";
+ result.append(relative.encoded_path().data(), relative.encoded_path().length());
}
else
{
@@ -1146,6 +1152,10 @@ namespace jsoncons {
}
};
+} // namespace utility
+
+using uri = utility::uri;
+
} // namespace jsoncons
#endif
diff --git a/include/jsoncons_ext/jsonschema/common/compilation_context.hpp b/include/jsoncons_ext/jsonschema/common/compilation_context.hpp
index d31c45f17..d60c3b2f4 100644
--- a/include/jsoncons_ext/jsonschema/common/compilation_context.hpp
+++ b/include/jsoncons_ext/jsonschema/common/compilation_context.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_COMMON_COMPILATION_CONTEXT_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/common/evaluation_context.hpp b/include/jsoncons_ext/jsonschema/common/evaluation_context.hpp
index 9b678ff76..5ba0061db 100644
--- a/include/jsoncons_ext/jsonschema/common/evaluation_context.hpp
+++ b/include/jsoncons_ext/jsonschema/common/evaluation_context.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_COMMON_EVALUATION_CONTEXT_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/common/format_validator.hpp b/include/jsoncons_ext/jsonschema/common/format_validator.hpp
index d103c6304..ba922ff88 100644
--- a/include/jsoncons_ext/jsonschema/common/format_validator.hpp
+++ b/include/jsoncons_ext/jsonschema/common/format_validator.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_COMMON_FORMAT_VALIDATOR_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp b/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp
index 0b5069223..b48ebe0d0 100644
--- a/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp
+++ b/include/jsoncons_ext/jsonschema/common/keyword_validators.hpp
@@ -9,7 +9,7 @@
#define JSONCONS_JSONSCHEMA_COMMON_KEYWORD_VALIDATORS_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/common/schema_validators.hpp b/include/jsoncons_ext/jsonschema/common/schema_validators.hpp
index 608193ed0..c021d49e0 100644
--- a/include/jsoncons_ext/jsonschema/common/schema_validators.hpp
+++ b/include/jsoncons_ext/jsonschema/common/schema_validators.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_COMMON_SCHEMA_VALIDATORS_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp b/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp
index 8816814dd..e61108058 100644
--- a/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp
+++ b/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_COMMON_SCHEMA_IDENTIFIER_HPP
#include
-#include
+#include
#include
#include
#include
@@ -118,7 +118,7 @@ namespace jsonschema {
jsoncons::jsonpointer::json_pointer pointer(std::string(uri_.encoded_fragment()));
pointer /= field;
- jsoncons::uri new_uri(uri_, uri_fragment_part, pointer.to_string());
+ jsoncons::uri new_uri(uri_, utility::uri_fragment_part, pointer.to_string());
return uri_wrapper(std::move(new_uri));
}
@@ -131,7 +131,7 @@ namespace jsonschema {
jsoncons::jsonpointer::json_pointer pointer(std::string(uri_.encoded_fragment()));
pointer /= index;
- jsoncons::uri new_uri(uri_, uri_fragment_part, pointer.to_string());
+ jsoncons::uri new_uri(uri_, utility::uri_fragment_part, pointer.to_string());
return uri_wrapper(std::move(new_uri));
}
diff --git a/include/jsoncons_ext/jsonschema/common/validator.hpp b/include/jsoncons_ext/jsonschema/common/validator.hpp
index 7a9a8464a..075094465 100644
--- a/include/jsoncons_ext/jsonschema/common/validator.hpp
+++ b/include/jsoncons_ext/jsonschema/common/validator.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_COMMON_VALIDATOR_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp b/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp
index fb53086b6..67dc9b0cf 100644
--- a/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp
+++ b/include/jsoncons_ext/jsonschema/draft201909/schema_builder_201909.hpp
@@ -7,7 +7,7 @@
#ifndef JSONCONS_JSONSCHEMA_DRAFT201909_SCHEMA_BUILDER_201909_HPP
#define JSONCONS_JSONSCHEMA_DRAFT201909_SCHEMA_BUILDER_201909_HPP
-#include
+#include
#include
#include
#include
@@ -524,7 +524,7 @@ namespace draft201909 {
JSONCONS_THROW(schema_error("Invalid $anchor " + anchor));
}
auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::uri{"#"};
- jsoncons::uri new_uri(uri, uri_fragment_part, anchor);
+ jsoncons::uri new_uri(uri, utility::uri_fragment_part, anchor);
uri_wrapper identifier{ new_uri };
if (std::find(new_uris.begin(), new_uris.end(), identifier) == new_uris.end())
{
diff --git a/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp b/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp
index 292413164..c0a653849 100644
--- a/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp
+++ b/include/jsoncons_ext/jsonschema/draft202012/schema_builder_202012.hpp
@@ -7,7 +7,7 @@
#ifndef JSONCONS_JSONSCHEMA_DRAFT202012_SCHEMA_BUILDER_202012_HPP
#define JSONCONS_JSONSCHEMA_DRAFT202012_SCHEMA_BUILDER_202012_HPP
-#include
+#include
#include
#include
#include
@@ -252,7 +252,7 @@ namespace draft202012 {
if (it != sch.object_range().end())
{
std::string value = it->value().template as();
- jsoncons::uri new_uri(context.get_base_uri(), uri_fragment_part, value);
+ jsoncons::uri new_uri(context.get_base_uri(), utility::uri_fragment_part, value);
dynamic_anchor = jsoncons::optional(new_uri);
local_anchor_dict.emplace(value, context.get_base_uri());
}
@@ -579,7 +579,7 @@ namespace draft202012 {
JSONCONS_THROW(schema_error("Invalid $anchor " + anchor));
}
auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::uri{"#"};
- jsoncons::uri new_uri(uri, uri_fragment_part, anchor);
+ jsoncons::uri new_uri(uri, utility::uri_fragment_part, anchor);
uri_wrapper identifier{ new_uri };
if (std::find(new_uris.begin(), new_uris.end(), identifier) == new_uris.end())
{
@@ -595,7 +595,7 @@ namespace draft202012 {
JSONCONS_THROW(schema_error("Invalid $dynamicAnchor " + anchor));
}
auto uri = !new_uris.empty() ? new_uris.back().uri() : jsoncons::uri{"#"};
- jsoncons::uri new_uri(uri, uri_fragment_part, anchor);
+ jsoncons::uri new_uri(uri, utility::uri_fragment_part, anchor);
uri_wrapper identifier{ new_uri };
if (std::find(new_uris.begin(), new_uris.end(), identifier) == new_uris.end())
{
diff --git a/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp b/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp
index 04d874e7b..2914cde57 100644
--- a/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp
+++ b/include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp
@@ -7,7 +7,7 @@
#ifndef JSONCONS_JSONSCHEMA_DRAFT4_SCHEMA_BUILDER_4_HPP
#define JSONCONS_JSONSCHEMA_DRAFT4_SCHEMA_BUILDER_4_HPP
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp b/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp
index 258625f11..f0a09e74b 100644
--- a/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp
+++ b/include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp
@@ -7,7 +7,7 @@
#ifndef JSONCONS_JSONSCHEMA_DRAFT6_SCHEMA_BUILDER_6_HPP
#define JSONCONS_JSONSCHEMA_DRAFT6_SCHEMA_BUILDER_6_HPP
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp b/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp
index edb899565..00387cecc 100644
--- a/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp
+++ b/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp
@@ -7,7 +7,7 @@
#ifndef JSONCONS_JSONSCHEMA_DRAFT7_SCHEMA_BUILDER_7_HPP
#define JSONCONS_JSONSCHEMA_DRAFT7_SCHEMA_BUILDER_7_HPP
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/json_schema_factory.hpp b/include/jsoncons_ext/jsonschema/json_schema_factory.hpp
index 5ad0e6021..5ebc75478 100644
--- a/include/jsoncons_ext/jsonschema/json_schema_factory.hpp
+++ b/include/jsoncons_ext/jsonschema/json_schema_factory.hpp
@@ -206,9 +206,9 @@ namespace jsonschema {
}
}
- template
- typename std::enable_if::value,json_schema>::type
- make_json_schema(Json sch, const std::string& retrieval_uri, const URIResolver& resolver,
+ template
+ typename std::enable_if::value,json_schema>::type
+ make_json_schema(Json sch, const std::string& retrieval_uri, const ResolveURI& resolve,
evaluation_options options = evaluation_options{})
{
using schema_store_type = std::map*>;
@@ -216,7 +216,7 @@ namespace jsonschema {
schema_builder_factory builder_factory{};
std::unordered_map vocabulary{};
- std::vector> resolvers = {{meta_resolver, resolver}};
+ std::vector> resolvers = {{meta_resolver, resolve}};
auto schema_builder = builder_factory(std::move(sch), options, &schema_store, resolvers, vocabulary);
schema_builder->build_schema(retrieval_uri);
@@ -239,9 +239,9 @@ namespace jsonschema {
return json_schema(schema_builder->get_schema_validator());
}
- template
- typename std::enable_if::value,json_schema>::type
- make_json_schema(Json sch, const URIResolver& resolver,
+ template
+ typename std::enable_if::value,json_schema>::type
+ make_json_schema(Json sch, const ResolveURI& resolve,
evaluation_options options = evaluation_options{})
{
using schema_store_type = std::map*>;
@@ -249,7 +249,7 @@ namespace jsonschema {
schema_builder_factory builder_factory{};
std::unordered_map vocabulary{};
- std::vector> resolvers = {{meta_resolver, resolver}};
+ std::vector> resolvers = {{meta_resolver, resolve}};
auto schema_builder = builder_factory(std::move(sch), options, &schema_store, resolvers, vocabulary);
schema_builder->build_schema();
@@ -275,16 +275,16 @@ namespace jsonschema {
#if !defined(JSONCONS_NO_DEPRECATED)
// Legacy
- template
- typename std::enable_if::value,std::shared_ptr>>::type
- make_schema(Json sch, const std::string& retrieval_uri, const URIResolver& resolver)
+ template
+ typename std::enable_if::value,std::shared_ptr>>::type
+ make_schema(Json sch, const std::string& retrieval_uri, const ResolveURI& resolve)
{
using schema_store_type = std::map*>;
schema_store_type schema_store;
schema_builder_factory builder_factory{};
std::unordered_map vocabulary{};
- std::vector> resolvers = {{meta_resolver, resolver}};
+ std::vector> resolvers = {{meta_resolver, resolve}};
auto schema_builder = builder_factory(std::move(sch),
jsonschema::evaluation_options{}.default_version(jsonschema::schema_version::draft7()),
&schema_store, resolvers, vocabulary);
@@ -310,16 +310,16 @@ namespace jsonschema {
return std::make_shared>(schema_builder->get_schema_validator());
}
- template
- typename std::enable_if::value,std::shared_ptr>>::type
- make_schema(Json sch, const URIResolver& resolver)
+ template
+ typename std::enable_if::value,std::shared_ptr>>::type
+ make_schema(Json sch, const ResolveURI& resolve)
{
using schema_store_type = std::map*>;
schema_store_type schema_store;
schema_builder_factory builder_factory{};
std::unordered_map vocabulary{};
- std::vector> resolvers = {{meta_resolver, resolver}};
+ std::vector> resolvers = {{meta_resolver, resolve}};
auto schema_builder = builder_factory(std::move(sch),
jsonschema::evaluation_options{}.default_version(jsonschema::schema_version::draft7()),
&schema_store, resolvers, vocabulary);
diff --git a/include/jsoncons_ext/jsonschema/json_validator.hpp b/include/jsoncons_ext/jsonschema/json_validator.hpp
index f9a902ea9..6cb3d880e 100644
--- a/include/jsoncons_ext/jsonschema/json_validator.hpp
+++ b/include/jsoncons_ext/jsonschema/json_validator.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_JSON_VALIDATOR_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/include/jsoncons_ext/jsonschema/validation_message.hpp b/include/jsoncons_ext/jsonschema/validation_message.hpp
index dbdb1ccad..df5449b00 100644
--- a/include/jsoncons_ext/jsonschema/validation_message.hpp
+++ b/include/jsoncons_ext/jsonschema/validation_message.hpp
@@ -8,7 +8,7 @@
#define JSONCONS_JSONSCHEMA_VALIDATION_MESSAGE_HPP
#include
-#include
+#include
#include
#include
#include
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 730e9234c..2143b496f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -128,6 +128,7 @@ add_executable(unit_tests
corelib/src/detail/span_tests.cpp
corelib/src/detail/string_view_tests.cpp
corelib/src/utility/heap_string_tests.cpp
+ corelib/src/utility/uri_tests.cpp
corelib/src/detail/to_integer_tests.cpp
corelib/src/double_round_trip_tests.cpp
corelib/src/double_to_string_tests.cpp
@@ -171,7 +172,6 @@ add_executable(unit_tests
corelib/src/json_type_traits_chrono_tests.cpp
corelib/src/json_type_traits_container_tests.cpp
corelib/src/json_type_traits_tests.cpp
- corelib/src/uri_tests.cpp
corelib/src/json_validation_tests.cpp
corelib/src/jsoncons_tests.cpp
corelib/src/JSONTestSuite_tests.cpp
diff --git a/test/corelib/src/uri_tests.cpp b/test/corelib/src/utility/uri_tests.cpp
similarity index 74%
rename from test/corelib/src/uri_tests.cpp
rename to test/corelib/src/utility/uri_tests.cpp
index ec9bdaa89..358a1d20d 100644
--- a/test/corelib/src/uri_tests.cpp
+++ b/test/corelib/src/utility/uri_tests.cpp
@@ -1,11 +1,10 @@
// Copyright 2013-2024 Daniel Parker
// Distributed under Boost license
-#include
+#include
#include
#include
-//#if 0
TEST_CASE("uri tests (https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)")
{
SECTION("https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top")
@@ -323,14 +322,14 @@ TEST_CASE("uri constructors")
{
jsoncons::uri x{"http://localhost:4242/draft2019-09/recursiveRef6/base.json"};
- jsoncons::uri y{ x, jsoncons::uri_fragment_part, "/anyOf" };
+ jsoncons::uri y{ x, jsoncons::utility::uri_fragment_part, "/anyOf" };
jsoncons::uri expected{"http://localhost:4242/draft2019-09/recursiveRef6/base.json#/anyOf"};
CHECK(expected == y);
}
}
-//#endif
+
TEST_CASE("uri parsing tests")
{
@@ -351,3 +350,119 @@ TEST_CASE("uri parsing tests")
}
}
+TEST_CASE("cpp-netlib uri tests")
+{
+ SECTION("test_empty_path")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56", ec);
+ REQUIRE_FALSE(ec);
+ CHECK(uri.encoded_path().empty());
+ }
+ SECTION("test_empty_path_with_query")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56?query", ec);
+ REQUIRE_FALSE(ec);
+ CHECK(uri.encoded_path().empty());
+ }
+ SECTION("test_empty_path_with_fragment")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56#fragment", ec);
+ REQUIRE_FALSE(ec);
+ CHECK(uri.encoded_path().empty());
+ }
+ SECTION("test_single_slash")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56/", ec);
+ REQUIRE_FALSE(ec);
+ CHECK("/" == uri.encoded_path());
+ }
+ SECTION("test_single_slash_with_query")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56/?query", ec);
+ REQUIRE_FALSE(ec);
+ CHECK("/" == uri.encoded_path());
+ }
+ SECTION("test_single_slash_with_fragment")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("http://123.34.23.56/#fragment", ec);
+ REQUIRE_FALSE(ec);
+ CHECK("/" == uri.encoded_path());
+ }
+ SECTION("test_double_slash_empty_path_empty_everything")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("file://", ec);
+ REQUIRE(ec == jsoncons::utility::uri_errc::invalid_uri);
+ CHECK(uri.encoded_path().empty());
+ }
+ SECTION("test_triple_slash_empty_everything")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("file:///", ec);
+ REQUIRE_FALSE(ec);
+ CHECK("/" == uri.encoded_path());
+ }
+ SECTION("test_triple_slash_with_path_name")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("file:///path", ec);
+ REQUIRE_FALSE(ec);
+ CHECK("/path" == uri.encoded_path());
+ }
+ SECTION("test_rootless_1")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:john.doe@example.com", ec);
+ REQUIRE_FALSE(ec);
+ CHECK("john.doe@example.com" == uri.encoded_path());
+ }
+ SECTION("test_invalid_characters_in_path")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:jo%hn.doe@example.com", ec);
+ REQUIRE(ec);
+ REQUIRE(jsoncons::utility::uri_errc::invalid_characters_in_path == ec);
+ //std::cout << ec.message() << "\n";
+ }
+ SECTION("test_invalid_percent_encoded_characters_in_path_1")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:john.doe@example%G0.com", ec);
+ REQUIRE(ec);
+ REQUIRE(jsoncons::utility::uri_errc::invalid_characters_in_path == ec);
+ //std::cout << ec.message() << "\n";
+ }
+ SECTION("test_invalid_percent_encoded_characters_in_path_2")
+ {
+ std::error_code ec;
+ jsoncons::utility::uri uri = jsoncons::utility::uri::parse("mailto:john.doe@example%0G.com", ec);
+ REQUIRE(ec);
+ REQUIRE(jsoncons::utility::uri_errc::invalid_characters_in_path == ec);
+ //std::cout << ec.message() << "\n";
+ }
+}
+
+TEST_CASE("test uri resolve")
+{
+ SECTION("empty base-1")
+ {
+ std::string str = "./other.schema.json";
+ jsoncons::utility::uri uri{str};
+ auto uri2 = uri.resolve(jsoncons::utility::uri{ "" });
+ CHECK(str == uri2.string());
+ }
+ SECTION("empty base-2")
+ {
+ std::string str = "../../../../dir2/foo/bar/baz/main.schema.json";
+ jsoncons::utility::uri uri{str};
+ auto uri2 = uri.resolve(jsoncons::utility::uri{ "" });
+ CHECK(str == uri2.string());
+ }
+}
+
diff --git a/test/jsonschema/src/validation_report_tests.cpp b/test/jsonschema/src/validation_report_tests.cpp
index acce516f2..0b1d0df2c 100644
--- a/test/jsonschema/src/validation_report_tests.cpp
+++ b/test/jsonschema/src/validation_report_tests.cpp
@@ -628,14 +628,14 @@ TEST_CASE("jsonschema more output tests 3")
{
"valid": false,
"evaluationPath": "/additionalProperties/baz",
- "schemaLocation": "/example-schema#/additionalProperties",
+ "schemaLocation": "example-schema#/additionalProperties",
"instanceLocation": "/baz",
"error": "Additional property 'baz' not allowed by schema."
},
{
"valid": false,
"evaluationPath": "/required",
- "schemaLocation": "/example-schema#/required",
+ "schemaLocation": "example-schema#/required",
"instanceLocation": "",
"error": "Required property 'foo' not found."
}
|