| 2147 | } |
| 2148 | |
| 2149 | inline std::string encode_query_param(const std::string &value) { |
| 2150 | std::ostringstream escaped; |
| 2151 | escaped.fill('0'); |
| 2152 | escaped << std::hex; |
| 2153 | |
| 2154 | for (auto c : value) { |
| 2155 | if (std::isalnum(static_cast<uint8_t>(c)) || c == '-' || c == '_' || |
| 2156 | c == '.' || c == '!' || c == '~' || c == '*' || c == '\'' || c == '(' || |
| 2157 | c == ')') { |
| 2158 | escaped << c; |
| 2159 | } else { |
| 2160 | escaped << std::uppercase; |
| 2161 | escaped << '%' << std::setw(2) |
| 2162 | << static_cast<int>(static_cast<unsigned char>(c)); |
| 2163 | escaped << std::nouppercase; |
| 2164 | } |
| 2165 | } |
| 2166 | |
| 2167 | return escaped.str(); |
| 2168 | } |
| 2169 | |
| 2170 | inline std::string encode_url(const std::string &s) { |
| 2171 | std::string result; |
no outgoing calls
no test coverage detected