注意
本节中提到的函数都经过优化,以实现最大性能,并且在大多数情况下不遵循 RFC-3986 标准。实现 RFC-3986 的函数在其函数名称后附加了 RFC,通常速度较慢。
在处理公开注册的域名时,通常可以使用非 RFC 函数变体,这些域名不包含用户字符串或 @ 符号。下表详细说明了 URL 中的哪些符号可以(✔)或不能(✗)被各自的 RFC 和非 RFC 变体解析
| 符号 | 非-RFC | RFC |
|---|
| ' ' | ✗ | ✗ |
| \t | ✗ | ✗ |
| < | ✗ | ✗ |
| > | ✗ | ✗ |
| % | ✗ | ✔* |
| { | ✗ | ✗ |
| } | ✗ | ✗ |
| | | ✗ | ✗ |
| \\ | ✗ | ✗ |
| ^ | ✗ | ✗ |
| ~ | ✗ | ✔* |
| [ | ✗ | ✗ |
| ] | ✗ | ✔ |
| ; | ✗ | ✔* |
| = | ✗ | ✔* |
| & | ✗ | ✔* |
带有 * 标记的符号是 RFC 3986 中的子分隔符,允许在 @ 符号之后跟随用户信息。
URL 函数有两种类型
- 提取 URL 各部分的函数。如果 URL 中不存在相关部分,则返回一个空字符串。
- 删除 URL 各部分的函数。如果 URL 不包含类似内容,则 URL 保持不变。
注意
以下函数是从 system.functions 系统表生成的。
cutFragment
引入于:v1.1
从 URL 中删除片段标识符,包括井号。
语法
参数
返回值
返回删除了片段标识符的 URL。 String
示例
使用示例
SELECT cutFragment('http://example.com/path?query=value#fragment123');
┌─cutFragment('http://example.com/path?query=value#fragment123')─┐
│ http://example.com/path?query=value │
└────────────────────────────────────────────────────────────────┘
cutQueryString
引入于:v1.1
从 URL 中删除查询字符串,包括问号。
语法
参数
返回值
返回删除了查询字符串的 URL。 String
示例
使用示例
SELECT cutQueryString('http://example.com/path?query=value¶m=123#fragment');
┌─cutQueryString('http://example.com/path?query=value¶m=123#fragment')─┐
│ http://example.com/path#fragment │
└──────────────────────────────────────────────────────────────────────────┘
cutQueryStringAndFragment
引入于:v1.1
从 URL 中删除查询字符串和片段标识符,包括问号和井号。
语法
cutQueryStringAndFragment(url)
参数
返回值
返回删除了查询字符串和片段标识符的 URL。 String
示例
使用示例
SELECT cutQueryStringAndFragment('http://example.com/path?query=value¶m=123#fragment');
┌─cutQueryStringAndFragment('http://example.com/path?query=value¶m=123#fragment')─┐
│ http://example.com/path │
└─────────────────────────────────────────────────────────────────────────────────────┘
cutToFirstSignificantSubdomain
引入于:v1.1
返回包含顶级子域名的域名部分,直到 第一个重要的子域名。
语法
cutToFirstSignificantSubdomain(url)
参数
返回值
如果可能,返回包含顶级子域名的域名部分,直到第一个重要的子域名,否则返回一个空字符串。 String
示例
使用示例
SELECT
cutToFirstSignificantSubdomain('https://news.clickhouse.com.tr/'),
cutToFirstSignificantSubdomain('www.tr'),
cutToFirstSignificantSubdomain('tr');
┌─cutToFirstSignificantSubdomain('https://news.clickhouse.com.tr/')─┬─cutToFirstSignificantSubdomain('www.tr')─┬─cutToFirstSignificantSubdomain('tr')─┐
│ clickhouse.com.tr │ tr │ │
└───────────────────────────────────────────────────────────────────┴──────────────────────────────────────────┴──────────────────────────────────────┘
cutToFirstSignificantSubdomainCustom
引入于:v21.1
返回包含顶级子域名的域名部分,直到第一个重要的子域名。接受自定义 TLD 列表名称。如果您需要最新的 TLD 列表或拥有自定义列表,此函数会很有用。
配置示例
<!-- <top_level_domains_path>/var/lib/clickhouse/top_level_domains/</top_level_domains_path> -->
<top_level_domains_lists>
<!-- https://publicsuffix.org/list/public_suffix_list.dat -->
<public_suffix_list>public_suffix_list.dat</public_suffix_list>
<!-- NOTE: path is under top_level_domains_path -->
</top_level_domains_lists>
语法
cutToFirstSignificantSubdomainCustom(url, tld_list_name)
参数
url — 要处理的 URL 或域名字符串。 String
tld_list_name — 在 ClickHouse 中配置的自定义 TLD 列表的名称。 const String
返回值
返回包含顶级子域名的域名部分,直到第一个重要的子域名。 String
示例
使用自定义 TLD 列表处理非标准域名
SELECT cutToFirstSignificantSubdomainCustom('bar.foo.there-is-no-such-domain', 'public_suffix_list')
foo.there-is-no-such-domain
cutToFirstSignificantSubdomainCustomRFC
引入于:v22.10
返回包含顶级子域名的域名部分,直到第一个重要的子域名。接受自定义 TLD 列表名称。如果您需要最新的 TLD 列表或拥有自定义列表,此函数会很有用。与 cutToFirstSignificantSubdomainCustom 类似,但符合 RFC 3986。
配置示例
<!-- <top_level_domains_path>/var/lib/clickhouse/top_level_domains/</top_level_domains_path> -->
<top_level_domains_lists>
<!-- https://publicsuffix.org/list/public_suffix_list.dat -->
<public_suffix_list>public_suffix_list.dat</public_suffix_list>
<!-- NOTE: path is under top_level_domains_path -->
</top_level_domains_lists>
语法
cutToFirstSignificantSubdomainCustomRFC(url, tld_list_name)
参数
url — 要根据 RFC 3986 处理的 URL 或域名字符串。 - tld_list_name — 在 ClickHouse 中配置的自定义 TLD 列表的名称。
返回值
返回包含顶级子域名的域名部分,直到第一个重要的子域名。 String
示例
使用示例
SELECT cutToFirstSignificantSubdomainCustomRFC('www.foo', 'public_suffix_list');
┌─cutToFirstSignificantSubdomainCustomRFC('www.foo', 'public_suffix_list')─────┐
│ www.foo │
└──────────────────────────────────────────────────────────────────────────────┘
cutToFirstSignificantSubdomainCustomWithWWW
引入于:v21.1
返回包含顶级子域名的域名部分,直到第一个重要的子域名,不去除 'www'。接受自定义 TLD 列表名称。如果您需要最新的 TLD 列表或拥有自定义列表,此函数会很有用。
配置示例
<!-- <top_level_domains_path>/var/lib/clickhouse/top_level_domains/</top_level_domains_path> -->
<top_level_domains_lists>
<!-- https://publicsuffix.org/list/public_suffix_list.dat -->
<public_suffix_list>public_suffix_list.dat</public_suffix_list>
<!-- NOTE: path is under top_level_domains_path -->
</top_level_domains_lists>
**Syntax**
```sql
cutToFirstSignificantSubdomainCustomWithWWW(url, tld_list_name)
参数
url — 要处理的 URL 或域名字符串。 - tld_list_name — 在 ClickHouse 中配置的自定义 TLD 列表的名称。
返回值
包含顶级子域名的域名部分,直到第一个重要的子域名,不去除 'www'。 String
示例
使用示例
SELECT cutToFirstSignificantSubdomainCustomWithWWW('www.foo', 'public_suffix_list');
┌─cutToFirstSignificantSubdomainCustomWithWWW('www.foo', 'public_suffix_list')─┐
│ www.foo │
└──────────────────────────────────────────────────────────────────────────────┘
cutToFirstSignificantSubdomainCustomWithWWWRFC
引入于:v22.10
返回包含顶级子域名的域名部分,直到第一个重要的子域名,不去除 www。接受自定义 TLD 列表名称。如果您需要最新的 TLD 列表或拥有自定义列表,此函数会很有用。与 cutToFirstSignificantSubdomainCustomWithWWW 类似,但符合 RFC 3986。
配置示例
<!-- <top_level_domains_path>/var/lib/clickhouse/top_level_domains/</top_level_domains_path> -->
<top_level_domains_lists>
<!-- https://publicsuffix.org/list/public_suffix_list.dat -->
<public_suffix_list>public_suffix_list.dat</public_suffix_list>
<!-- NOTE: path is under top_level_domains_path -->
</top_level_domains_lists>
**Syntax**
```sql
cutToFirstSignificantSubdomainCustomWithWWWRFC(url, tld_list_name)
参数
url — 要根据 RFC 3986 处理的 URL 或域名字符串。 - tld_list_name — 在 ClickHouse 中配置的自定义 TLD 列表的名称。
返回值
返回包含顶级子域名的域名部分,直到第一个重要的子域名,不去除 www。 String
示例
使用自定义 TLD 列表解析 RFC 3986,保留 www
SELECT cutToFirstSignificantSubdomainCustomWithWWWRFC('https://www.subdomain.example.custom', 'public_suffix_list')
cutToFirstSignificantSubdomainRFC
引入于:v22.10
返回包含顶级子域名的域名部分,直到 “第一个重要的子域名”。与 cutToFirstSignificantSubdomain 类似,但符合 RFC 3986。
语法
cutToFirstSignificantSubdomainRFC(url)
参数
url — 要根据 RFC 3986 处理的 URL 或域名字符串。 String
返回值
如果可能,返回包含顶级子域名的域名部分,直到第一个重要的子域名,否则返回一个空字符串。 String
示例
使用示例
┌─cutToFirstSignificantSubdomain('http://user:[email protected]:8080')─┬─cutToFirstSignificantSubdomainRFC('http://user:[email protected]:8080')─┐
│ │ example.com │
└─────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────┘
cutToFirstSignificantSubdomainWithWWW
引入于:v20.12
返回包含顶级子域名的域名部分,直到“第一个重要的子域名”,不去除 'www'。
与 cutToFirstSignificantSubdomain 类似,但保留 'www'。如果存在。
语法
cutToFirstSignificantSubdomainWithWWW(url)
参数
返回值
如果可能,返回包含顶级子域名的域名部分,直到第一个重要的子域名(带有 www),否则返回一个空字符串。 String
示例
使用示例
SELECT
cutToFirstSignificantSubdomainWithWWW('https://news.clickhouse.com.tr/'),
cutToFirstSignificantSubdomainWithWWW('www.tr'),
cutToFirstSignificantSubdomainWithWWW('tr');
┌─cutToFirstSignificantSubdomainWithWWW('https://news.clickhouse.com.tr/')─┬─cutToFirstSignificantSubdomainWithWWW('www.tr')─┬─cutToFirstSignificantSubdomainWithWWW('tr')─┐
│ clickhouse.com.tr │ www.tr │ │
└──────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────┴─────────────────────────────────────────────┘
cutToFirstSignificantSubdomainWithWWWRFC
引入于:v22.10
返回包含顶级子域名的域名部分,直到“第一个重要的子域名”,不去除 'www'。与 cutToFirstSignificantSubdomainWithWWW 类似,但符合 RFC 3986。
语法
cutToFirstSignificantSubdomainWithWWWRFC(url)
参数
url — 要根据 RFC 3986 处理的 URL 或域名字符串。
返回值
如果可能,返回包含顶级子域名的域名部分,直到第一个重要的子域名(带有 'www'),否则返回一个空字符串 String
示例
使用示例
SELECT
cutToFirstSignificantSubdomainWithWWW('http:%2F%[email protected]/economicheskiy'),
cutToFirstSignificantSubdomainWithWWWRFC('http:%2F%[email protected]/economicheskiy');
┌─cutToFirstSignificantSubdomainWithWWW('http:%2F%[email protected]/economicheskiy')─┬─cutToFirstSignificantSubdomainWithWWWRFC('http:%2F%[email protected]/economicheskiy')─┐
│ │ mail.ru │
└───────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────┘
cutURLParameter
引入于:v1.1
如果存在,则从 URL 中删除 name 参数。此函数不会对参数名称进行编码或解码,例如 Client ID 和 Client%20ID 被视为不同的参数名称。
语法
cutURLParameter(url, name)
参数
返回值
删除了 name URL 参数的 URL。 String
示例
使用示例
SELECT
cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', 'a') AS url_without_a,
cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', ['c', 'e']) AS url_without_c_and_e;
┌─url_without_a────────────────┬─url_without_c_and_e──────┐
│ http://bigmir.net/?c=d&e=f#g │ http://bigmir.net/?a=b#g │
└──────────────────────────────┴──────────────────────────┘
cutWWW
引入于:v1.1
如果存在,则从 URL 的域名中删除前导 www.。
语法
参数
返回值
返回删除了域名中前导 www. 的 URL。 String
示例
使用示例
SELECT cutWWW('http://www.example.com/path?query=value#fragment');
┌─cutWWW('http://www.example.com/path?query=value#fragment')─┐
│ http://example.com/path?query=value#fragment │
└────────────────────────────────────────────────────────────┘
decodeURLComponent
引入于:v1.1
接受 URL 编码的字符串作为输入,并将其解码回原始的可读形式。
语法
参数
返回值
返回解码后的 URL。 String
示例
使用示例
SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL;
┌─DecodedURL─────────────────────────────┐
│ http://127.0.0.1:8123/?query=SELECT 1; │
└────────────────────────────────────────┘
引入于:v1.1
使用表单编码规则 (RFC-1866) 解码 URL 编码的字符串,其中 + 符号被转换为空格,并且百分比编码的字符被解码。
语法
decodeURLFormComponent(url)
参数
返回值
返回解码后的 URL。 String
示例
使用示例
SELECT decodeURLFormComponent('http://127.0.0.1:8123/?query=SELECT%201+2%2B3') AS DecodedURL;
┌─DecodedURL────────────────────────────────┐
│ http://127.0.0.1:8123/?query=SELECT 1 2+3 │
└───────────────────────────────────────────┘
domain
引入于:v1.1
从 URL 中提取主机名。
URL 可以指定带有或不带有协议。
语法
参数
返回值
如果输入字符串可以解析为 URL,则返回主机名,否则返回一个空字符串。 String
示例
使用示例
SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk');
┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐
│ some.svn-hosting.com │
└────────────────────────────────────────────────────────┘
domainRFC
引入于:v22.10
从 URL 中提取主机名。与 domain 类似,但符合 RFC 3986。
语法
参数
返回值
如果输入字符串可以解析为 URL,则返回主机名,否则返回一个空字符串。 String
示例
使用示例
┌─domain('http://user:[email protected]:8080/path?query=value#fragment')─┬─domainRFC('http://user:[email protected]:8080/path?query=value#fragment')─┐
│ │ example.com │
└───────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────┘
domainWithoutWWW
引入于:v1.1
如果存在,则返回 URL 的域名,不带前导 www.。
语法
参数
返回值
如果输入字符串可以解析为 URL(不带前导 www.),则返回域名,否则返回一个空字符串。 String
示例
使用示例
┌─domainWithoutWWW('http://[email protected]:80/')─┐
│ example.com │
└─────────────────────────────────────────────────────┘
domainWithoutWWWRFC
引入于:v1.1
如果存在,则返回不带前导 www. 的域名。与 domainWithoutWWW 类似,但符合 RFC 3986。
语法
参数
返回值
如果输入字符串可以解析为 URL(不带前导 www.),则返回域名,否则返回一个空字符串。 String
示例
使用示例
SELECT
domainWithoutWWW('http://user:[email protected]:8080/path?query=value#fragment'),
domainWithoutWWWRFC('http://user:[email protected]:8080/path?query=value#fragment');
┌─domainWithoutWWW('http://user:[email protected]:8080/path?query=value#fragment')─┬─domainWithoutWWWRFC('http://user:[email protected]:8080/path?query=value#fragment')─┐
│ │ example.com │
└─────────────────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────┘
encodeURLComponent
引入于:v22.3
接受一个普通字符串,并将其转换为 URL 编码(百分比编码)格式,其中特殊字符被替换为其百分比编码的等效值。
语法
参数
返回值
返回编码后的 URL。 String
示例
使用示例
SELECT encodeURLComponent('http://127.0.0.1:8123/?query=SELECT 1;') AS EncodedURL;
┌─EncodedURL───────────────────────────────────────────────┐
│ http%3A%2F%2F127.0.0.1%3A8123%2F%3Fquery%3DSELECT%201%3B │
└──────────────────────────────────────────────────────────┘
引入于:v22.3
使用表单编码规则编码字符串(RFC-1866),其中空格转换为 + 号,特殊字符进行百分比编码。
语法
encodeURLFormComponent(url)
参数
返回值
返回编码后的 URL。 String
示例
使用示例
SELECT encodeURLFormComponent('http://127.0.0.1:8123/?query=SELECT 1 2+3') AS EncodedURL;
┌─EncodedURL────────────────────────────────────────────────┐
│ http%3A%2F%2F127.0.0.1%3A8123%2F%3Fquery%3DSELECT+1+2%2B3 │
└───────────────────────────────────────────────────────────┘
引入于:v1.1
如果存在,则返回 URL 中 name 参数的值,否则返回一个空字符串。 如果存在多个具有此名称的参数,则返回第一次出现的位置。 该函数假定 url 参数中的参数与 name 参数中的编码方式相同。
语法
extractURLParameter(url, name)
参数
返回值
返回具有指定名称的 URL 参数的值。 String
示例
使用示例
SELECT extractURLParameter('http://example.com/?param1=value1¶m2=value2', 'param1');
┌─extractURLPa⋯, 'param1')─┐
│ value1 │
└──────────────────────────┘
引入于:v1.1
返回一个字符串数组,对应于 URL 参数的名称。 值不会被解码。
语法
extractURLParameterNames(url)
参数
返回值
返回一个字符串数组,对应于 URL 参数的名称。 Array(String)
示例
使用示例
SELECT extractURLParameterNames('http://example.com/?param1=value1¶m2=value2');
┌─extractURLPa⋯m2=value2')─┐
│ ['param1','param2'] │
└──────────────────────────┘
引入于:v1.1
返回一个 name=value 字符串数组,对应于 URL 参数。 值不会被解码。
语法
extractURLParameters(url)
参数
返回值
返回一个 name=value 字符串数组,对应于 URL 参数。 Array(String)
示例
使用示例
SELECT extractURLParameters('http://example.com/?param1=value1¶m2=value2');
┌─extractURLParame⋯¶m2=value2')─┐
│ ['param1=value1','param2=value2'] │
└───────────────────────────────────┘
firstSignificantSubdomain
引入于:v
返回“第一个有意义的子域名”。
如果它是 'com'、'net'、'org' 或 'co',则第一个有意义的子域名是二级域名。 否则,它是三级域名。
例如,firstSignificantSubdomain('https://news.clickhouse.com/') = 'clickhouse',firstSignificantSubdomain ('https://news.clickhouse.com.tr/') = 'clickhouse'。
“不重要”的二级域名和其他实现细节在未来可能会发生变化。
语法
参数
返回值
示例
firstSignificantSubdomain
SELECT firstSignificantSubdomain('https://news.clickhouse.com/')
firstSignificantSubdomainRFC
引入于:v
根据 RFC 1034 返回“第一个有意义的子域名”。
语法
参数
返回值
示例
fragment
引入于:v1.1
返回不带初始井号符号的片段标识符。
语法
参数
返回值
返回不带初始井号符号的片段标识符。 String
示例
使用示例
SELECT fragment('https://clickhouse.ac.cn/docs/getting-started/quick-start/cloud#1-create-a-clickhouse-service');
┌─fragment('http⋯ouse-service')─┐
│ 1-create-a-clickhouse-service │
└───────────────────────────────┘
netloc
引入于:v20.5
从 URL 中提取网络位置(username:password@host:port)。
语法
参数
返回值
从给定的 URL 返回 username:password@host:port。 String
示例
使用示例
path
引入于:v1.1
返回不带查询字符串的 URL 的路径。
语法
参数
返回值
返回 URL 的路径,不带查询字符串。 String
示例
使用示例
SELECT path('https://clickhouse.ac.cn/docs/sql-reference/functions/url-functions/?query=value');
┌─path('https://clickhouse.ac.cn/en/sql-reference/functions/url-functions/?query=value')─┐
│ /docs/sql-reference/functions/url-functions/ │
└──────────────────────────────────────────────────────────────────────────────────────┘
pathFull
引入于:v1.1
与 path 相同,但包含 URL 的查询字符串和片段。
语法
参数
返回值
返回包含查询字符串和片段的 URL 的路径。 String
示例
使用示例
SELECT pathFull('https://clickhouse.ac.cn/docs/sql-reference/functions/url-functions/?query=value#section');
┌─pathFull('https://clickhouse.ac.cn⋯unctions/?query=value#section')─┐
│ /docs/sql-reference/functions/url-functions/?query=value#section │
└──────────────────────────────────────────────────────────────────┘
port
引入于:v20.5
返回 URL 的端口,或者如果 URL 不包含端口或无法解析,则返回 default_port。
语法
port(url[, default_port])
参数
url — URL。 String
default_port — 可选。要返回的默认端口号。 默认值为 0。 UInt16
返回值
返回 URL 的端口,或者如果 URL 中没有端口或在验证时出错,则返回默认端口。 UInt16
示例
使用示例
SELECT port('https://clickhouse.ac.cn:8443/docs'), port('https://clickhouse.ac.cn/docs', 443);
┌─port('https://clickhouse.ac.cn:8443/docs')─┬─port('https://clickhouse.ac.cn/docs', 443)─┐
│ 8443 │ 443 │
└──────────────────────────────────────────┴──────────────────────────────────────────┘
portRFC
引入于:v22.10
返回端口或 default_port,如果 URL 不包含端口或无法解析。 与 port 类似,但符合 RFC 3986。
语法
portRFC(url[, default_port])
参数
url — URL。 String
default_port — 可选。要返回的默认端口号。 默认值为 0。 UInt16
返回值
返回端口或默认端口,如果 URL 中没有端口或在验证时出错。 UInt16
示例
使用示例
┌─port('http:/⋯com:8080/')─┬─portRFC('htt⋯com:8080/')─┐
│ 0 │ 8080 │
└──────────────────────────┴──────────────────────────┘
protocol
引入于:v1.1
从 URL 中提取协议。
典型返回值的示例:http、https、ftp、mailto、tel、magnet。
语法
参数
返回值
返回 URL 的协议,如果无法确定,则返回一个空字符串。 String
示例
使用示例
SELECT protocol('https://clickhouse.ac.cn/');
┌─protocol('https://clickhouse.ac.cn/')─┐
│ https │
└─────────────────────────────────────┘
queryString
引入于:v1.1
返回 URL 的查询字符串,不带初始问号、# 以及 # 之后的所有内容。
语法
参数
返回值
返回 URL 的查询字符串,不带初始问号和片段。 String
示例
使用示例
SELECT queryString('https://clickhouse.ac.cn/docs?query=value¶m=123#section');
┌─queryString(⋯3#section')─┐
│ query=value¶m=123 │
└──────────────────────────┘
queryStringAndFragment
引入于:v1.1
返回 URL 的查询字符串和片段标识符。
语法
queryStringAndFragment(url)
参数
返回值
返回 URL 的查询字符串和片段标识符。 String
示例
使用示例
SELECT queryStringAndFragment('https://clickhouse.ac.cn/docs?query=value¶m=123#section');
┌─queryStringAnd⋯=123#section')─┐
│ query=value¶m=123#section │
└───────────────────────────────┘
topLevelDomain
引入于:v1.1
从 URL 中提取顶级域名。
注意
URL 可以带或不带协议指定。
svn+ssh://some.svn-hosting.com:80/repo/trunk
some.svn-hosting.com:80/repo/trunk
https://clickhouse.ac.cn/time/
语法
参数
返回值
如果输入字符串可以解析为 URL,则返回域名。 否则,返回一个空字符串。 String
示例
使用示例
SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk');
┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐
│ com │
└────────────────────────────────────────────────────────────────────┘
topLevelDomainRFC
引入于:v22.10
从 URL 中提取顶级域名。 与 topLevelDomain 类似,但符合 RFC 3986。
语法
参数
返回值
如果输入字符串可以解析为 URL,则返回域名。 否则,返回一个空字符串。 String
示例
使用示例
┌─topLevelDomain('http://foo:foo%[email protected]')─┬─topLevelDomainRFC('http://foo:foo%[email protected]')─┐
│ │ com │
└────────────────────────────────────────────────┴───────────────────────────────────────────────────┘