aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/url/url.cpp
diff options
context:
space:
mode:
authormelkov <melkov@yandex-team.ru>2022-02-10 16:48:13 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:13 +0300
commit438546c8737d5c1fdeb31157dcf999717d930eec (patch)
treed29d229abd2f9f889b9b7eb148d635059dc26acf /library/cpp/string_utils/url/url.cpp
parent96647fad5355ff5ef45a00a6d85c097028584ab0 (diff)
downloadydb-438546c8737d5c1fdeb31157dcf999717d930eec.tar.gz
Restoring authorship annotation for <melkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils/url/url.cpp')
-rw-r--r--library/cpp/string_utils/url/url.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp
index 85f4ac5d69..a7f42f0360 100644
--- a/library/cpp/string_utils/url/url.cpp
+++ b/library/cpp/string_utils/url/url.cpp
@@ -16,37 +16,37 @@
#include <cstdlib>
namespace {
- struct TUncheckedSize {
+ struct TUncheckedSize {
static bool Has(size_t) {
- return true;
- }
- };
-
- struct TKnownSize {
- size_t MySize;
+ return true;
+ }
+ };
+
+ struct TKnownSize {
+ size_t MySize;
explicit TKnownSize(size_t sz)
- : MySize(sz)
+ : MySize(sz)
{
}
- bool Has(size_t sz) const {
- return sz <= MySize;
- }
- };
-
- template <typename TChar1, typename TChar2>
- int Compare1Case2(const TChar1* s1, const TChar2* s2, size_t n) {
- for (size_t i = 0; i < n; ++i) {
+ bool Has(size_t sz) const {
+ return sz <= MySize;
+ }
+ };
+
+ template <typename TChar1, typename TChar2>
+ int Compare1Case2(const TChar1* s1, const TChar2* s2, size_t n) {
+ for (size_t i = 0; i < n; ++i) {
if ((TChar1)ToLower(s1[i]) != s2[i])
return (TChar1)ToLower(s1[i]) < s2[i] ? -1 : 1;
- }
- return 0;
- }
-
+ }
+ return 0;
+ }
+
template <typename TChar, typename TBounds>
inline size_t GetHttpPrefixSizeImpl(const TChar* url, const TBounds& urlSize, bool ignorehttps) {
const TChar httpPrefix[] = {'h', 't', 't', 'p', ':', '/', '/', 0};
const TChar httpsPrefix[] = {'h', 't', 't', 'p', 's', ':', '/', '/', 0};
- if (urlSize.Has(7) && Compare1Case2(url, httpPrefix, 7) == 0)
+ if (urlSize.Has(7) && Compare1Case2(url, httpPrefix, 7) == 0)
return 7;
if (!ignorehttps && urlSize.Has(8) && Compare1Case2(url, httpsPrefix, 8) == 0)
return 8;
@@ -113,8 +113,8 @@ size_t GetSchemePrefixSize(const TStringBuf url) noexcept {
}
return n + 3 - url.begin();
-}
-
+}
+
TStringBuf GetSchemePrefix(const TStringBuf url) noexcept {
return url.Head(GetSchemePrefixSize(url));
}
@@ -236,7 +236,7 @@ void GetSchemeHostAndPort(const TStringBuf url, TStringBuf& scheme, TStringBuf&
}
TStringBuf GetOnlyHost(const TStringBuf url) noexcept {
- return GetHost(CutSchemePrefix(url));
+ return GetHost(CutSchemePrefix(url));
}
TStringBuf GetPathAndQuery(const TStringBuf url, bool trimFragment) noexcept {
@@ -248,19 +248,19 @@ TStringBuf GetPathAndQuery(const TStringBuf url, bool trimFragment) noexcept {
return trimFragment ? path.Before('#') : path;
}
-// this strange creature returns 2nd level domain, possibly with port
+// this strange creature returns 2nd level domain, possibly with port
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 == '.') {
- if (wasPoint) {
+ if (*c == '.') {
+ if (wasPoint) {
++c;
break;
- }
+ }
wasPoint = true;
}
}
- return TStringBuf(c, host.end());
+ return TStringBuf(c, host.end());
}
TStringBuf GetParentDomain(const TStringBuf host, size_t level) noexcept {