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:
Lajamerr Mittesdine 2018-06-05 06:19:35 -04:00 committed by GitHub
parent 64461161ec
commit 848253b015
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}