diff options
author | mowgli <mowgli@yandex-team.ru> | 2022-02-10 16:49:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:25 +0300 |
commit | 89afbbe4ca0e02e386dd4df08f7945f190dc1b84 (patch) | |
tree | c4772201af6215d48734691b8796e4cfc77c2ac8 /library/cpp/tld | |
parent | 7510cec1516d17cbc8d7749974e36aa45f547a26 (diff) | |
download | ydb-89afbbe4ca0e02e386dd4df08f7945f190dc1b84.tar.gz |
Restoring authorship annotation for <mowgli@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/tld')
-rw-r--r-- | library/cpp/tld/tld.cpp | 8 | ||||
-rw-r--r-- | library/cpp/tld/tld.h | 8 | ||||
-rw-r--r-- | library/cpp/tld/tld_ut.cpp | 60 |
3 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/tld/tld.cpp b/library/cpp/tld/tld.cpp index e31f3f0322..d67291676e 100644 --- a/library/cpp/tld/tld.cpp +++ b/library/cpp/tld/tld.cpp @@ -5,7 +5,7 @@ #include <util/generic/hash_set.h> #include <util/generic/singleton.h> -namespace NTld { +namespace NTld { namespace { #include <library/cpp/tld/tld.inc> @@ -18,18 +18,18 @@ namespace NTld { } } }; - + struct TVeryGoodTld: public TCiHash { TVeryGoodTld() { auto domains = { "am", "az", "biz", "by", "com", "cz", "de", "ec", "fr", "ge", "gov", "gr", "il", "info", "kg", "kz", "mobi", "net", "nu", "org", "lt", "lv", "md", "ru", "su", "tr", "ua", "uk", "uz", "ws", "xn--p1ai", "рф"}; - + for (auto d : domains) { insert(d); } - } + } }; } diff --git a/library/cpp/tld/tld.h b/library/cpp/tld/tld.h index 9e241de090..7c2061717a 100644 --- a/library/cpp/tld/tld.h +++ b/library/cpp/tld/tld.h @@ -17,12 +17,12 @@ namespace NTld { inline bool InTld(const TStringBuf& host) { return IsTld(FindTld(host)); } - + // check if @s belongs to a "good" subset of reliable TLDs, defined in tld.cpp bool IsVeryGoodTld(const TStringBuf& tld); - + inline bool InVeryGoodTld(const TStringBuf& host) { return IsVeryGoodTld(FindTld(host)); } - -} + +} diff --git a/library/cpp/tld/tld_ut.cpp b/library/cpp/tld/tld_ut.cpp index 733200f2b5..61a6779673 100644 --- a/library/cpp/tld/tld_ut.cpp +++ b/library/cpp/tld/tld_ut.cpp @@ -8,20 +8,20 @@ using namespace NTld; Y_UNIT_TEST_SUITE(TTldTest) { Y_UNIT_TEST(TestFindTld) { - UNIT_ASSERT(FindTld("yandex.ru") == "ru"); - UNIT_ASSERT(FindTld("YandeX.Ru") == "Ru"); - UNIT_ASSERT(FindTld("yandex.com.tr") == "tr"); - UNIT_ASSERT(FindTld("com.tr") == "tr"); - UNIT_ASSERT(FindTld("abc.def.ghi") == "ghi"); - UNIT_ASSERT(FindTld("abc.def.aaaaaaaaaa") == "aaaaaaaaaa"); - UNIT_ASSERT(FindTld("a.b.c.d.e.f.g") == "g"); - - UNIT_ASSERT(FindTld(".diff") == "diff"); - UNIT_ASSERT(FindTld(".") == ""); - UNIT_ASSERT(FindTld("ru") == ""); - UNIT_ASSERT(FindTld("") == ""); - } - + UNIT_ASSERT(FindTld("yandex.ru") == "ru"); + UNIT_ASSERT(FindTld("YandeX.Ru") == "Ru"); + UNIT_ASSERT(FindTld("yandex.com.tr") == "tr"); + UNIT_ASSERT(FindTld("com.tr") == "tr"); + UNIT_ASSERT(FindTld("abc.def.ghi") == "ghi"); + UNIT_ASSERT(FindTld("abc.def.aaaaaaaaaa") == "aaaaaaaaaa"); + UNIT_ASSERT(FindTld("a.b.c.d.e.f.g") == "g"); + + UNIT_ASSERT(FindTld(".diff") == "diff"); + UNIT_ASSERT(FindTld(".") == ""); + UNIT_ASSERT(FindTld("ru") == ""); + UNIT_ASSERT(FindTld("") == ""); + } + Y_UNIT_TEST(TestTLDs) { UNIT_ASSERT(IsTld("ru")); UNIT_ASSERT(IsTld("Ru")); @@ -36,24 +36,24 @@ Y_UNIT_TEST_SUITE(TTldTest) { UNIT_ASSERT(!InTld("ru.")); UNIT_ASSERT(!InTld("ru.xn")); } - + Y_UNIT_TEST(TestVeryGoodTlds) { - UNIT_ASSERT(IsVeryGoodTld("ru")); - UNIT_ASSERT(IsVeryGoodTld("Ru")); - UNIT_ASSERT(!IsVeryGoodTld("BMW")); - UNIT_ASSERT(!IsVeryGoodTld("TiReS")); - UNIT_ASSERT(IsVeryGoodTld("рф")); + UNIT_ASSERT(IsVeryGoodTld("ru")); + UNIT_ASSERT(IsVeryGoodTld("Ru")); + UNIT_ASSERT(!IsVeryGoodTld("BMW")); + UNIT_ASSERT(!IsVeryGoodTld("TiReS")); + UNIT_ASSERT(IsVeryGoodTld("рф")); UNIT_ASSERT(!IsVeryGoodTld("РФ")); // note that uppercase non-ascii tlds cannot be found UNIT_ASSERT(IsVeryGoodTld("xn--p1ai")); // "рф" UNIT_ASSERT(!IsVeryGoodTld("xn--p1ag")); // "ру" - UNIT_ASSERT(!IsVeryGoodTld("YaHOO")); - UNIT_ASSERT(!IsVeryGoodTld("xn")); - - UNIT_ASSERT(InVeryGoodTld("ru.ru")); - UNIT_ASSERT(InVeryGoodTld("яндекс.рф")); - UNIT_ASSERT(InVeryGoodTld("http://xn--d1acpjx3f.xn--p1ai")); - UNIT_ASSERT(!InVeryGoodTld("ru")); - UNIT_ASSERT(!InVeryGoodTld("ru.")); - UNIT_ASSERT(!InVeryGoodTld("ru.xn")); - } + UNIT_ASSERT(!IsVeryGoodTld("YaHOO")); + UNIT_ASSERT(!IsVeryGoodTld("xn")); + + UNIT_ASSERT(InVeryGoodTld("ru.ru")); + UNIT_ASSERT(InVeryGoodTld("яндекс.рф")); + UNIT_ASSERT(InVeryGoodTld("http://xn--d1acpjx3f.xn--p1ai")); + UNIT_ASSERT(!InVeryGoodTld("ru")); + UNIT_ASSERT(!InVeryGoodTld("ru.")); + UNIT_ASSERT(!InVeryGoodTld("ru.xn")); + } } |