1 // Copyright (c) 2015-2019 The Bitcoin Core developers 2 // Distributed under the MIT software license, see the accompanying 3 // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 5 #include <util/url.h> 6 7 #include <event2/http.h> 8 #include <stdlib.h> 9 #include <string> 10 urlDecode(const std::string & urlEncoded)11std::string urlDecode(const std::string &urlEncoded) { 12 std::string res; 13 if (!urlEncoded.empty()) { 14 char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr); 15 if (decoded) { 16 res = std::string(decoded); 17 free(decoded); 18 } 19 } 20 return res; 21 } 22