util/MimeType: use std::string_view
This commit is contained in:
parent
0727ee94c0
commit
ca46b4d7a7
@ -29,25 +29,25 @@
|
|||||||
|
|
||||||
#include "MimeType.hxx"
|
#include "MimeType.hxx"
|
||||||
#include "IterableSplitString.hxx"
|
#include "IterableSplitString.hxx"
|
||||||
#include "StringView.hxx"
|
#include "util/StringSplit.hxx"
|
||||||
|
#include "util/StringStrip.hxx"
|
||||||
|
|
||||||
std::string_view
|
std::string_view
|
||||||
GetMimeTypeBase(std::string_view s) noexcept
|
GetMimeTypeBase(std::string_view s) noexcept
|
||||||
{
|
{
|
||||||
return StringView(s).Split(';').first;
|
return Split(s, ';').first;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::string>
|
std::map<std::string, std::string>
|
||||||
ParseMimeTypeParameters(std::string_view mime_type) noexcept
|
ParseMimeTypeParameters(std::string_view mime_type) noexcept
|
||||||
{
|
{
|
||||||
/* discard the first segment (the base MIME type) */
|
/* discard the first segment (the base MIME type) */
|
||||||
const auto params = StringView(mime_type).Split(';').second;
|
const auto params = Split(mime_type, ';').second;
|
||||||
|
|
||||||
std::map<std::string, std::string> result;
|
std::map<std::string, std::string> result;
|
||||||
for (auto i : IterableSplitString(params, ';')) {
|
for (const std::string_view i : IterableSplitString(params, ';')) {
|
||||||
i.Strip();
|
const auto s = Split(Strip(i), '=');
|
||||||
auto s = i.Split('=');
|
if (!s.first.empty() && s.second.data() != nullptr)
|
||||||
if (!s.second.IsNull())
|
|
||||||
result.emplace(s);
|
result.emplace(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user