| 210 | } |
| 211 | |
| 212 | bool URL::parse_query(std::map<std::string, std::string> & params) |
| 213 | { |
| 214 | std::vector<std::string_view> tokens; |
| 215 | strsplit(query, tokens, '&'); |
| 216 | |
| 217 | params.clear(); |
| 218 | for (const auto& it : tokens) { |
| 219 | if (!it.length()) // empty |
| 220 | continue; |
| 221 | std::size_t eq = it.find ('='); |
| 222 | if (eq != std::string::npos) { |
| 223 | auto e = std::pair<std::string, std::string>(it.substr(0, eq), it.substr(eq + 1)); |
| 224 | params.insert(e); |
| 225 | } else { |
| 226 | auto e = std::pair<std::string, std::string>(it, ""); |
| 227 | params.insert(e); |
| 228 | } |
| 229 | } |
| 230 | return true; |
| 231 | } |
| 232 | |
| 233 | std::string URL::to_string() { |
| 234 | std::string out = ""; |