Line data Source code
1 : // Copyright (c) 2015-2022 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 <common/url.h> 6 : 7 : #include <event2/http.h> 8 : 9 : #include <cstdlib> 10 : #include <string> 11 : 12 0 : std::string urlDecode(const std::string &urlEncoded) { 13 0 : std::string res; 14 0 : if (!urlEncoded.empty()) { 15 0 : char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr); 16 0 : if (decoded) { 17 0 : res = std::string(decoded); 18 0 : free(decoded); 19 0 : } 20 0 : } 21 0 : return res; 22 0 : }