Replace with exact match and add TODO to improve

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2023-03-02 09:26:00 +00:00
parent a7b8092296
commit 1f3d18ec12
2 changed files with 6 additions and 4 deletions

View File

@ -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());

View File

@ -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());