aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/ModPage.cpp
diff options
context:
space:
mode:
authorTheKodeToad <TheKodeToad@proton.me>2022-11-10 11:14:58 +0000
committerTheKodeToad <TheKodeToad@proton.me>2022-11-10 11:14:58 +0000
commit99ed0b6c2ca67733a574a13cd215ec5c46c4dcfa (patch)
tree00c1bac09761766585bcad60d0989a14bfa7d26e /launcher/ui/pages/modplatform/ModPage.cpp
parent16e3b786fc04ffd8d510bfb2a60157648825954f (diff)
downloadPrismLauncher-99ed0b6c2ca67733a574a13cd215ec5c46c4dcfa.tar.gz
PrismLauncher-99ed0b6c2ca67733a574a13cd215ec5c46c4dcfa.tar.bz2
PrismLauncher-99ed0b6c2ca67733a574a13cd215ec5c46c4dcfa.zip
Implement flowln's suggestions
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher/ui/pages/modplatform/ModPage.cpp')
-rw-r--r--launcher/ui/pages/modplatform/ModPage.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp
index 2f5f95bf..234f9f36 100644
--- a/launcher/ui/pages/modplatform/ModPage.cpp
+++ b/launcher/ui/pages/modplatform/ModPage.cpp
@@ -40,10 +40,10 @@
#include <QDesktopServices>
#include <QKeyEvent>
+#include <QRegularExpression>
#include <memory>
#include <HoeDown.h>
-#include <qregularexpression.h>
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
@@ -246,6 +246,10 @@ void ModPage::onModSelected()
ui->packView->adjustSize();
}
+static const QRegularExpression modrinth(QRegularExpression::anchoredPattern("(?:www\\.)?modrinth\\.com\\/mod\\/([^\\/]+)\\/?"));
+static const QRegularExpression curseForge(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/mc-mods\\/([^\\/]+)\\/?"));
+static const QRegularExpression curseForgeOld(QRegularExpression::anchoredPattern("minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)\\/?"));
+
void ModPage::openUrl(const QUrl& url)
{
// do not allow other url schemes for security reasons
@@ -255,19 +259,22 @@ void ModPage::openUrl(const QUrl& url)
}
// detect mod URLs and search instead
- static const QRegularExpression modrinth(QRegularExpression::anchoredPattern("(?:www\\.)?modrinth\\.com\\/mod\\/([^\\/]+)\\/?")),
- curseForge(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/mc-mods\\/([^\\/]+)\\/?")),
- curseForgeOld(QRegularExpression::anchoredPattern("minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)\\/?"));
const QString address = url.host() + url.path();
QRegularExpressionMatch match;
const char* page;
- if ((match = modrinth.match(address)).hasMatch())
+ match = modrinth.match(address);
+ if (match.hasMatch())
page = "modrinth";
- else if (APPLICATION->capabilities() & Application::SupportsFlame &&
- ((match = curseForge.match(address)).hasMatch() || (match = curseForgeOld.match(address)).hasMatch()))
- page = "curseforge";
+ else if (APPLICATION->capabilities() & Application::SupportsFlame) {
+ match = curseForge.match(address);
+ if (!match.hasMatch())
+ match = curseForgeOld.match(address);
+
+ if (match.hasMatch())
+ page = "curseforge";
+ }
if (match.hasMatch()) {
const QString slug = match.captured(1);