yhirose 4 years ago
parent
commit
865b0e4c03
2 changed files with 10 additions and 0 deletions
  1. 2 0
      httplib.h
  2. 8 0
      test/test.cc

+ 2 - 0
httplib.h

@@ -1661,6 +1661,8 @@ namespace detail {
 
 
 std::string encode_query_param(const std::string &value);
 std::string encode_query_param(const std::string &value);
 
 
+std::string decode_url(const std::string &s, bool convert_plus_to_space);
+
 void read_file(const std::string &path, std::string &out);
 void read_file(const std::string &path, std::string &out);
 
 
 std::string trim_copy(const std::string &s);
 std::string trim_copy(const std::string &s);

+ 8 - 0
test/test.cc

@@ -58,6 +58,14 @@ TEST(StartupTest, WSAStartup) {
 }
 }
 #endif
 #endif
 
 
+TEST(DecodeURLTest, PercentCharacter) {
+  EXPECT_EQ(
+      detail::decode_url(
+          R"(descrip=Gastos%20%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%B1%C3%91%206)",
+          false),
+      R"(descrip=Gastos áéíóúñÑ 6)");
+}
+
 TEST(EncodeQueryParamTest, ParseUnescapedChararactersTest) {
 TEST(EncodeQueryParamTest, ParseUnescapedChararactersTest) {
   string unescapedCharacters = "-_.!~*'()";
   string unescapedCharacters = "-_.!~*'()";