Commit d36a4228 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Apply type_filters on normalized type as per comment

The comment said "filter functions applied to objects of the corresponding (already normalized) type" but it didn't.
Probably went unnoticed as we don't actually normalize any of the types that have a specialized filter right now.

Differential Revision: https://phabricator.kde.org/D27598
parent b2496d67
......@@ -264,14 +264,15 @@ static void filterRecursive(QJsonArray &array)
static void filterRecursive(QJsonObject &obj)
{
const auto type = obj.value(QLatin1String("@type")).toString().toUtf8();
auto type = obj.value(QLatin1String("@type")).toString().toUtf8();
// normalize type
const auto it = std::lower_bound(std::begin(type_mapping), std::end(type_mapping), type, [](const auto &lhs, const auto &rhs) {
return std::strcmp(lhs.fromType, rhs.constData()) < 0;
});
if (it != std::end(type_mapping) && std::strcmp((*it).fromType, type.constData()) == 0) {
obj.insert(QStringLiteral("@type"), QLatin1String((*it).toType));
type = it->toType;
obj.insert(QStringLiteral("@type"), QLatin1String(type));
}
for (auto it = obj.begin(); it != obj.end(); ++it) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment