Refactor LinkParser (#4576)

This commit is contained in:
nerix
2023-04-23 16:56:39 +02:00
committed by GitHub
parent 4d0e4c1fca
commit 9c9fa86c45
3 changed files with 171 additions and 142 deletions
+7 -5
View File
@@ -80,11 +80,6 @@ TEST(LinkParser, parseIpv4Links)
{"http://", "196.168.4.0", "#foo"},
{"", "196.168.4.0", "/?#foo"},
{"", "196.168.4.0", "#?/foo"},
{"", "256.255.255.255"},
{"http://", "256.255.255.255"},
{"", "255.256.255.255"},
{"", "255.255.256.255"},
{"", "255.255.255.256"},
// test case-insensitiveness
{"HTTP://", "196.168.4.0", "#Foo"},
{"HTTPS://", "196.168.4.0", "#Foo"},
@@ -102,6 +97,8 @@ TEST(LinkParser, parseIpv4Links)
TEST(LinkParser, doesntParseInvalidIpv4Links)
{
const QStringList inputs = {
// U+0660 - in category "number digits"
QStringLiteral("٠.٠.٠.٠"),
"https://127.0.0.",
"http://127.0.01",
"127.0.0000.1",
@@ -112,6 +109,11 @@ TEST(LinkParser, doesntParseInvalidIpv4Links)
"1.2.3",
"htt://256.255.255.255",
"aliens://256.255.255.255",
"256.255.255.255",
"http://256.255.255.255",
"255.256.255.255",
"255.255.256.255",
"255.255.255.256",
};
for (const auto &input : inputs)