this strange creature returns 2nd level domain, possibly with port
| 303 | |
| 304 | // this strange creature returns 2nd level domain, possibly with port |
| 305 | TStringBuf GetDomain(const TStringBuf host Y_LIFETIME_BOUND) noexcept { |
| 306 | const char* c = !host ? host.data() : host.end() - 1; |
| 307 | for (bool wasPoint = false; c != host.data(); --c) { |
| 308 | if (*c == '.') { |
| 309 | if (wasPoint) { |
| 310 | ++c; |
| 311 | break; |
| 312 | } |
| 313 | wasPoint = true; |
| 314 | } |
| 315 | } |
| 316 | return TStringBuf(c, host.end()); |
| 317 | } |
| 318 | |
| 319 | TStringBuf GetParentDomain(const TStringBuf host Y_LIFETIME_BOUND, size_t level) noexcept { |
| 320 | size_t pos = host.size(); |
no test coverage detected