mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
RFC Compliant URL Matching
Implemented https://gist.github.com/dperini/729294 in Chatterino 2. This makes URL Validation / Matching RFC compliant.
This commit is contained in:
parent
64461161ec
commit
848253b015
1 changed files with 5 additions and 1 deletions
|
@ -79,7 +79,7 @@ QString MessageBuilder::matchLink(const QString &string)
|
|||
"$";
|
||||
|
||||
static QRegularExpression linkRegex(urlRegExp, QRegularExpression::CaseInsensitiveOption);
|
||||
|
||||
static QRegularExpression httpRegex("\\bhttps?://");
|
||||
auto match = linkRegex.match(string);
|
||||
|
||||
if (!match.hasMatch()) {
|
||||
|
@ -88,6 +88,10 @@ QString MessageBuilder::matchLink(const QString &string)
|
|||
|
||||
QString captured = match.captured();
|
||||
|
||||
if (!captured.contains(httpRegex)) {
|
||||
captured.insert(0, "http://");
|
||||
}
|
||||
|
||||
return captured;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue