mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixed regex triggering on everything. (#87)
This commit is contained in:
parent
950a84ec50
commit
a975e15573
1 changed files with 7 additions and 8 deletions
|
@ -10,7 +10,7 @@ MessageBuilder::MessageBuilder()
|
|||
: _words()
|
||||
{
|
||||
_parseTime = std::chrono::system_clock::now();
|
||||
regex.setPattern("(\\bhttps?:\/\/)?[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]");
|
||||
regex.setPattern("[[:ascii:]]*\\.[A-Z]+");
|
||||
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||
}
|
||||
|
||||
|
@ -59,14 +59,13 @@ void MessageBuilder::appendTimestamp(time_t time)
|
|||
|
||||
QString MessageBuilder::matchLink(const QString &string)
|
||||
{
|
||||
QString match = regex
|
||||
.match(string, 0, QRegularExpression::PartialPreferCompleteMatch,
|
||||
QRegularExpression::NoMatchOption)
|
||||
.captured();
|
||||
if (!match.contains(QRegularExpression("\\bhttps?:\/\/"))) {
|
||||
match.insert(0, "https://");
|
||||
auto match = regex.match(string);
|
||||
QString captured = match.captured();
|
||||
|
||||
if (!captured.contains(QRegularExpression("\\bhttps?:\/\/")) && match.hasMatch()) {
|
||||
captured.insert(0, "http://");
|
||||
}
|
||||
return match;
|
||||
return captured;
|
||||
}
|
||||
|
||||
} // namespace messages
|
||||
|
|
Loading…
Reference in a new issue