aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tld/tld.h
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/tld/tld.h
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/tld/tld.h')
-rw-r--r--library/cpp/tld/tld.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/library/cpp/tld/tld.h b/library/cpp/tld/tld.h
new file mode 100644
index 00000000000..9e241de090b
--- /dev/null
+++ b/library/cpp/tld/tld.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <util/generic/strbuf.h>
+
+namespace NTld {
+ const char* const* GetTlds();
+
+ // Note that FindTld() returns empty string when @host is single domain label (without '.').
+ // If you need whole @host for such case, you can use GetZone() from library/cpp/string_utils/url/url.h
+ inline TStringBuf FindTld(const TStringBuf& host) {
+ size_t p = host.rfind('.');
+ return p != TStringBuf::npos ? host.SubStr(p + 1) : TStringBuf();
+ }
+
+ bool IsTld(const TStringBuf& tld);
+
+ 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));
+ }
+
+}