blob: 443a3323075c1cb44055789e0519c5cccb0862bd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "domain.h"
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionStringToString.h>
namespace DB
{
struct NameDomain { static constexpr auto name = "domain"; };
using FunctionDomain = FunctionStringToString<ExtractSubstringImpl<ExtractDomain<false, false>>, NameDomain>;
struct NameDomainRFC { static constexpr auto name = "domainRFC"; };
using FunctionDomainRFC = FunctionStringToString<ExtractSubstringImpl<ExtractDomain<false, true>>, NameDomainRFC>;
REGISTER_FUNCTION(Domain)
{
factory.registerFunction<FunctionDomain>(FunctionDocumentation
{
.description=R"(
Extracts the hostname from a URL.
The URL can be specified with or without a scheme.
If the argument can't be parsed as URL, the function returns an empty string.
)",
.examples{{"domain", "SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')", ""}},
.categories{"URL"}
});
factory.registerFunction<FunctionDomainRFC>(FunctionDocumentation
{
.description=R"(Similar to `domain` but follows stricter rules to be compatible with RFC 3986 and less performant.)",
.examples{},
.categories{"URL"}
});
}
}
|