aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils
diff options
context:
space:
mode:
authorsomov <somov@yandex-team.ru>2022-02-10 16:45:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:49 +0300
commit7489e4682331202b9c7d863c0898eb83d7b12c2b (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /library/cpp/string_utils
parenta5950576e397b1909261050b8c7da16db58f10b1 (diff)
downloadydb-7489e4682331202b9c7d863c0898eb83d7b12c2b.tar.gz
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/string_utils')
-rw-r--r--library/cpp/string_utils/url/url.cpp24
-rw-r--r--library/cpp/string_utils/url/url.h6
-rw-r--r--library/cpp/string_utils/url/url_ut.cpp14
3 files changed, 22 insertions, 22 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp
index 988122e5d1..85f4ac5d69 100644
--- a/library/cpp/string_utils/url/url.cpp
+++ b/library/cpp/string_utils/url/url.cpp
@@ -312,28 +312,28 @@ TStringBuf CutMPrefix(const TStringBuf url) noexcept {
static inline bool IsSchemeChar(char c) noexcept {
return IsAsciiAlnum(c); //what about '+' ?..
-}
-
+}
+
static bool HasPrefix(const TStringBuf url) noexcept {
TStringBuf scheme, unused;
if (!url.TrySplit(TStringBuf("://"), scheme, unused))
- return false;
-
+ return false;
+
return AllOf(scheme, IsSchemeChar);
-}
-
+}
+
TString AddSchemePrefix(const TString& url) {
return AddSchemePrefix(url, TStringBuf("http"));
}
TString AddSchemePrefix(const TString& url, TStringBuf scheme) {
- if (HasPrefix(url)) {
- return url;
- }
-
+ if (HasPrefix(url)) {
+ return url;
+ }
+
return TString::Join(scheme, TStringBuf("://"), url);
-}
-
+}
+
#define X(c) (c >= 'A' ? ((c & 0xdf) - 'A') + 10 : (c - '0'))
static inline int x2c(unsigned char* x) {
diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h
index c5c550ea6b..84137ccc57 100644
--- a/library/cpp/string_utils/url/url.h
+++ b/library/cpp/string_utils/url/url.h
@@ -56,10 +56,10 @@ TWtringBuf CutHttpPrefix(const TWtringBuf url, bool ignorehttps = false) noexcep
Y_PURE_FUNCTION
TStringBuf CutSchemePrefix(const TStringBuf url) noexcept;
-//! adds specified scheme prefix if URL has no scheme
-//! @note if URL has scheme prefix already the function returns unchanged URL
+//! adds specified scheme prefix if URL has no scheme
+//! @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")`.
TString AddSchemePrefix(const TString& url);
diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp
index 02a0de9e5f..1588013893 100644
--- a/library/cpp/string_utils/url/url_ut.cpp
+++ b/library/cpp/string_utils/url/url_ut.cpp
@@ -69,14 +69,14 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("FHFBN", GetZone("ya.FHFBN"));
UNIT_ASSERT_VALUES_EQUAL("", GetZone(""));
}
-
+
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"));
- UNIT_ASSERT_VALUES_EQUAL("file://yandex.ru", AddSchemePrefix("file://yandex.ru"));
- UNIT_ASSERT_VALUES_EQUAL("ftp://ya.ru", AddSchemePrefix("ya.ru", "ftp"));
- }
+ 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"));
+ UNIT_ASSERT_VALUES_EQUAL("file://yandex.ru", AddSchemePrefix("file://yandex.ru"));
+ UNIT_ASSERT_VALUES_EQUAL("ftp://ya.ru", AddSchemePrefix("ya.ru", "ftp"));
+ }
Y_UNIT_TEST(TestSchemeGet) {
UNIT_ASSERT_VALUES_EQUAL("http://", GetSchemePrefix("http://ya.ru/bebe"));