| 82 | } |
| 83 | |
| 84 | std::string UriEncodeHost(std::string_view host) { |
| 85 | // Fairly naive check: if it contains a ':', it's IPv6 and needs |
| 86 | // brackets, else it's OK |
| 87 | if (host.find(":") != std::string::npos) { |
| 88 | std::string result = "["; |
| 89 | result += host; |
| 90 | result += ']'; |
| 91 | return result; |
| 92 | } else { |
| 93 | return std::string(host); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | bool IsValidUriScheme(std::string_view s) { |
| 98 | auto is_alpha = [](char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }; |