diff options
author | rihter007 <rihter007@yandex-team.ru> | 2022-02-10 16:49:56 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:56 +0300 |
commit | b680597fd640bc7c018ffdd21f0d94a24f18450b (patch) | |
tree | e6a96c9570ccaf0212486f6d9b6c6f589027786e /library/cpp/string_utils | |
parent | d0a386457ef009c1ed42e3e9b30f0dbcbf89d76b (diff) | |
download | ydb-b680597fd640bc7c018ffdd21f0d94a24f18450b.tar.gz |
Restoring authorship annotation for <rihter007@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils')
-rw-r--r-- | library/cpp/string_utils/url/url.cpp | 14 | ||||
-rw-r--r-- | library/cpp/string_utils/url/url.h | 24 | ||||
-rw-r--r-- | library/cpp/string_utils/url/url_ut.cpp | 10 |
3 files changed, 24 insertions, 24 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 85f4ac5d69..8947ea0674 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -303,13 +303,13 @@ TStringBuf CutWWWNumberedPrefix(const TStringBuf url) noexcept { return url; } -TStringBuf CutMPrefix(const TStringBuf url) noexcept { - if (url.size() >= 2 && url[1] == '.' && (url[0] == 'm' || url[0] == 'M')) { - return url.substr(2); - } - return url; -} - +TStringBuf CutMPrefix(const TStringBuf url) noexcept { + if (url.size() >= 2 && url[1] == '.' && (url[0] == 'm' || url[0] == 'M')) { + return url.substr(2); + } + return url; +} + static inline bool IsSchemeChar(char c) noexcept { return IsAsciiAlnum(c); //what about '+' ?.. } diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h index 84137ccc57..dd43c0ae81 100644 --- a/library/cpp/string_utils/url/url.h +++ b/library/cpp/string_utils/url/url.h @@ -145,18 +145,18 @@ TStringBuf CutWWWPrefix(const TStringBuf url) noexcept; Y_PURE_FUNCTION TStringBuf CutWWWNumberedPrefix(const TStringBuf url) noexcept; -/** - * Cuts 'm.' prefix from url if and only if the url starts with it - * Example: 'm.some-domain.com' -> 'some-domain.com'. - * 'http://m.some-domain.com' is not changed - * - * @param[in] url any URL - * @return url without 'm.' or 'M.' prefix. - */ -Y_PURE_FUNCTION -TStringBuf CutMPrefix(const TStringBuf url) noexcept; - -Y_PURE_FUNCTION +/** + * Cuts 'm.' prefix from url if and only if the url starts with it + * Example: 'm.some-domain.com' -> 'some-domain.com'. + * 'http://m.some-domain.com' is not changed + * + * @param[in] url any URL + * @return url without 'm.' or 'M.' prefix. + */ +Y_PURE_FUNCTION +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); diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp index 1588013893..a1ba1c534d 100644 --- a/library/cpp/string_utils/url/url_ut.cpp +++ b/library/cpp/string_utils/url/url_ut.cpp @@ -109,7 +109,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", CutWWWPrefix("WwW.")); UNIT_ASSERT_VALUES_EQUAL("www", CutWWWPrefix("www")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWPrefix("www.ya.ru")); - + UNIT_ASSERT_VALUES_EQUAL("", CutWWWNumberedPrefix("www.")); UNIT_ASSERT_VALUES_EQUAL("www", CutWWWNumberedPrefix("www")); UNIT_ASSERT_VALUES_EQUAL("www27", CutWWWNumberedPrefix("www27")); @@ -121,10 +121,10 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("w1w2w3.ya.ru", CutWWWNumberedPrefix("w1w2w3.ya.ru")); UNIT_ASSERT_VALUES_EQUAL("123.ya.ru", CutWWWNumberedPrefix("123.ya.ru")); - UNIT_ASSERT_VALUES_EQUAL("", CutMPrefix("m.")); - UNIT_ASSERT_VALUES_EQUAL("", CutMPrefix("M.")); - UNIT_ASSERT_VALUES_EQUAL("m", CutMPrefix("m")); - UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutMPrefix("m.ya.ru")); + UNIT_ASSERT_VALUES_EQUAL("", CutMPrefix("m.")); + UNIT_ASSERT_VALUES_EQUAL("", CutMPrefix("M.")); + UNIT_ASSERT_VALUES_EQUAL("m", CutMPrefix("m")); + UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutMPrefix("m.ya.ru")); } Y_UNIT_TEST(TestSplitUrlToHostAndPath) { |