Implement flowln's suggestions
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
16e3b786fc
commit
99ed0b6c2c
@ -40,10 +40,10 @@
|
|||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <HoeDown.h>
|
#include <HoeDown.h>
|
||||||
#include <qregularexpression.h>
|
|
||||||
|
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
@ -246,6 +246,10 @@ void ModPage::onModSelected()
|
|||||||
ui->packView->adjustSize();
|
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)
|
void ModPage::openUrl(const QUrl& url)
|
||||||
{
|
{
|
||||||
// do not allow other url schemes for security reasons
|
// 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
|
// 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();
|
const QString address = url.host() + url.path();
|
||||||
QRegularExpressionMatch match;
|
QRegularExpressionMatch match;
|
||||||
const char* page;
|
const char* page;
|
||||||
|
|
||||||
if ((match = modrinth.match(address)).hasMatch())
|
match = modrinth.match(address);
|
||||||
|
if (match.hasMatch())
|
||||||
page = "modrinth";
|
page = "modrinth";
|
||||||
else if (APPLICATION->capabilities() & Application::SupportsFlame &&
|
else if (APPLICATION->capabilities() & Application::SupportsFlame) {
|
||||||
((match = curseForge.match(address)).hasMatch() || (match = curseForgeOld.match(address)).hasMatch()))
|
match = curseForge.match(address);
|
||||||
|
if (!match.hasMatch())
|
||||||
|
match = curseForgeOld.match(address);
|
||||||
|
|
||||||
|
if (match.hasMatch())
|
||||||
page = "curseforge";
|
page = "curseforge";
|
||||||
|
}
|
||||||
|
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
const QString slug = match.captured(1);
|
const QString slug = match.captured(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user