Apply suggestions

This commit is contained in:
timoreo
2022-05-20 22:06:36 +02:00
parent 30b56dbcbd
commit 6542f5f15a
2 changed files with 40 additions and 34 deletions

View File

@ -82,12 +82,13 @@ bool Flame::File::parseFromBytes(const QByteArray& bytes)
// this is probably a mod, dunno what else could modpacks download
targetFolder = "mods";
}
if(!obj.contains("downloadUrl") || obj["downloadUrl"].isNull() || !obj["downloadUrl"].isString() || obj["downloadUrl"].toString().isEmpty()){
QString rawUrl = Json::ensureString(obj, "downloadUrl");
if(rawUrl.isEmpty()){
//either there somehow is an emtpy string as a link, or it's null either way it's invalid
//soft failing
return false;
}
QString rawUrl = Json::requireString(obj, "downloadUrl");
url = QUrl(rawUrl, QUrl::TolerantMode);
if (!url.isValid()) {
throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl));