From 1f3d18ec12bb7a971962101570cbad8e18788614 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 2 Mar 2023 09:26:00 +0000 Subject: [PATCH] Replace with exact match and add TODO to improve Signed-off-by: TheKodeToad --- launcher/net/Download.cpp | 5 +++-- launcher/net/Upload.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp index 0816e926..adb3d6fa 100644 --- a/launcher/net/Download.cpp +++ b/launcher/net/Download.cpp @@ -114,10 +114,11 @@ void Download::executeTask() } request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8()); + // TODO remove duplication and use constant if (APPLICATION->capabilities() & Application::SupportsFlame - && request.url().host().contains("api.curseforge.com")) { + && request.url().host() == "api.curseforge.com") { request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8()); - } else if (request.url().host().contains("api.modrinth.com")) { + } else if (request.url().host() == "api.modrinth.com") { QString token = APPLICATION->getModrinthAPIToken(); if (!token.isNull()) request.setRawHeader("Authorization", token.toUtf8()); diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp index 36d50c1e..cd0de945 100644 --- a/launcher/net/Upload.cpp +++ b/launcher/net/Upload.cpp @@ -217,10 +217,11 @@ namespace Net { } request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8()); + // TODO remove duplication and use constant if (APPLICATION->capabilities() & Application::SupportsFlame - && request.url().host().contains("api.curseforge.com")) { + && request.url().host() == "api.curseforge.com") { request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8()); - } else if (request.url().host().contains("api.modrinth.com")) { + } else if (request.url().host() == "api.modrinth.com") { QString token = APPLICATION->getModrinthAPIToken(); if (!token.isNull()) request.setRawHeader("Authorization", token.toUtf8());