Fix up the ParameterParser a bit more

This commit is contained in:
Alex Hultman
2020-10-11 19:56:35 +02:00
parent 1534858928
commit 2989189048
+21 -3
View File
@@ -64,7 +64,10 @@ namespace uWS {
} }
if (op[0] != ';') { if (op[0] != ';') {
return {key, getToken()}; auto value = getToken();
/* Strip ; or if at end, nothing */
getToken();
return {key, value};
} }
return {key, ""}; return {key, ""};
@@ -91,9 +94,23 @@ namespace uWS {
remainingLine.remove_prefix(1); remainingLine.remove_prefix(1);
return op; return op;
} else { } else {
/* This part is not entirely correct */ /* Are we at a quoted string? */
if (remainingLine[0] == '\"') {
/* Remove first quote and start counting */
remainingLine.remove_prefix(1);
auto quote = remainingLine;
int quoteLength = 0;
/* Read the whole alpha word */ /* Read anything until other double quote appears */
while (remainingLine.length() && remainingLine[0] != '\"') {
remainingLine.remove_prefix(1);
quoteLength++;
}
remainingLine.remove_prefix(1);
return quote.substr(0, quoteLength);
} else {
/* Read anything until ; = space or end */
std::string_view token = remainingLine; std::string_view token = remainingLine;
int tokenLength = 0; int tokenLength = 0;
@@ -105,6 +122,7 @@ namespace uWS {
return token.substr(0, tokenLength); return token.substr(0, tokenLength);
} }
} }
}
/* Nothing */ /* Nothing */
return ""; return "";