LibURL: Replace use of URL::get_public_suffix

It is confusing to have both URL::Host::public_suffix and
URL:get_public_suffix, both with slightly different semantics.

Instead, use PublicSuffixData for cases that just want a direct
match against the list, and URL::Host::public_suffix in LibWeb
land as the URL spec defined AO.
This commit is contained in:
Shannon Booth 2025-06-28 21:05:42 +12:00 committed by Tim Ledbetter
parent e6ecafea84
commit a2b523eeb8
Notes: github-actions[bot] 2025-06-29 11:49:11 +00:00
5 changed files with 9 additions and 13 deletions

View file

@ -496,16 +496,11 @@ bool is_public_suffix(StringView host)
return PublicSuffixData::the()->is_public_suffix(host);
}
Optional<String> get_public_suffix(StringView host)
{
return PublicSuffixData::the()->get_public_suffix(host);
}
// https://github.com/publicsuffix/list/wiki/Format#algorithm
Optional<String> get_registrable_domain(StringView host)
{
// The registered or registrable domain is the public suffix plus one additional label.
auto public_suffix = get_public_suffix(host);
auto public_suffix = PublicSuffixData::the()->get_public_suffix(host);
if (!public_suffix.has_value() || !host.ends_with(*public_suffix))
return {};