aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/url/url.cpp
diff options
context:
space:
mode:
authorsmikler <smikler@yandex-team.ru>2022-02-10 16:49:33 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:33 +0300
commit0e68ae909d3b76a5a001a07880eb0010dec6b2ea (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/string_utils/url/url.cpp
parente4f0fd4ab53ca40eb91e750cf3e7f76c21e930db (diff)
downloadydb-0e68ae909d3b76a5a001a07880eb0010dec6b2ea.tar.gz
Restoring authorship annotation for <smikler@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/string_utils/url/url.cpp')
-rw-r--r--library/cpp/string_utils/url/url.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp
index 579d1e25be..85f4ac5d69 100644
--- a/library/cpp/string_utils/url/url.cpp
+++ b/library/cpp/string_utils/url/url.cpp
@@ -147,41 +147,41 @@ static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) {
}
TStringBuf GetHost(const TStringBuf url) noexcept {
- return GetHostAndPortImpl<false>(url);
-}
-
+ return GetHostAndPortImpl<false>(url);
+}
+
TStringBuf GetHostAndPort(const TStringBuf url) noexcept {
- return GetHostAndPortImpl<true>(url);
-}
-
+ return GetHostAndPortImpl<true>(url);
+}
+
TStringBuf GetSchemeHostAndPort(const TStringBuf url, bool trimHttp, bool trimDefaultPort) noexcept {
- const size_t schemeSize = GetSchemePrefixSize(url);
- const TStringBuf scheme = url.Head(schemeSize);
-
+ const size_t schemeSize = GetSchemePrefixSize(url);
+ const TStringBuf scheme = url.Head(schemeSize);
+
const bool isHttp = (schemeSize == 0 || scheme == TStringBuf("http://"));
-
- TStringBuf hostAndPort = GetHostAndPort(url.Tail(schemeSize));
-
- if (trimDefaultPort) {
- const size_t pos = hostAndPort.find(':');
- if (pos != TStringBuf::npos) {
+
+ TStringBuf hostAndPort = GetHostAndPort(url.Tail(schemeSize));
+
+ if (trimDefaultPort) {
+ const size_t pos = hostAndPort.find(':');
+ if (pos != TStringBuf::npos) {
const bool isHttps = (scheme == TStringBuf("https://"));
-
- const TStringBuf port = hostAndPort.Tail(pos + 1);
+
+ const TStringBuf port = hostAndPort.Tail(pos + 1);
if ((isHttp && port == TStringBuf("80")) || (isHttps && port == TStringBuf("443"))) {
- // trimming default port
- hostAndPort = hostAndPort.Head(pos);
- }
- }
- }
-
- if (isHttp && trimHttp) {
- return hostAndPort;
- } else {
- return TStringBuf(scheme.begin(), hostAndPort.end());
- }
-}
-
+ // trimming default port
+ hostAndPort = hostAndPort.Head(pos);
+ }
+ }
+ }
+
+ if (isHttp && trimHttp) {
+ return hostAndPort;
+ } else {
+ return TStringBuf(scheme.begin(), hostAndPort.end());
+ }
+}
+
void SplitUrlToHostAndPath(const TStringBuf url, TStringBuf& host, TStringBuf& path) {
auto [hostBuf, pathBuf] = NUrl::SplitUrlToHostAndPath(url);
host = hostBuf;
@@ -240,14 +240,14 @@ TStringBuf GetOnlyHost(const TStringBuf url) noexcept {
}
TStringBuf GetPathAndQuery(const TStringBuf url, bool trimFragment) noexcept {
- const size_t off = url.find('/', GetHttpPrefixSize(url));
+ const size_t off = url.find('/', GetHttpPrefixSize(url));
TStringBuf hostUnused, path;
if (!url.TrySplitAt(off, hostUnused, path))
- return "/";
+ return "/";
return trimFragment ? path.Before('#') : path;
-}
-
+}
+
// 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;