Better scheme cut

This commit is contained in:
alesapin 2019-06-25 12:04:35 +03:00
parent 48451b2b0f
commit fa88954e56
2 changed files with 9 additions and 13 deletions

View File

@ -32,23 +32,19 @@ inline StringRef getURLHost(const char * data, size_t size)
Pos end = data + size;
Pos slash_pos = find_first_symbols<'/'>(pos, end);
if (slash_pos != end)
pos = slash_pos;
if (slash_pos < end - 1 && *(slash_pos + 1) == '/')
pos = slash_pos + 2;
else
pos = data;
if (pos != data)
{
StringRef scheme = getURLScheme(data, size);
StringRef scheme = getURLScheme(data, end - pos);
Pos scheme_end = data + scheme.size;
if (pos - scheme_end != 1 || *scheme_end != ':')
if (scheme.size && (pos - scheme_end != 3 || *scheme_end != ':'))
return StringRef{};
}
// Check with we still have // character from the scheme
if (end - pos > 2 && *(pos) == '/' && *(pos + 1) == '/')
pos += 2;
auto start_of_host = pos;
Pos dot_pos = nullptr;
for (; pos < end; ++pos)

View File

@ -1,16 +1,16 @@
ru 262911 69218
ru 262914 69218
92101 89421
com 63297 30285
com 63298 30285
ua 29037 17475
html 25077 15037
html 25079 15039
tr 16770 11857
net 16387 11686
php 14373 10307
php 14374 10307
yandsearch 12024 9484
by 8192 6915
yandex 7211 6124
org 4890 4514
kz 4677 4209
kz 4679 4211
tv 4400 3928
su 2602 2396
phtml 2409 2226