| 455 | } |
| 456 | |
| 457 | bool 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 | } |
no test coverage detected