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()
|
: _words()
|
||||||
{
|
{
|
||||||
_parseTime = std::chrono::system_clock::now();
|
_parseTime = std::chrono::system_clock::now();
|
||||||
regex.setPattern("(\\bhttps?:\/\/)?[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]");
|
regex.setPattern("[[:ascii:]]*\\.[A-Z]+");
|
||||||
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,14 +59,13 @@ void MessageBuilder::appendTimestamp(time_t time)
|
||||||
|
|
||||||
QString MessageBuilder::matchLink(const QString &string)
|
QString MessageBuilder::matchLink(const QString &string)
|
||||||
{
|
{
|
||||||
QString match = regex
|
auto match = regex.match(string);
|
||||||
.match(string, 0, QRegularExpression::PartialPreferCompleteMatch,
|
QString captured = match.captured();
|
||||||
QRegularExpression::NoMatchOption)
|
|
||||||
.captured();
|
if (!captured.contains(QRegularExpression("\\bhttps?:\/\/")) && match.hasMatch()) {
|
||||||
if (!match.contains(QRegularExpression("\\bhttps?:\/\/"))) {
|
captured.insert(0, "http://");
|
||||||
match.insert(0, "https://");
|
|
||||||
}
|
}
|
||||||
return match;
|
return captured;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
|
|
Loading…
Reference in a new issue