clean up validateDownloadUrl

This commit is contained in:
Lenny McLennington 2022-05-28 19:54:00 +01:00 committed by flow
parent b5e00027d1
commit abd240468e

View File

@ -42,6 +42,8 @@
#include "minecraft/MinecraftInstance.h" #include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h" #include "minecraft/PackProfile.h"
#include <QSet>
static ModrinthAPI api; static ModrinthAPI api;
namespace Modrinth { namespace Modrinth {
@ -95,17 +97,15 @@ void loadIndexedVersions(Modpack& pack, QJsonDocument& doc)
auto validateDownloadUrl(QUrl url) -> bool auto validateDownloadUrl(QUrl url) -> bool
{ {
auto domain = url.host(); static QSet<QString> domainWhitelist{
if(domain == "cdn.modrinth.com") "cdn.modrinth.com",
return true; "github.com",
if(domain == "github.com") "raw.githubusercontent.com",
return true; "gitlab.com"
if(domain == "raw.githubusercontent.com") };
return true;
if(domain == "gitlab.com")
return true;
return false; auto domain = url.host();
return domainWhitelist.contains(domain);
} }
auto loadIndexedVersion(QJsonObject &obj) -> ModpackVersion auto loadIndexedVersion(QJsonObject &obj) -> ModpackVersion