mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Parse Domains Starting With http
(#4598)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
91f4b86436
commit
280b6d934e
|
@ -6,6 +6,7 @@
|
|||
- Minor: Added `/shield` and `/shieldoff` commands to toggle shield mode. (#4580)
|
||||
- Bugfix: Fixed the menu warping on macOS on Qt6. (#4595)
|
||||
- Bugfix: Fixed link tooltips not showing unless the thumbnail setting was enabled. (#4597)
|
||||
- Bugfix: Domains starting with `http` are now parsed as links again. (#4598)
|
||||
- Bugfix: Fixed click effects on buttons not being antialiased. (#4473)
|
||||
- Dev: Added the ability to control the `followRedirect` mode for requests. (#4594)
|
||||
|
||||
|
|
|
@ -137,16 +137,18 @@ LinkParser::LinkParser(const QString &unparsedString)
|
|||
if (remaining.startsWith(QStringLiteral("http"), Qt::CaseInsensitive) &&
|
||||
remaining.length() >= 4 + 3 + 1) // 'http' + '://' + [any]
|
||||
{
|
||||
remaining = remaining.mid(4); // 'http'
|
||||
// optimistic view assuming there's a protocol (http or https)
|
||||
auto withProto = remaining.mid(4); // 'http'
|
||||
|
||||
if (remaining[0] == QChar(u's') || remaining[0] == QChar(u'S'))
|
||||
if (withProto[0] == QChar(u's') || withProto[0] == QChar(u'S'))
|
||||
{
|
||||
remaining = remaining.mid(1);
|
||||
withProto = withProto.mid(1);
|
||||
}
|
||||
|
||||
if (remaining.startsWith(QStringLiteral("://")))
|
||||
if (withProto.startsWith(QStringLiteral("://")))
|
||||
{
|
||||
remaining = remaining.mid(3);
|
||||
// there's really a protocol => consume it
|
||||
remaining = withProto.mid(3);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
result.protocol = {protocol.begin(), remaining.begin()};
|
||||
#else
|
||||
|
|
|
@ -48,6 +48,13 @@ TEST(LinkParser, parseDomainLinks)
|
|||
{"", "1.com"},
|
||||
{"", "127.0.0.1.com"},
|
||||
{"https://", "127.0.0.1.com"},
|
||||
{"https://", "http.cat", "/200"},
|
||||
{"https://", "http.cat"},
|
||||
{"", "http.cat", ":8080"},
|
||||
{"", "http.cat"},
|
||||
{"", "https.cat"},
|
||||
{"", "httpsd.cat"},
|
||||
{"", "http.cat", "/200"},
|
||||
// test case-insensitiveness
|
||||
{"HtTpS://", "127.0.0.1.CoM"},
|
||||
{"HTTP://", "XD.CHATTERINO.COM", "/#?FOO"},
|
||||
|
@ -146,6 +153,18 @@ TEST(LinkParser, doesntParseInvalidLinks)
|
|||
"a",
|
||||
"://chatterino.com",
|
||||
"//chatterino.com",
|
||||
"http://pn.",
|
||||
"http://pn./",
|
||||
"https://pn./",
|
||||
"pn./",
|
||||
"pn.",
|
||||
"http/chatterino.com",
|
||||
"http/wiki.chatterino.com",
|
||||
"http:cat.com",
|
||||
"https:cat.com",
|
||||
"http:/cat.com",
|
||||
"http:/cat.com",
|
||||
"https:/cat.com",
|
||||
};
|
||||
|
||||
for (const auto &input : inputs)
|
||||
|
|
Loading…
Reference in a new issue