diff --git a/src/QueryParser.h b/src/QueryParser.h index 552bb56..94acc65 100644 --- a/src/QueryParser.h +++ b/src/QueryParser.h @@ -44,7 +44,7 @@ namespace uWS { if (statement.length() && statement[0] == key[0]) { /* Equal sign must be present and not in the end of statement */ auto equality = statement.find('='); - if (equality != std::string_view::npos && equality != statement.length() - 1) { + if (/*equality != std::string_view::npos && equality != statement.length() - 1*/ true) { std::string_view statementKey = statement.substr(0, equality); std::string_view statementValue = statement.substr(equality + 1); diff --git a/tests/Makefile b/tests/Makefile index 79731d3..1883fd9 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,4 +1,6 @@ default: + $(CXX) -std=c++17 -fsanitize=address Query.cpp -o Query + ./Query $(CXX) -std=c++17 -fsanitize=address ChunkedEncoding.cpp -o ChunkedEncoding ./ChunkedEncoding $(CXX) -std=c++17 -fsanitize=address TopicTree.cpp -o TopicTree diff --git a/tests/Query.cpp b/tests/Query.cpp new file mode 100644 index 0000000..3e19574 --- /dev/null +++ b/tests/Query.cpp @@ -0,0 +1,20 @@ +#include +#include + +#include "../src/QueryParser.h" + +int main() { + + { + std::string buf = "?test1=&test2=someValue"; + assert(uWS::getDecodedQueryValue("test2", (char *) buf.data()) == "someValue"); + } + + { + std::string buf = "?test1=&test2=someValue"; + assert(uWS::getDecodedQueryValue("test1", (char *) buf.data()) == ""); + assert(uWS::getDecodedQueryValue("test2", (char *) buf.data()) == "someValue"); + } + + return 0; +} \ No newline at end of file