Checks if the (un-well-known) scheme is valid RFC 3986 Section 3.1 These are the valid characters in a scheme: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) return an error if there is another character in the scheme */
| 132 | return an error if there is another character in the scheme |
| 133 | */ |
| 134 | bool |
| 135 | validate_scheme(std::string_view scheme) |
| 136 | { |
| 137 | if (scheme.empty()) { |
| 138 | return false; |
| 139 | } |
| 140 | |
| 141 | if (!ParseRules::is_alpha(scheme[0])) { |
| 142 | return false; |
| 143 | } |
| 144 | |
| 145 | for (size_t i = 0; i < scheme.size(); ++i) { |
| 146 | const char &c = scheme[i]; |
| 147 | |
| 148 | if (!(ParseRules::is_alnum(c) != 0 || c == '+' || c == '-' || c == '.')) { |
| 149 | return false; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | return true; |
| 154 | } |
| 155 | |
| 156 | /*------------------------------------------------------------------------- |
| 157 | -------------------------------------------------------------------------*/ |
no test coverage detected