#include "url.h" std::string urlDecode(std::string s) { std::string result; size_t pos = 0; while (pos < s.size()) { char c {s[pos]}; if (c == '+') { result += ' '; } else if (c == '%' && pos + 2 < s.size()) { try { int i = stoi(s.substr(pos + 1, 2), 0, 16); if (i < 0 || i > 255) return result; result += static_cast(i); } catch (...) { return result; } pos += 2; } else { result += c; } pos++; } return result; }