ClickHouse/tests/queries/0_stateless/00398_url_functions.sql.j2

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

173 lines
9.5 KiB
Plaintext
Raw Normal View History

2018-02-19 07:18:19 +00:00
SELECT '====SCHEMA====';
SELECT protocol('http://example.com') AS Scheme;
SELECT protocol('https://example.com/') AS Scheme;
SELECT protocol('svn+ssh://example.com?q=hello%20world') AS Scheme;
SELECT protocol('ftp!://example.com/') AS Scheme;
2016-12-09 22:49:21 +00:00
SELECT protocol('http://127.0.0.1:443/') AS Scheme;
2018-02-19 07:18:19 +00:00
SELECT protocol('//127.0.0.1:443/') AS Scheme;
2018-02-19 07:18:19 +00:00
SELECT '====HOST====';
{% for suffix in ['', 'RFC'] -%}
SELECT domain{{ suffix }}('http://paul@www.example.com:80/') AS Host;
SELECT domain{{ suffix }}('user:password@example.com:8080') AS Host;
SELECT domain{{ suffix }}('http://user:password@example.com:8080') AS Host;
SELECT domain{{ suffix }}('http://user:password@example.com:8080/path?query=value#fragment') AS Host;
SELECT domain{{ suffix }}('newuser:@example.com') AS Host;
SELECT domain{{ suffix }}('http://:pass@example.com') AS Host;
SELECT domain{{ suffix }}(':newpass@example.com') AS Host;
SELECT domain{{ suffix }}('http://user:pass@example@.com') AS Host;
SELECT domain{{ suffix }}('http://user:pass:example.com') AS Host;
SELECT domain{{ suffix }}('http:/paul/example/com') AS Host;
SELECT domain{{ suffix }}('http://www.example.com?q=4') AS Host;
SELECT domain{{ suffix }}('http://127.0.0.1:443/') AS Host;
SELECT domain{{ suffix }}('//www.example.com') AS Host;
SELECT domain{{ suffix }}('//paul@www.example.com') AS Host;
SELECT domain{{ suffix }}('www.example.com') as Host;
SELECT domain{{ suffix }}('example.com') as Host;
SELECT domainWithoutWWW{{ suffix }}('//paul@www.example.com') AS Host;
SELECT domainWithoutWWW{{ suffix }}('http://paul@www.example.com:80/') AS Host;
{% endfor %}
2016-12-09 22:49:21 +00:00
2020-06-02 08:34:08 +00:00
SELECT '====NETLOC====';
SELECT netloc('http://paul@www.example.com:80/') AS Netloc;
SELECT netloc('http://127.0.0.1:443/') AS Netloc;
SELECT netloc('http://127.0.0.1:443') AS Netloc;
SELECT netloc('svn+ssh://example.ru/?q=hello%20world') AS Netloc;
SELECT netloc('svn+ssh://example.ru/?q=hello%20world') AS Netloc;
SELECT netloc('svn+ssh://paul:zozo@example.ru/?q=hello%20world') AS Netloc;
SELECT netloc('svn+ssh://paul:zozo@example.ru/?q=hello%20world') AS Netloc;
SELECT netloc('//www.example.com') AS Netloc;
SELECT netloc('www.example.com') as Netloc;
SELECT netloc('example.com') as Netloc;
2018-02-19 07:18:19 +00:00
SELECT '====DOMAIN====';
2016-12-09 22:49:21 +00:00
SELECT topLevelDomain('http://paul@www.example.com:80/') AS Domain;
SELECT topLevelDomain('http://127.0.0.1:443/') AS Domain;
SELECT topLevelDomain('svn+ssh://example.ru?q=hello%20world') AS Domain;
SELECT topLevelDomain('svn+ssh://example.ru.?q=hello%20world') AS Domain;
2018-02-19 07:18:19 +00:00
SELECT topLevelDomain('//www.example.com') AS Domain;
SELECT topLevelDomain('www.example.com') as Domain;
SELECT topLevelDomain('example.com') as Domain;
2021-06-08 23:30:29 +00:00
SELECT topLevelDomain('example.рф') as Domain;
SELECT topLevelDomain('example.') as Domain;
SELECT topLevelDomain('example') as Domain;
2016-12-10 21:04:58 +00:00
2018-02-19 07:18:19 +00:00
SELECT '====PATH====';
SELECT decodeURLComponent('%D0%9F');
SELECT decodeURLComponent('%D%9');
2018-02-19 07:18:19 +00:00
SELECT decodeURLComponent(pathFull('//127.0.0.1/?query=hello%20world+foo%2Bbar')) AS Path;
SELECT decodeURLComponent(pathFull('http://127.0.0.1/?query=hello%20world+foo%2Bbar')) AS Path;
SELECT decodeURLComponent(materialize(pathFull('http://127.0.0.1/?query=hello%20world+foo%2Bbar'))) AS Path;
2018-02-19 07:18:19 +00:00
SELECT decodeURLComponent(materialize(pathFull('//127.0.0.1/?query=hello%20world+foo%2Bbar'))) AS Path;
2022-01-07 12:51:30 +00:00
SELECT decodeURLFormComponent(materialize(pathFull('//127.0.0.1/?query=hello%20world+foo%2Bbar'))) AS Path;
2018-02-20 00:45:32 +00:00
SELECT path('http://127.0.0.1') AS Path;
SELECT path('http://127.0.0.1/a/b/c') AS Path;
SELECT path('http://127.0.0.1:443/a/b/c') AS Path;
SELECT path('http://paul@127.0.0.1:443/a/b/c') AS Path;
SELECT path('//paul@127.0.0.1:443/a/b/c') AS Path;
SELECT '====QUERY STRING====';
SELECT decodeURLComponent(queryString('http://127.0.0.1/'));
SELECT decodeURLComponent(queryString('http://127.0.0.1/?'));
SELECT decodeURLComponent(queryString('http://127.0.0.1/?query=hello%20world+foo%2Bbar'));
SELECT decodeURLComponent(queryString('http://127.0.0.1:443/?query=hello%20world+foo%2Bbar'));
SELECT decodeURLComponent(queryString('http://paul@127.0.0.1:443/?query=hello%20world+foo%2Bbar'));
SELECT decodeURLComponent(queryString('//paul@127.0.0.1:443/?query=hello%20world+foo%2Bbar'));
2022-01-07 12:51:30 +00:00
SELECT decodeURLFormComponent(queryString('//paul@127.0.0.1:443/?query=hello%20world+foo%2Bbar'));
SELECT encodeURLComponent('');
SELECT encodeURLFormComponent('');
SELECT encodeURLComponent(NULL);
SELECT encodeURLFormComponent(NULL);
SELECT encodeURLComponent('hello world foo+bar');
SELECT encodeURLFormComponent('hello world foo+bar');
SELECT decodeURLComponent(encodeURLComponent('http://paul@127.0.0.1/?query=hello world foo+bar'));
SELECT decodeURLFormComponent(encodeURLFormComponent('http://paul@127.0.0.1/?query=hello world foo+bar'));
2018-02-20 00:45:32 +00:00
SELECT '====FRAGMENT====';
SELECT decodeURLComponent(fragment('http://127.0.0.1/?query=hello%20world+foo%2Bbar'));
SELECT decodeURLComponent(fragment('http://127.0.0.1/?query=hello%20world+foo%2Bbar#'));
SELECT decodeURLComponent(fragment('http://127.0.0.1/?query=hello%20world+foo%2Bbar#a=b'));
SELECT decodeURLComponent(fragment('http://paul@127.0.0.1/?query=hello%20world+foo%2Bbar#a=b'));
SELECT decodeURLComponent(fragment('//paul@127.0.0.1/?query=hello%20world+foo%2Bbar#a=b'));
SELECT '====QUERY STRING AND FRAGMENT====';
SELECT decodeURLComponent(queryStringAndFragment('http://127.0.0.1/'));
SELECT decodeURLComponent(queryStringAndFragment('http://127.0.0.1/?'));
SELECT decodeURLComponent(queryStringAndFragment('http://127.0.0.1/?query=hello%20world+foo%2Bbar'));
SELECT decodeURLComponent(queryStringAndFragment('http://127.0.0.1/?query=hello%20world+foo%2Bbar#a=b'));
SELECT decodeURLComponent(queryStringAndFragment('http://paul@127.0.0.1/?query=hello%20world+foo%2Bbar#a=b'));
SELECT decodeURLComponent(queryStringAndFragment('//paul@127.0.0.1/?query=hello%20world+foo%2Bbar#a=b'));
SELECT decodeURLComponent(queryStringAndFragment('//paul@127.0.0.1/#a=b'));
2022-01-07 12:51:30 +00:00
SELECT decodeURLFormComponent(queryStringAndFragment('//paul@127.0.0.1/?query=hello%20world+foo%2Bbar#a=b'));
SELECT encodeURLComponent('hello world foo+bar#a=b');
SELECT encodeURLFormComponent('hello world foo+bar#a=b');
SELECT decodeURLComponent(encodeURLComponent('http://paul@127.0.0.1/?query=hello world foo+bar#a=b'));
SELECT decodeURLFormComponent(encodeURLFormComponent('http://paul@127.0.0.1/?query=hello world foo+bar#a=b'));
2018-02-20 00:45:32 +00:00
SELECT '====CUT TO FIRST SIGNIFICANT SUBDOMAIN====';
{% for suffix in ['', 'RFC'] -%}
SELECT cutToFirstSignificantSubdomain{{ suffix }}('http://www.example.com');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('http://www.example.com:1234');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('http://www.example.com/a/b/c');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('http://www.example.com/a/b/c?a=b');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('http://www.example.com/a/b/c?a=b#d=f');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('http://paul@www.example.com/a/b/c?a=b#d=f');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('//paul@www.example.com/a/b/c?a=b#d=f');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('www.example.com');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('example.com');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('www.com');
SELECT cutToFirstSignificantSubdomain{{ suffix }}('com');
{% endfor %}
SELECT '====CUT TO FIRST SIGNIFICANT SUBDOMAIN WITH WWW====';
{% for suffix in ['', 'RFC'] -%}
SELECT cutToFirstSignificantSubdomainWithWWW{{ suffix }}('http://com');
SELECT cutToFirstSignificantSubdomainWithWWW{{ suffix }}('http://www.com');
SELECT cutToFirstSignificantSubdomainWithWWW{{ suffix }}('http://www.example.com');
SELECT cutToFirstSignificantSubdomainWithWWW{{ suffix }}('http://www.foo.example.com');
SELECT cutToFirstSignificantSubdomainWithWWW{{ suffix }}('http://www.example.com:1');
SELECT cutToFirstSignificantSubdomainWithWWW{{ suffix }}('http://www.example.com/');
{% endfor %}
2018-02-20 00:45:32 +00:00
SELECT '====CUT WWW====';
SELECT cutWWW('http://www.example.com');
SELECT cutWWW('http://www.example.com:1234');
SELECT cutWWW('http://www.example.com/a/b/c');
SELECT cutWWW('http://www.example.com/a/b/c?a=b');
SELECT cutWWW('http://www.example.com/a/b/c?a=b#d=f');
SELECT cutWWW('http://paul@www.example.com/a/b/c?a=b#d=f');
SELECT cutWWW('//paul@www.example.com/a/b/c?a=b#d=f');
SELECT '====CUT QUERY STRING====';
SELECT cutQueryString('http://www.example.com');
SELECT cutQueryString('http://www.example.com:1234');
SELECT cutQueryString('http://www.example.com/a/b/c');
SELECT cutQueryString('http://www.example.com/a/b/c?a=b');
SELECT cutQueryString('http://www.example.com/a/b/c?a=b#d=f');
SELECT cutQueryString('http://paul@www.example.com/a/b/c?a=b#d=f');
SELECT cutQueryString('//paul@www.example.com/a/b/c?a=b#d=f');
SELECT '====CUT FRAGMENT====';
SELECT cutFragment('http://www.example.com');
SELECT cutFragment('http://www.example.com:1234');
SELECT cutFragment('http://www.example.com/a/b/c');
SELECT cutFragment('http://www.example.com/a/b/c?a=b');
SELECT cutFragment('http://www.example.com/a/b/c?a=b#d=f');
SELECT cutFragment('http://paul@www.example.com/a/b/c?a=b#d=f');
SELECT cutFragment('//paul@www.example.com/a/b/c?a=b#d=f');
SELECT '====CUT QUERY STRING AND FRAGMENT====';
SELECT cutQueryStringAndFragment('http://www.example.com');
SELECT cutQueryStringAndFragment('http://www.example.com:1234');
SELECT cutQueryStringAndFragment('http://www.example.com/a/b/c');
SELECT cutQueryStringAndFragment('http://www.example.com/a/b/c?a=b');
SELECT cutQueryStringAndFragment('http://www.example.com/a/b/c?a=b#d=f');
SELECT cutQueryStringAndFragment('http://paul@www.example.com/a/b/c?a=b#d=f');
SELECT cutQueryStringAndFragment('//paul@www.example.com/a/b/c?a=b#d=f');
SELECT cutQueryStringAndFragment('//paul@www.example.com/a/b/c#d=f');
2018-02-20 00:45:32 +00:00