aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/url
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:46 +0300
commit8cbc307de0221f84c80c42dcbe07d40727537e2c (patch)
tree625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/string_utils/url
parent30d1ef3941e0dc835be7609de5ebee66958f215a (diff)
downloadydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils/url')
-rw-r--r--library/cpp/string_utils/url/url.cpp12
-rw-r--r--library/cpp/string_utils/url/url.h10
-rw-r--r--library/cpp/string_utils/url/url_ut.cpp24
3 files changed, 23 insertions, 23 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp
index 85f4ac5d69..284842f831 100644
--- a/library/cpp/string_utils/url/url.cpp
+++ b/library/cpp/string_utils/url/url.cpp
@@ -124,7 +124,7 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept {
}
template <bool KeepPort>
-static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) {
+static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) {
TStringBuf urlNoScheme = url;
urlNoScheme.Skip(GetHttpPrefixSize(url));
@@ -324,8 +324,8 @@ static bool HasPrefix(const TStringBuf url) noexcept {
TString AddSchemePrefix(const TString& url) {
return AddSchemePrefix(url, TStringBuf("http"));
-}
-
+}
+
TString AddSchemePrefix(const TString& url, TStringBuf scheme) {
if (HasPrefix(url)) {
return url;
@@ -347,7 +347,7 @@ static inline int x2c(unsigned char* x) {
static inline int Unescape(char* str) {
char *to, *from;
int dlen = 0;
- if ((str = strchr(str, '%')) == nullptr)
+ if ((str = strchr(str, '%')) == nullptr)
return dlen;
for (to = str, from = str; *from; from++, to++) {
if ((*to = *from) == '%') {
@@ -361,7 +361,7 @@ static inline int Unescape(char* str) {
return dlen;
}
-size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) {
+size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) {
if (source.empty() || source[0] == '?')
return strlcpy(dest, "/", dest_size);
size_t len = Min(dest_size - 1, source.length());
@@ -372,7 +372,7 @@ size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) {
return len;
}
-size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport) {
+size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport) {
size_t len = Min(dest_size - 1, source.length());
memcpy(dest, source.data(), len);
dest[len] = 0;
diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h
index 84137ccc57..287b42d3e3 100644
--- a/library/cpp/string_utils/url/url.h
+++ b/library/cpp/string_utils/url/url.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/fwd.h>
+#include <util/generic/fwd.h>
#include <util/generic/strbuf.h>
namespace NUrl {
@@ -60,9 +60,9 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept;
//! @note if URL has scheme prefix already the function returns unchanged URL
TString AddSchemePrefix(const TString& url, const TStringBuf scheme);
-//! Same as `AddSchemePrefix(url, "http")`.
+//! Same as `AddSchemePrefix(url, "http")`.
TString AddSchemePrefix(const TString& url);
-
+
Y_PURE_FUNCTION
TStringBuf GetHost(const TStringBuf url) noexcept;
@@ -159,8 +159,8 @@ TStringBuf CutMPrefix(const TStringBuf url) noexcept;
Y_PURE_FUNCTION
TStringBuf GetDomain(const TStringBuf host) noexcept; // should not be used
-size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size);
-size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport = 80);
+size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size);
+size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport = 80);
Y_PURE_FUNCTION
TStringBuf RemoveFinalSlash(TStringBuf str) noexcept;
diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp
index 1588013893..2c2f5948a0 100644
--- a/library/cpp/string_utils/url/url_ut.cpp
+++ b/library/cpp/string_utils/url/url_ut.cpp
@@ -4,8 +4,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TUtilUrlTest) {
- Y_UNIT_TEST(TestGetHostAndGetHostAndPort) {
+Y_UNIT_TEST_SUITE(TUtilUrlTest) {
+ Y_UNIT_TEST(TestGetHostAndGetHostAndPort) {
UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru/bebe"));
UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHostAndPort("ya.ru/bebe"));
UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru"));
@@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("", GetHost(""));
}
- Y_UNIT_TEST(TestGetPathAndQuery) {
+ Y_UNIT_TEST(TestGetPathAndQuery) {
UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org"));
UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org/"));
UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org:8080"));
@@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("/?1#comment", GetPathAndQuery("ru.wikipedia.org/?1#comment", false));
}
- Y_UNIT_TEST(TestGetDomain) {
+ Y_UNIT_TEST(TestGetDomain) {
UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("www.ya.ru"));
UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("ya.ru"));
UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("a.b.ya.ru"));
@@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("", GetDomain(""));
}
- Y_UNIT_TEST(TestGetParentDomain) {
+ Y_UNIT_TEST(TestGetParentDomain) {
UNIT_ASSERT_VALUES_EQUAL("", GetParentDomain("www.ya.ru", 0));
UNIT_ASSERT_VALUES_EQUAL("ru", GetParentDomain("www.ya.ru", 1));
UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetParentDomain("www.ya.ru", 2));
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("", GetParentDomain("", 1));
}
- Y_UNIT_TEST(TestGetZone) {
+ Y_UNIT_TEST(TestGetZone) {
UNIT_ASSERT_VALUES_EQUAL("ru", GetZone("www.ya.ru"));
UNIT_ASSERT_VALUES_EQUAL("com", GetZone("ya.com"));
UNIT_ASSERT_VALUES_EQUAL("RU", GetZone("RU"));
@@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("", GetZone(""));
}
- Y_UNIT_TEST(TestAddSchemePrefix) {
+ Y_UNIT_TEST(TestAddSchemePrefix) {
UNIT_ASSERT_VALUES_EQUAL("http://yandex.ru", AddSchemePrefix("yandex.ru"));
UNIT_ASSERT_VALUES_EQUAL("http://yandex.ru", AddSchemePrefix("http://yandex.ru"));
UNIT_ASSERT_VALUES_EQUAL("https://yandex.ru", AddSchemePrefix("https://yandex.ru"));
@@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("ftp://ya.ru", AddSchemePrefix("ya.ru", "ftp"));
}
- Y_UNIT_TEST(TestSchemeGet) {
+ Y_UNIT_TEST(TestSchemeGet) {
UNIT_ASSERT_VALUES_EQUAL("http://", GetSchemePrefix("http://ya.ru/bebe"));
UNIT_ASSERT_VALUES_EQUAL("", GetSchemePrefix("yaru"));
UNIT_ASSERT_VALUES_EQUAL("yaru://", GetSchemePrefix("yaru://ya.ru://zzz"));
@@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("https://", GetSchemePrefix("https://")); // is that right?
}
- Y_UNIT_TEST(TestSchemeCut) {
+ Y_UNIT_TEST(TestSchemeCut) {
UNIT_ASSERT_VALUES_EQUAL("ya.ru/bebe", CutSchemePrefix("http://ya.ru/bebe"));
UNIT_ASSERT_VALUES_EQUAL("yaru", CutSchemePrefix("yaru"));
UNIT_ASSERT_VALUES_EQUAL("ya.ru://zzz", CutSchemePrefix("yaru://ya.ru://zzz"));
@@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("https://", CutHttpPrefix("https://", true)); // is that right?
}
- Y_UNIT_TEST(TestMisc) {
+ Y_UNIT_TEST(TestMisc) {
UNIT_ASSERT_VALUES_EQUAL("", CutWWWPrefix("www."));
UNIT_ASSERT_VALUES_EQUAL("", CutWWWPrefix("WwW."));
UNIT_ASSERT_VALUES_EQUAL("www", CutWWWPrefix("www"));
@@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutMPrefix("m.ya.ru"));
}
- Y_UNIT_TEST(TestSplitUrlToHostAndPath) {
+ Y_UNIT_TEST(TestSplitUrlToHostAndPath) {
TStringBuf host, path;
SplitUrlToHostAndPath("https://yandex.ru/yandsearch", host, path);
@@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_STRINGS_EQUAL(fragment, "fragment");
}
- Y_UNIT_TEST(TestGetSchemeHostAndPort) {
+ Y_UNIT_TEST(TestGetSchemeHostAndPort) {
{ // all components are present
TStringBuf scheme("unknown"), host("unknown");
ui16 port = 0;