mpd/src/util/UriQueryParser.cxx

24 lines
560 B
C++
Raw Normal View History

// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
2019-08-09 16:27:42 +02:00
#include "UriQueryParser.hxx"
#include "IterableSplitString.hxx"
using std::string_view_literals::operator""sv;
std::string_view
UriFindRawQueryParameter(std::string_view query_string, std::string_view name) noexcept
2019-08-09 16:27:42 +02:00
{
for (const std::string_view i : IterableSplitString(query_string, '&')) {
if (i.starts_with(name)) {
if (i.size() == name.size())
return ""sv;
2019-08-09 16:27:42 +02:00
if (i[name.size()] == '=')
return i.substr(name.size() + 1);
2019-08-09 16:27:42 +02:00
}
}
return {};
2019-08-09 16:27:42 +02:00
}