aboutsummaryrefslogtreecommitdiff
path: root/src/common/url.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/url.cpp')
-rw-r--r--src/common/url.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/url.cpp b/src/common/url.cpp
new file mode 100644
index 0000000000..5200d55096
--- /dev/null
+++ b/src/common/url.cpp
@@ -0,0 +1,22 @@
+// Copyright (c) 2015-2019 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <common/url.h>
+
+#include <event2/http.h>
+
+#include <cstdlib>
+#include <string>
+
+std::string urlDecode(const std::string &urlEncoded) {
+ std::string res;
+ if (!urlEncoded.empty()) {
+ char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr);
+ if (decoded) {
+ res = std::string(decoded);
+ free(decoded);
+ }
+ }
+ return res;
+}