diff --git a/doc/ref/corelib/uri.md b/doc/ref/corelib/uri.md index 3a005d529..8bb909b29 100644 --- a/doc/ref/corelib/uri.md +++ b/doc/ref/corelib/uri.md @@ -10,6 +10,9 @@ The class `uri` represents a Uniform Resource Identifier (URI) reference. uri(); + uri(const std::string& s); +Constructs a URI by parsing the given string. + uri(const std::string& uri); Constructs a URI by parsing the given string. @@ -20,7 +23,7 @@ Constructs a URI by parsing the given string. jsoncons::string_view path, jsoncons::string_view query, jsoncons::string_view fragment) -Constructs a URI from the given components. +Constructs a URI from the given non-encoded parts. uri(const uri& other); @@ -34,58 +37,59 @@ Constructs a URI from the given components. #### Member functions - bool is_absolute() const noexcept; -Returns true if this URI is absolute, false otherwise. An absolute URI is a URI that has -a scheme part (the part after the colon), e.g. 'https://john.doe@www.example.com'. - - bool is_opaque() const noexcept; -Returns true if this URI is opaque, false otherwise. An opaque URI is an absolute URI whose -scheme-specific part does not begin with a slash character ('/'), e.g. 'mailto:john.doe@example.com'. - - uri base() const noexcept; - - const std::string& string() const; - jsoncons::string_view scheme() const noexcept; - - jsoncons::string_view scheme() const noexcept; - - jsoncons::string_view encoded_scheme() const noexcept; +Returns the scheme part of this URI. The scheme is the first part of the URI, before the : character. std::string userinfo() const; +Returns the decoded userinfo part of this URI. jsoncons::string_view encoded_userinfo() const noexcept; +Returns the encoded userinfo part of this URI. jsoncons::string_view host() const noexcept; - - jsoncons::string_view encoded_host() const noexcept; +Returns the host part of this URI. jsoncons::string_view port() const noexcept; - - jsoncons::string_view encoded_port() const noexcept; +Returns the port number of this URI. std::string authority() const; +Returns the decoded authority part of this URI. jsoncons::string_view encoded_authority() const noexcept; +Returns the encoded authority part of this URI. std::string path() const; +Returns the decoded path part of this URI. jsoncons::string_view encoded_path() const noexcept; +Returns the encoded path part of this URI. std::string query() const; +Returns the decoded query part of this URI. jsoncons::string_view encoded_query() const noexcept; - - std::string query() const; - - jsoncons::string_view encoded_query() const noexcept; +Returns the encoded query part of this URI. std::string fragment() const; +Returns the decoded fragment part of this URI. jsoncons::string_view encoded_fragment() const noexcept; +Returns the encoded fragment part of this URI. + + bool is_absolute() const noexcept; +Returns true if this URI is absolute, false otherwise. An absolute URI is a URI that has +a scheme part (the part after the colon), e.g. 'https://john.doe@www.example.com'. + + bool is_opaque() const noexcept; +Returns true if this URI is opaque, false otherwise. An opaque URI is an absolute URI whose +scheme-specific part does not begin with a slash character ('/'), e.g. 'mailto:john.doe@example.com'. + + uri base() const noexcept; uri resolve(const uri& base) const; + const std::string& string() const; + ### Examples diff --git a/include/jsoncons/utility/uri.hpp b/include/jsoncons/utility/uri.hpp index c9634f64d..83fde41f4 100644 --- a/include/jsoncons/utility/uri.hpp +++ b/include/jsoncons/utility/uri.hpp @@ -321,12 +321,8 @@ namespace jsoncons { string_view host() const noexcept { return string_view(uri_string_.data()+host_.first,(host_.second-host_.first)); } - string_view encoded_host() const noexcept { return string_view(uri_string_.data()+host_.first,(host_.second-host_.first)); } - string_view port() const noexcept { return string_view(uri_string_.data()+port_.first,(port_.second-port_.first)); } - string_view encoded_port() const noexcept { return string_view(uri_string_.data()+port_.first,(port_.second-port_.first)); } - std::string authority() const { return decode_part(encoded_authority()); diff --git a/include/jsoncons_ext/jsonschema/common/schema_builder.hpp b/include/jsoncons_ext/jsonschema/common/schema_builder.hpp index c0b5bc8e0..1413ab799 100644 --- a/include/jsoncons_ext/jsonschema/common/schema_builder.hpp +++ b/include/jsoncons_ext/jsonschema/common/schema_builder.hpp @@ -469,7 +469,7 @@ namespace jsonschema { virtual std::unique_ptr> make_type_validator(const compilation_context& context, const Json& sch, const Json& parent) { - std::string schema_location = context.get_base_uri().string(); + uri schema_location = context.get_base_uri(); std::vector expected_types; switch (sch.type()) diff --git a/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp b/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp index bdfd4c472..8cc1a2fab 100644 --- a/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp +++ b/include/jsoncons_ext/jsonschema/common/uri_wrapper.hpp @@ -115,7 +115,7 @@ namespace jsonschema { if (has_plain_name_fragment()) return *this; - jsoncons::jsonpointer::json_pointer pointer(std::string(uri_.encoded_fragment())); + jsoncons::jsonpointer::json_pointer pointer(std::string(uri_.fragment())); pointer /= field; jsoncons::uri new_uri(uri_, uri_fragment_part, pointer.to_string()); diff --git a/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp b/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp index d8d903671..b406d52e3 100644 --- a/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp +++ b/include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp @@ -329,10 +329,11 @@ namespace draft7 { for (const auto& prop : sch.object_range()) { + std::string sub_keys[] = {"patternProperties", prop.key()}; pattern_properties.emplace_back( std::make_pair( std::regex(prop.key(), std::regex::ECMAScript), - make_schema_validator(context, prop.value(), {}, anchor_dict))); + make_schema_validator(context, prop.value(), sub_keys, anchor_dict))); } return jsoncons::make_unique>(parent, std::move(schema_location), diff --git a/test/corelib/src/utility/uri_tests.cpp b/test/corelib/src/utility/uri_tests.cpp index 2e4eef825..767af5412 100644 --- a/test/corelib/src/utility/uri_tests.cpp +++ b/test/corelib/src/utility/uri_tests.cpp @@ -370,8 +370,8 @@ TEST_CASE("uri parsing tests") jsoncons::uri id = jsoncons::uri::parse(str, ec); /*std::cout << "authority: [" << id.encoded_authority() << "]\n"; - std::cout << "host: [" << id.encoded_host() << "]\n"; - std::cout << "port: [" << id.encoded_port() << "]\n"; + std::cout << "host: [" << id.host() << "]\n"; + std::cout << "port: [" << id.port() << "]\n"; std::cout << "path: [" << id.encoded_path() << "]\n"; */ diff --git a/test/jsonschema/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json b/test/jsonschema/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json index ba83d89e5..c276e6479 100644 --- a/test/jsonschema/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json +++ b/test/jsonschema/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json @@ -95,7 +95,7 @@ } }, "tests": [ - /*{ + { "description": "non recognized members are ignored", "data": { "answer 1": "42" }, "valid": true @@ -114,7 +114,7 @@ "description": "regexes are case sensitive, 2", "data": { "a_X_3": 3 }, "valid": false - }*/ + } ] }, {