mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
add comment to trim
function, use it correctly and remove redundant whitespace checks in CookieParser
.
This commit is contained in:
parent
d27b5bc1bd
commit
02bbbde8b7
@ -225,17 +225,15 @@ namespace crow
|
||||
if (pos_equal == cookies.npos)
|
||||
break;
|
||||
std::string name = cookies.substr(pos, pos_equal - pos);
|
||||
utility::trim(name);
|
||||
name = utility::trim(name);
|
||||
pos = pos_equal + 1;
|
||||
while (pos < cookies.size() && cookies[pos] == ' ')
|
||||
pos++;
|
||||
if (pos == cookies.size())
|
||||
break;
|
||||
|
||||
size_t pos_semicolon = cookies.find(';', pos);
|
||||
std::string value = cookies.substr(pos, pos_semicolon - pos);
|
||||
|
||||
utility::trim(value);
|
||||
value = utility::trim(value);
|
||||
if (value[0] == '"' && value[value.size() - 1] == '"')
|
||||
{
|
||||
value = value.substr(1, value.size() - 2);
|
||||
@ -247,8 +245,6 @@ namespace crow
|
||||
if (pos == cookies.npos)
|
||||
break;
|
||||
pos++;
|
||||
while (pos < cookies.size() && cookies[pos] == ' ')
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -832,6 +832,9 @@ namespace crow
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/// Return a copy of the given string with its
|
||||
/// leading and trailing whitespaces removed.
|
||||
inline static std::string trim(const std::string& v)
|
||||
{
|
||||
if (v.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user