| 28 | } |
| 29 | |
| 30 | TParsedLocation::TParsedLocation(TStringBuf path) { |
| 31 | path.Split(':', Scheme, path); |
| 32 | path.Skip(2); |
| 33 | |
| 34 | // try to handle both https://cert=./path_to_cert@host:port/... (userinfo is "cert=./path_to_cert") |
| 35 | // and http[s]://host:port/@zzz (userinfo is empty, host is host, not zzz |
| 36 | // see SEARCH-14238 |
| 37 | if (!SplitUserInfo(path, UserInfo, IsHttps(Scheme))) { |
| 38 | SplitUserInfo(path, UserInfo, false); |
| 39 | } |
| 40 | |
| 41 | auto checkRange = [](size_t b, size_t e){ |
| 42 | return b != TStringBuf::npos && e != TStringBuf::npos && b < e; |
| 43 | }; |
| 44 | |
| 45 | size_t oBracket = path.find_first_of('['); |
| 46 | size_t cBracket = path.find_first_of(']'); |
| 47 | size_t endEndPointPos = path.find_first_of('/'); |
| 48 | if (checkRange(oBracket, cBracket)) { |
| 49 | endEndPointPos = path.find_first_of('/', cBracket); |
| 50 | } |
| 51 | EndPoint = path.SubStr(0, endEndPointPos); |
| 52 | Host = EndPoint; |
| 53 | |
| 54 | size_t lastColon = EndPoint.find_last_of(':'); |
| 55 | if (checkRange(cBracket, lastColon) |
| 56 | || (cBracket == TStringBuf::npos && lastColon != TStringBuf::npos)) |
| 57 | { |
| 58 | Host = EndPoint.SubStr(0, lastColon); |
| 59 | Port = EndPoint.SubStr(lastColon + 1, EndPoint.size() - lastColon + 1); |
| 60 | } |
| 61 | |
| 62 | if (endEndPointPos != TStringBuf::npos) { |
| 63 | Service = path.SubStr(endEndPointPos + 1, path.size() - endEndPointPos + 1); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | ui16 TParsedLocation::GetPort() const { |
| 68 | if (!Port) { |
nothing calls this directly
no test coverage detected