aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/url/url.cpp
diff options
context:
space:
mode:
authorarcturus <arcturus@yandex-team.ru>2022-02-10 16:49:55 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:55 +0300
commit0b79544a9f9a331f71e17b24779bf91ccdee76a0 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/string_utils/url/url.cpp
parent4f03479b0d4ce794fae3628730b99157af573339 (diff)
downloadydb-0b79544a9f9a331f71e17b24779bf91ccdee76a0.tar.gz
Restoring authorship annotation for <arcturus@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.cpp50
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 6376d9695b..85f4ac5d69 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;
+}
+