Update urn regex to match widely accepted expression

This commit is contained in:
Ray Vincent 2021-08-24 13:51:32 -07:00
parent 653d515d32
commit f787a8a7a7

View File

@ -26,9 +26,7 @@ inline bool isUriAbsolute(const std::string &documentUri)
*/
inline bool isUrn(const std::string &documentUri) {
static const std::regex pattern(
"^((urn)|(URN)):[a-zA-Z0-9]+[-]{0,1}[a-zA-Z0-9]+(:[-a-zA-Z0-9\\\\._~%!"
"$&'()\\/*+,;=]+)+(\\?[-a-zA-Z0-9\\\\._~%!$&'()\\/"
"*+,;:=]+){0,1}(#[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;:=]+){0,1}$");
"^(?i:urn:(?!urn:)([a-z0-9][a-z0-9-]{1,31}):((?:[-a-z0-9()+,.:=@;$_!*'&~\\/]|%[0-9a-f]{2})+)(?:\\?\\+(.*?))?(?:\\?=(.*?))?(?:#(.*?))?)$");
return std::regex_match(documentUri, pattern);
}