Check for empty slug before setting pack url

This commit is contained in:
Harry Peach 2022-04-03 23:06:44 +01:00
parent 8f61633551
commit bd8b61651a
No known key found for this signature in database
GPG Key ID: 5A24B165D56227F3

View File

@ -12,7 +12,13 @@ void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
{ {
pack.addonId = Json::requireString(obj, "project_id"); pack.addonId = Json::requireString(obj, "project_id");
pack.name = Json::requireString(obj, "title"); pack.name = Json::requireString(obj, "title");
pack.websiteUrl = "https://modrinth.com/mod/" + Json::ensureString(obj, "slug", "");
QString slug = Json::ensureString(obj, "slug", "");
if (!slug.isEmpty())
pack.websiteUrl = "https://modrinth.com/mod/" + Json::ensureString(obj, "slug", "");
else
pack.websiteUrl = "";
pack.description = Json::ensureString(obj, "description", ""); pack.description = Json::ensureString(obj, "description", "");
pack.logoUrl = Json::requireString(obj, "icon_url"); pack.logoUrl = Json::requireString(obj, "icon_url");