mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Added support for non http/https links. (#82)
This commit is contained in:
parent
b3b89e8019
commit
f787d3f464
1 changed files with 6 additions and 3 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("(\\bhttps?:\/\/)?[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]");
|
||||||
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,11 @@ void MessageBuilder::appendTimestamp(time_t time)
|
||||||
|
|
||||||
QString MessageBuilder::matchLink(const QString &string)
|
QString MessageBuilder::matchLink(const QString &string)
|
||||||
{
|
{
|
||||||
QRegularExpressionMatch match = regex.match(string);
|
QString match = regex.match(string,0,QRegularExpression::PartialPreferCompleteMatch,QRegularExpression::NoMatchOption).captured();
|
||||||
return match.captured();
|
if(!match.contains(QRegularExpression("\\bhttps?:\/\/"))){
|
||||||
|
match.insert(0,"https://");
|
||||||
|
}
|
||||||
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
|
|
Loading…
Reference in a new issue