diff options
author | Ilnur Khuziev <ilnur.khuziev@yandex.ru> | 2022-02-10 16:46:14 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:14 +0300 |
commit | 60040c91ffe701a84689b2c6310ff845e65cff42 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/string_utils/url/url.cpp | |
parent | 736dcd8ca259457a136f2f9f9168c44643914323 (diff) | |
download | ydb-60040c91ffe701a84689b2c6310ff845e65cff42.tar.gz |
Restoring authorship annotation for Ilnur Khuziev <ilnur.khuziev@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/string_utils/url/url.cpp')
-rw-r--r-- | library/cpp/string_utils/url/url.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 376a09a465..85f4ac5d69 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -73,31 +73,31 @@ namespace NUrl { } // namespace NUrl -size_t GetHttpPrefixSize(const char* url, bool ignorehttps) noexcept { +size_t GetHttpPrefixSize(const char* url, bool ignorehttps) noexcept { return GetHttpPrefixSizeImpl<char>(url, TUncheckedSize(), ignorehttps); } -size_t GetHttpPrefixSize(const wchar16* url, bool ignorehttps) noexcept { +size_t GetHttpPrefixSize(const wchar16* url, bool ignorehttps) noexcept { return GetHttpPrefixSizeImpl<wchar16>(url, TUncheckedSize(), ignorehttps); } -size_t GetHttpPrefixSize(const TStringBuf url, bool ignorehttps) noexcept { +size_t GetHttpPrefixSize(const TStringBuf url, bool ignorehttps) noexcept { return GetHttpPrefixSizeImpl<char>(url.data(), TKnownSize(url.size()), ignorehttps); } -size_t GetHttpPrefixSize(const TWtringBuf url, bool ignorehttps) noexcept { +size_t GetHttpPrefixSize(const TWtringBuf url, bool ignorehttps) noexcept { return GetHttpPrefixSizeImpl<wchar16>(url.data(), TKnownSize(url.size()), ignorehttps); } -TStringBuf CutHttpPrefix(const TStringBuf url, bool ignorehttps) noexcept { +TStringBuf CutHttpPrefix(const TStringBuf url, bool ignorehttps) noexcept { return CutHttpPrefixImpl(url, ignorehttps); } -TWtringBuf CutHttpPrefix(const TWtringBuf url, bool ignorehttps) noexcept { +TWtringBuf CutHttpPrefix(const TWtringBuf url, bool ignorehttps) noexcept { return CutHttpPrefixImpl(url, ignorehttps); } -size_t GetSchemePrefixSize(const TStringBuf url) noexcept { +size_t GetSchemePrefixSize(const TStringBuf url) noexcept { struct TDelim: public str_spn { inline TDelim() : str_spn("!-/:-@[-`{|}", true) @@ -115,11 +115,11 @@ size_t GetSchemePrefixSize(const TStringBuf url) noexcept { return n + 3 - url.begin(); } -TStringBuf GetSchemePrefix(const TStringBuf url) noexcept { +TStringBuf GetSchemePrefix(const TStringBuf url) noexcept { return url.Head(GetSchemePrefixSize(url)); } -TStringBuf CutSchemePrefix(const TStringBuf url) noexcept { +TStringBuf CutSchemePrefix(const TStringBuf url) noexcept { return url.Tail(GetSchemePrefixSize(url)); } @@ -146,15 +146,15 @@ static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) { return urlNoScheme; } -TStringBuf GetHost(const TStringBuf url) noexcept { +TStringBuf GetHost(const TStringBuf url) noexcept { return GetHostAndPortImpl<false>(url); } -TStringBuf GetHostAndPort(const TStringBuf url) noexcept { +TStringBuf GetHostAndPort(const TStringBuf url) noexcept { return GetHostAndPortImpl<true>(url); } -TStringBuf GetSchemeHostAndPort(const TStringBuf url, bool trimHttp, bool trimDefaultPort) noexcept { +TStringBuf GetSchemeHostAndPort(const TStringBuf url, bool trimHttp, bool trimDefaultPort) noexcept { const size_t schemeSize = GetSchemePrefixSize(url); const TStringBuf scheme = url.Head(schemeSize); @@ -235,11 +235,11 @@ void GetSchemeHostAndPort(const TStringBuf url, TStringBuf& scheme, TStringBuf& Y_ENSURE(isOk, "cannot parse port number from URL: " << url); } -TStringBuf GetOnlyHost(const TStringBuf url) noexcept { +TStringBuf GetOnlyHost(const TStringBuf url) noexcept { return GetHost(CutSchemePrefix(url)); } -TStringBuf GetPathAndQuery(const TStringBuf url, bool trimFragment) noexcept { +TStringBuf GetPathAndQuery(const TStringBuf url, bool trimFragment) noexcept { const size_t off = url.find('/', GetHttpPrefixSize(url)); TStringBuf hostUnused, path; if (!url.TrySplitAt(off, hostUnused, path)) @@ -249,7 +249,7 @@ TStringBuf GetPathAndQuery(const TStringBuf url, bool trimFragment) noexcept { } // this strange creature returns 2nd level domain, possibly with port -TStringBuf GetDomain(const TStringBuf host) noexcept { +TStringBuf GetDomain(const TStringBuf host) noexcept { const char* c = !host ? host.data() : host.end() - 1; for (bool wasPoint = false; c != host.data(); --c) { if (*c == '.') { @@ -263,7 +263,7 @@ TStringBuf GetDomain(const TStringBuf host) noexcept { return TStringBuf(c, host.end()); } -TStringBuf GetParentDomain(const TStringBuf host, size_t level) noexcept { +TStringBuf GetParentDomain(const TStringBuf host, size_t level) noexcept { size_t pos = host.size(); for (size_t i = 0; i < level; ++i) { pos = host.rfind('.', pos); @@ -273,11 +273,11 @@ TStringBuf GetParentDomain(const TStringBuf host, size_t level) noexcept { return host.SubStr(pos + 1); } -TStringBuf GetZone(const TStringBuf host) noexcept { +TStringBuf GetZone(const TStringBuf host) noexcept { return GetParentDomain(host, 1); } -TStringBuf CutWWWPrefix(const TStringBuf url) noexcept { +TStringBuf CutWWWPrefix(const TStringBuf url) noexcept { if (url.size() >= 4 && url[3] == '.' && !strnicmp(url.data(), "www", 3)) return url.substr(4); return url; @@ -388,7 +388,7 @@ size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, return len; } -TStringBuf RemoveFinalSlash(TStringBuf str) noexcept { +TStringBuf RemoveFinalSlash(TStringBuf str) noexcept { if (str.EndsWith('/')) { str.Chop(1); } |