From eb58d96d77fa062e83a1710dededc17903ce881d Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Thu, 26 Feb 2026 00:31:06 +0100 Subject: [PATCH] Remove duplicate regexes --- src/libneochat/models/actionsmodel.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libneochat/models/actionsmodel.cpp b/src/libneochat/models/actionsmodel.cpp index f96f155aa..cbd4f0238 100644 --- a/src/libneochat/models/actionsmodel.cpp +++ b/src/libneochat/models/actionsmodel.cpp @@ -310,8 +310,7 @@ QList actions{ Action{ u"ignore"_s, [](const QString &text, NeoChatRoom *room, ChatBarCache *) { - static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s); - auto regexMatch = mxidRegex.match(text); + auto regexMatch = TextRegex::mxId.match(text); if (!regexMatch.hasMatch()) { Q_EMIT room->showMessage(MessageType::Error, i18nc("'' does not look like a matrix id.", "'%1' does not look like a matrix id.", text)); return QString(); @@ -332,8 +331,7 @@ QList actions{ Action{ u"unignore"_s, [](const QString &text, NeoChatRoom *room, ChatBarCache *) { - static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s); - auto regexMatch = mxidRegex.match(text); + auto regexMatch = TextRegex::mxId.match(text); if (!regexMatch.hasMatch()) { Q_EMIT room->showMessage(MessageType::Error, i18nc("'' does not look like a matrix id.", "'%1' does not look like a matrix id.", text)); return QString(); @@ -373,8 +371,7 @@ QList actions{ u"ban"_s, [](const QString &text, NeoChatRoom *room, ChatBarCache *) { auto parts = text.split(u" "_s); - static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s); - auto regexMatch = mxidRegex.match(parts[0]); + auto regexMatch = TextRegex::mxId.match(text); if (!regexMatch.hasMatch()) { Q_EMIT room->showMessage(MessageType::Error, i18nc("'' does not look like a matrix id.", "'%1' does not look like a matrix id.", text)); return QString(); @@ -410,8 +407,7 @@ QList actions{ Action{ u"unban"_s, [](const QString &text, NeoChatRoom *room, ChatBarCache *) { - static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s); - auto regexMatch = mxidRegex.match(text); + auto regexMatch = TextRegex::mxId.match(text); if (!regexMatch.hasMatch()) { Q_EMIT room->showMessage(MessageType::Error, i18nc("'' does not look like a matrix id.", "'%1' does not look like a matrix id.", text)); return QString(); @@ -442,8 +438,7 @@ QList actions{ u"kick"_s, [](const QString &text, NeoChatRoom *room, ChatBarCache *) { auto parts = text.split(u" "_s); - static const QRegularExpression mxidRegex(uR"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"_s); - auto regexMatch = mxidRegex.match(parts[0]); + auto regexMatch = TextRegex::mxId.match(text); if (!regexMatch.hasMatch()) { Q_EMIT room->showMessage(MessageType::Error, i18nc("'' does not look like a matrix id.", "'%1' does not look like a matrix id.", parts[0]));