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