MCPcopy Create free account
hub / github.com/catboost/catboost / DoesUrlPathStartWithToken

Function DoesUrlPathStartWithToken

library/cpp/string_utils/url/url.cpp:457–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457bool DoesUrlPathStartWithToken(TStringBuf url, const TStringBuf token) noexcept {
458 url = CutSchemePrefix(url);
459 const TStringBuf noHostSuffix = url.After('/');
460 if (noHostSuffix == url) {
461 // no slash => no suffix with token info
462 return false;
463 }
464 const bool suffixHasPrefix = noHostSuffix.StartsWith(token);
465 if (!suffixHasPrefix) {
466 return false;
467 }
468 const bool slashAfterPrefix = noHostSuffix.find("/", token.length()) == token.length();
469 const bool qMarkAfterPrefix = noHostSuffix.find("?", token.length()) == token.length();
470 const bool nothingAfterPrefix = noHostSuffix.length() <= token.length();
471 const bool prefixIsToken = slashAfterPrefix || qMarkAfterPrefix || nothingAfterPrefix;
472 return prefixIsToken;
473}

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 5

CutSchemePrefixFunction · 0.85
AfterMethod · 0.80
StartsWithMethod · 0.45
findMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected