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

Function GetDomain

library/cpp/string_utils/url/url.cpp:305–317  ·  view source on GitHub ↗

this strange creature returns 2nd level domain, possibly with port

Source from the content-addressed store, hash-verified

303
304// this strange creature returns 2nd level domain, possibly with port
305TStringBuf 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
319TStringBuf GetParentDomain(const TStringBuf host Y_LIFETIME_BOUND, size_t level) noexcept {
320 size_t pos = host.size();

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 2

dataMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected