chore: improve link parser and its tests a bit (#5522)

This commit is contained in:
nerix
2024-07-23 23:38:17 +02:00
committed by GitHub
parent a0b70b8c5e
commit a2cbe6377d
2 changed files with 29 additions and 16 deletions
+11
View File
@@ -72,6 +72,8 @@ TEST(LinkParser, parseDomainLinks)
{"", "chatterino.com", ":80"},
{"", "wiki.chatterino.com", ":80"},
{"", "wiki.chatterino.com", ":80/foo/bar"},
{"", "wiki.chatterino.com", ":80?foo"},
{"", "wiki.chatterino.com", ":80#foo"},
{"", "wiki.chatterino.com", "/:80?foo/bar"},
{"", "wiki.chatterino.com", "/127.0.0.1"},
{"", "a.b.c.chatterino.com"},
@@ -156,6 +158,7 @@ TEST(LinkParser, parseIpv4Links)
TEST(LinkParser, doesntParseInvalidIpv4Links)
{
const QStringList inputs = {
"196.162.a.1",
// U+0660 - in category "number digits"
QStringLiteral("٠.٠.٠.٠"),
"https://127.0.0.",
@@ -186,6 +189,10 @@ TEST(LinkParser, doesntParseInvalidIpv4Links)
"196.162.8.1(",
"196.162.8.1(!",
"127.1.1;.com",
"127.0.-.1",
"127...",
"1.1.1.",
"1.1.1.:80",
};
for (const auto &input : inputs)
@@ -223,6 +230,10 @@ TEST(LinkParser, doesntParseInvalidLinks)
"https://pn./",
"pn./",
"pn.",
"pn.:80",
"pn./foo",
"pn.#foo",
"pn.?foo",
"http/chatterino.com",
"http/wiki.chatterino.com",
"http:cat.com",