Apply flowln's suggestion

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2023-03-05 18:21:24 +00:00
parent 4efbf22089
commit 76f66148db
2 changed files with 8 additions and 8 deletions

View File

@ -114,11 +114,11 @@ void Download::executeTask()
} }
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8()); request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
// TODO remove duplication and use constant // TODO remove duplication
if (APPLICATION->capabilities() & Application::SupportsFlame if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
&& request.url().host() == "api.curseforge.com") {
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8()); request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
} else if (request.url().host() == "api.modrinth.com") { } else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
QString token = APPLICATION->getModrinthAPIToken(); QString token = APPLICATION->getModrinthAPIToken();
if (!token.isNull()) if (!token.isNull())
request.setRawHeader("Authorization", token.toUtf8()); request.setRawHeader("Authorization", token.toUtf8());

View File

@ -217,11 +217,11 @@ namespace Net {
} }
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8()); request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
// TODO remove duplication and use constant // TODO remove duplication
if (APPLICATION->capabilities() & Application::SupportsFlame if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
&& request.url().host() == "api.curseforge.com") {
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8()); request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
} else if (request.url().host() == "api.modrinth.com") { } else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
QString token = APPLICATION->getModrinthAPIToken(); QString token = APPLICATION->getModrinthAPIToken();
if (!token.isNull()) if (!token.isNull())
request.setRawHeader("Authorization", token.toUtf8()); request.setRawHeader("Authorization", token.toUtf8());