2022-07-22 07:38:37 +00:00
|
|
|
-- { echo }
|
|
|
|
|
|
|
|
select '-- no-tld';
|
2021-03-21 07:55:28 +00:00
|
|
|
-- no-tld
|
2022-07-22 07:38:37 +00:00
|
|
|
-- even if there is no TLD, 2-nd level by default anyway
|
|
|
|
-- FIXME: make this behavior optional (so that TLD for host never changed, either empty or something real)
|
|
|
|
select cutToFirstSignificantSubdomain('there-is-no-such-domain');
|
2021-03-21 07:55:28 +00:00
|
|
|
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomain('foo.there-is-no-such-domain');
|
2021-03-21 07:55:28 +00:00
|
|
|
foo.there-is-no-such-domain
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomain('bar.foo.there-is-no-such-domain');
|
2021-03-21 07:55:28 +00:00
|
|
|
foo.there-is-no-such-domain
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('there-is-no-such-domain', 'public_suffix_list');
|
2020-12-03 21:11:38 +00:00
|
|
|
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.there-is-no-such-domain', 'public_suffix_list');
|
2020-12-03 21:11:38 +00:00
|
|
|
foo.there-is-no-such-domain
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('bar.foo.there-is-no-such-domain', 'public_suffix_list');
|
2020-12-03 21:11:38 +00:00
|
|
|
foo.there-is-no-such-domain
|
2022-07-22 07:38:37 +00:00
|
|
|
select firstSignificantSubdomainCustom('bar.foo.there-is-no-such-domain', 'public_suffix_list');
|
2020-12-03 21:11:38 +00:00
|
|
|
foo
|
2022-07-22 07:38:37 +00:00
|
|
|
select '-- generic';
|
2021-03-21 07:55:28 +00:00
|
|
|
-- generic
|
2022-07-22 07:38:37 +00:00
|
|
|
select firstSignificantSubdomainCustom('foo.kernel.biz.ss', 'public_suffix_list'); -- kernel
|
2020-12-03 21:11:38 +00:00
|
|
|
kernel
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.kernel.biz.ss', 'public_suffix_list'); -- kernel.biz.ss
|
2020-12-03 21:11:38 +00:00
|
|
|
kernel.biz.ss
|
2022-07-22 07:38:37 +00:00
|
|
|
select '-- difference';
|
2021-03-21 07:55:28 +00:00
|
|
|
-- difference
|
2023-09-04 20:38:37 +00:00
|
|
|
-- dev.ss is not in the default TLD list, hence:
|
|
|
|
select cutToFirstSignificantSubdomain('foo.kernel.dev.ss'); -- dev.ss
|
|
|
|
dev.ss
|
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.kernel.dev.ss', 'public_suffix_list'); -- kernel.dev.ss
|
|
|
|
dev.ss
|
2022-07-22 07:38:37 +00:00
|
|
|
select '-- 3+level';
|
2021-03-21 07:55:28 +00:00
|
|
|
-- 3+level
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('xx.blogspot.co.at', 'public_suffix_list'); -- xx.blogspot.co.at
|
2021-03-21 07:55:28 +00:00
|
|
|
xx.blogspot.co.at
|
2022-07-22 07:38:37 +00:00
|
|
|
select firstSignificantSubdomainCustom('xx.blogspot.co.at', 'public_suffix_list'); -- blogspot
|
2021-03-21 07:55:28 +00:00
|
|
|
blogspot
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.bar.xx.blogspot.co.at', 'public_suffix_list'); -- xx.blogspot.co.at
|
2021-03-21 07:55:28 +00:00
|
|
|
xx.blogspot.co.at
|
2022-07-22 07:38:37 +00:00
|
|
|
select firstSignificantSubdomainCustom('foo.bar.xx.blogspot.co.at', 'public_suffix_list'); -- blogspot
|
2021-03-21 07:55:28 +00:00
|
|
|
blogspot
|
2022-07-22 07:38:37 +00:00
|
|
|
select '-- url';
|
2021-03-21 07:55:28 +00:00
|
|
|
-- url
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('http://foobar.com', 'public_suffix_list');
|
2021-03-21 07:55:28 +00:00
|
|
|
foobar.com
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('http://foobar.com/foo', 'public_suffix_list');
|
2021-03-21 07:55:28 +00:00
|
|
|
foobar.com
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('http://bar.foobar.com/foo', 'public_suffix_list');
|
2021-03-21 07:55:28 +00:00
|
|
|
foobar.com
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('http://xx.blogspot.co.at', 'public_suffix_list');
|
2021-03-21 07:55:28 +00:00
|
|
|
xx.blogspot.co.at
|
2022-07-22 07:38:37 +00:00
|
|
|
select '-- www';
|
2021-07-06 22:12:56 +00:00
|
|
|
-- www
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustomWithWWW('http://www.foo', 'public_suffix_list');
|
2021-07-06 22:12:56 +00:00
|
|
|
www.foo
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('http://www.foo', 'public_suffix_list');
|
2021-07-06 22:12:56 +00:00
|
|
|
foo
|
2022-07-22 07:38:37 +00:00
|
|
|
select '-- vector';
|
2021-07-06 22:12:56 +00:00
|
|
|
-- vector
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('http://xx.blogspot.co.at/' || toString(number), 'public_suffix_list') from numbers(1);
|
2021-07-06 22:12:56 +00:00
|
|
|
xx.blogspot.co.at
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('there-is-no-such-domain' || toString(number), 'public_suffix_list') from numbers(1);
|
2021-07-06 22:12:56 +00:00
|
|
|
|
2022-07-22 07:38:37 +00:00
|
|
|
select '-- no new line';
|
2021-08-26 21:43:21 +00:00
|
|
|
-- no new line
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.bar', 'no_new_line_list');
|
2021-08-26 21:43:21 +00:00
|
|
|
foo.bar
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('a.foo.bar', 'no_new_line_list');
|
2021-08-26 21:43:21 +00:00
|
|
|
a.foo.bar
|
2022-07-22 07:38:37 +00:00
|
|
|
select cutToFirstSignificantSubdomainCustom('a.foo.baz', 'no_new_line_list');
|
2021-08-26 21:43:21 +00:00
|
|
|
foo.baz
|
2022-07-22 07:36:50 +00:00
|
|
|
select '-- asterisk';
|
|
|
|
-- asterisk
|
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.something.sheffield.sch.uk', 'public_suffix_list');
|
|
|
|
something.sheffield.sch.uk
|
|
|
|
select cutToFirstSignificantSubdomainCustom('something.sheffield.sch.uk', 'public_suffix_list');
|
|
|
|
something.sheffield.sch.uk
|
|
|
|
select cutToFirstSignificantSubdomainCustom('sheffield.sch.uk', 'public_suffix_list');
|
|
|
|
sheffield.sch.uk
|
|
|
|
select '-- exclamation mark';
|
|
|
|
-- exclamation mark
|
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.kawasaki.jp', 'public_suffix_list');
|
|
|
|
foo.kawasaki.jp
|
|
|
|
select cutToFirstSignificantSubdomainCustom('foo.foo.kawasaki.jp', 'public_suffix_list');
|
|
|
|
foo.foo.kawasaki.jp
|
|
|
|
select cutToFirstSignificantSubdomainCustom('city.kawasaki.jp', 'public_suffix_list');
|
|
|
|
city.kawasaki.jp
|
|
|
|
select cutToFirstSignificantSubdomainCustom('some.city.kawasaki.jp', 'public_suffix_list');
|
|
|
|
city.kawasaki.jp
|
2022-10-25 17:18:32 +00:00
|
|
|
select '-- no-tld';
|
|
|
|
-- no-tld
|
|
|
|
-- even if there is no TLD, 2-nd level by default anyway
|
|
|
|
-- FIXME: make this behavior optional (so that TLD for host never changed, either empty or something real)
|
|
|
|
select cutToFirstSignificantSubdomainRFC('there-is-no-such-domain');
|
|
|
|
|
|
|
|
select cutToFirstSignificantSubdomainRFC('foo.there-is-no-such-domain');
|
|
|
|
foo.there-is-no-such-domain
|
|
|
|
select cutToFirstSignificantSubdomainRFC('bar.foo.there-is-no-such-domain');
|
|
|
|
foo.there-is-no-such-domain
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('there-is-no-such-domain', 'public_suffix_list');
|
|
|
|
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.there-is-no-such-domain', 'public_suffix_list');
|
|
|
|
foo.there-is-no-such-domain
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('bar.foo.there-is-no-such-domain', 'public_suffix_list');
|
|
|
|
foo.there-is-no-such-domain
|
|
|
|
select firstSignificantSubdomainCustomRFC('bar.foo.there-is-no-such-domain', 'public_suffix_list');
|
|
|
|
foo
|
|
|
|
select '-- generic';
|
|
|
|
-- generic
|
|
|
|
select firstSignificantSubdomainCustomRFC('foo.kernel.biz.ss', 'public_suffix_list'); -- kernel
|
|
|
|
kernel
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.kernel.biz.ss', 'public_suffix_list'); -- kernel.biz.ss
|
|
|
|
kernel.biz.ss
|
|
|
|
select '-- difference';
|
|
|
|
-- difference
|
2023-09-04 20:38:37 +00:00
|
|
|
-- dev.ss is not in the default TLD list, hence:
|
|
|
|
select cutToFirstSignificantSubdomainRFC('foo.kernel.dev.ss'); -- dev.ss
|
|
|
|
dev.ss
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.kernel.dev.ss', 'public_suffix_list'); -- kernel.dev.ss
|
|
|
|
dev.ss
|
2022-10-25 17:18:32 +00:00
|
|
|
select '-- 3+level';
|
|
|
|
-- 3+level
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('xx.blogspot.co.at', 'public_suffix_list'); -- xx.blogspot.co.at
|
|
|
|
xx.blogspot.co.at
|
|
|
|
select firstSignificantSubdomainCustomRFC('xx.blogspot.co.at', 'public_suffix_list'); -- blogspot
|
|
|
|
blogspot
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.bar.xx.blogspot.co.at', 'public_suffix_list'); -- xx.blogspot.co.at
|
|
|
|
xx.blogspot.co.at
|
|
|
|
select firstSignificantSubdomainCustomRFC('foo.bar.xx.blogspot.co.at', 'public_suffix_list'); -- blogspot
|
|
|
|
blogspot
|
|
|
|
select '-- url';
|
|
|
|
-- url
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('http://foobar.com', 'public_suffix_list');
|
|
|
|
foobar.com
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('http://foobar.com/foo', 'public_suffix_list');
|
|
|
|
foobar.com
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('http://bar.foobar.com/foo', 'public_suffix_list');
|
|
|
|
foobar.com
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('http://xx.blogspot.co.at', 'public_suffix_list');
|
|
|
|
xx.blogspot.co.at
|
|
|
|
select '-- www';
|
|
|
|
-- www
|
|
|
|
select cutToFirstSignificantSubdomainCustomWithWWWRFC('http://www.foo', 'public_suffix_list');
|
|
|
|
www.foo
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('http://www.foo', 'public_suffix_list');
|
|
|
|
foo
|
|
|
|
select '-- vector';
|
|
|
|
-- vector
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('http://xx.blogspot.co.at/' || toString(number), 'public_suffix_list') from numbers(1);
|
|
|
|
xx.blogspot.co.at
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('there-is-no-such-domain' || toString(number), 'public_suffix_list') from numbers(1);
|
|
|
|
|
|
|
|
select '-- no new line';
|
|
|
|
-- no new line
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.bar', 'no_new_line_list');
|
|
|
|
foo.bar
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('a.foo.bar', 'no_new_line_list');
|
|
|
|
a.foo.bar
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('a.foo.baz', 'no_new_line_list');
|
|
|
|
foo.baz
|
|
|
|
select '-- asterisk';
|
|
|
|
-- asterisk
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.something.sheffield.sch.uk', 'public_suffix_list');
|
|
|
|
something.sheffield.sch.uk
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('something.sheffield.sch.uk', 'public_suffix_list');
|
|
|
|
something.sheffield.sch.uk
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('sheffield.sch.uk', 'public_suffix_list');
|
|
|
|
sheffield.sch.uk
|
|
|
|
select '-- exclamation mark';
|
|
|
|
-- exclamation mark
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.kawasaki.jp', 'public_suffix_list');
|
|
|
|
foo.kawasaki.jp
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('foo.foo.kawasaki.jp', 'public_suffix_list');
|
|
|
|
foo.foo.kawasaki.jp
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('city.kawasaki.jp', 'public_suffix_list');
|
|
|
|
city.kawasaki.jp
|
|
|
|
select cutToFirstSignificantSubdomainCustomRFC('some.city.kawasaki.jp', 'public_suffix_list');
|
|
|
|
city.kawasaki.jp
|