2023-03-06 14:42:04 +01:00
|
|
|
// 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"
|
|
|
|
|
2022-07-01 11:08:20 +02:00
|
|
|
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
|
|
|
{
|
2022-07-01 11:08:20 +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
|
|
|
|
2022-07-01 11:08:20 +02:00
|
|
|
if (i[name.size()] == '=')
|
|
|
|
return i.substr(name.size() + 1);
|
2019-08-09 16:27:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-01 11:08:20 +02:00
|
|
|
return {};
|
2019-08-09 16:27:42 +02:00
|
|
|
}
|