diff options
author | arcturus <arcturus@yandex-team.ru> | 2022-02-10 16:49:55 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:55 +0300 |
commit | 4f03479b0d4ce794fae3628730b99157af573339 (patch) | |
tree | 51b2bbed8d9dc4de8b8c91bae1dc000da10af7a7 /library/cpp/string_utils/url/url.cpp | |
parent | f7e6d639f6922829aa197bf9413624d0d4ca4d66 (diff) | |
download | ydb-4f03479b0d4ce794fae3628730b99157af573339.tar.gz |
Restoring authorship annotation for <arcturus@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.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 85f4ac5d69..6376d9695b 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -394,28 +394,28 @@ TStringBuf RemoveFinalSlash(TStringBuf str) noexcept { } return str; } - -TStringBuf CutUrlPrefixes(TStringBuf url) noexcept { - url = CutSchemePrefix(url); - url = CutWWWPrefix(url); - return url; -} - -bool DoesUrlPathStartWithToken(TStringBuf url, const TStringBuf& token) noexcept { - url = CutSchemePrefix(url); - const TStringBuf noHostSuffix = url.After('/'); - if (noHostSuffix == url) { - // no slash => no suffix with token info - return false; - } - const bool suffixHasPrefix = noHostSuffix.StartsWith(token); - if (!suffixHasPrefix) { - return false; - } - const bool slashAfterPrefix = noHostSuffix.find("/", token.length()) == token.length(); - const bool qMarkAfterPrefix = noHostSuffix.find("?", token.length()) == token.length(); - const bool nothingAfterPrefix = noHostSuffix.length() <= token.length(); - const bool prefixIsToken = slashAfterPrefix || qMarkAfterPrefix || nothingAfterPrefix; - return prefixIsToken; -} - + +TStringBuf CutUrlPrefixes(TStringBuf url) noexcept { + url = CutSchemePrefix(url); + url = CutWWWPrefix(url); + return url; +} + +bool DoesUrlPathStartWithToken(TStringBuf url, const TStringBuf& token) noexcept { + url = CutSchemePrefix(url); + const TStringBuf noHostSuffix = url.After('/'); + if (noHostSuffix == url) { + // no slash => no suffix with token info + return false; + } + const bool suffixHasPrefix = noHostSuffix.StartsWith(token); + if (!suffixHasPrefix) { + return false; + } + const bool slashAfterPrefix = noHostSuffix.find("/", token.length()) == token.length(); + const bool qMarkAfterPrefix = noHostSuffix.find("?", token.length()) == token.length(); + const bool nothingAfterPrefix = noHostSuffix.length() <= token.length(); + const bool prefixIsToken = slashAfterPrefix || qMarkAfterPrefix || nothingAfterPrefix; + return prefixIsToken; +} + |