diff --git a/src/string-format-check.cpp b/src/string-format-check.cpp index 448ae45..f43a692 100644 --- a/src/string-format-check.cpp +++ b/src/string-format-check.cpp @@ -213,6 +213,8 @@ void default_string_format_check(const std::string &format, const std::string &v rfc3339_date_check(value); } else if (format == "time") { rfc3339_time_check(value); + } else if (format == "uri") { + rfc3986_uri_check(value); } else if (format == "email") { if (!is_ascii(value)) { throw std::invalid_argument(value + " contains non-ASCII values, not RFC 5321 compliant."); diff --git a/test/JSON-Schema-Test-Suite/CMakeLists.txt b/test/JSON-Schema-Test-Suite/CMakeLists.txt index 3c02af9..3d93b55 100644 --- a/test/JSON-Schema-Test-Suite/CMakeLists.txt +++ b/test/JSON-Schema-Test-Suite/CMakeLists.txt @@ -61,7 +61,6 @@ if(JSON_SCHEMA_TEST_SUITE_PATH) JSON-Suite::Optional::Format::relative-json-pointer JSON-Suite::Optional::Format::uri-reference JSON-Suite::Optional::Format::uri-template - JSON-Suite::Optional::Format::uri JSON-Suite::Optional::unicode PROPERTIES diff --git a/test/string-format-check-test.cpp b/test/string-format-check-test.cpp index 2a5fb88..4a207b1 100644 --- a/test/string-format-check-test.cpp +++ b/test/string-format-check-test.cpp @@ -82,5 +82,21 @@ int main() numberOfErrors += testStringFormat("ipv4", ipv4Checks); + const std::vector> uriChecks{ + {"http://www.google.com/search?q=regular%20expression", true}, + {"http://www.google.com/", true}, + {"http://www.google.com/search?q=regular%20expression", true}, + {"www.google.com", false}, + {"http://www.google.comj", true}, + {"ldap://[2001:db8::7]/c=GB?objectClass?one", true}, + {"mailto:John.Doe@example.com", true}, + {"news:comp.infosystems.www.servers.unix", true}, + {"https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top", true}, + {"tel:+1-816-555-1212", true}, + {"telnet://192.0.2.16:80/", true}, + {"urn:oasis:names:specification:docbook:dtd:xml:4.1.2", true}}; + + numberOfErrors += testStringFormat("uri", uriChecks); + return numberOfErrors; }