mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-15 05:22:04 +00:00
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:
parent
e6ecafea84
commit
a2b523eeb8
Notes:
github-actions[bot]
2025-06-29 11:49:11 +00:00
Author: https://github.com/shannonbooth
Commit: a2b523eeb8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5242
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 9 additions and 13 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibURL/PublicSuffixData.h>
|
||||
#include <LibWebView/URL.h>
|
||||
|
||||
namespace WebView {
|
||||
|
@ -61,7 +62,7 @@ Optional<URL::URL> sanitize_url(StringView location, Optional<SearchEngine> cons
|
|||
if (any_of(RESERVED_TLDS, [&](StringView const& tld) { return domain.byte_count() > tld.length() && domain.ends_with_bytes(tld); }))
|
||||
return url;
|
||||
|
||||
auto public_suffix = URL::get_public_suffix(domain);
|
||||
auto public_suffix = URL::PublicSuffixData::the()->get_public_suffix(domain);
|
||||
if (!public_suffix.has_value() || *public_suffix == domain) {
|
||||
if (append_tld == AppendTLD::Yes)
|
||||
url->set_host(MUST(String::formatted("{}.com", domain)));
|
||||
|
@ -120,7 +121,7 @@ static URLParts break_web_url_into_parts(URL::URL const& url, StringView url_str
|
|||
domain = url_without_scheme;
|
||||
}
|
||||
|
||||
auto public_suffix = URL::get_public_suffix(domain);
|
||||
auto public_suffix = URL::PublicSuffixData::the()->get_public_suffix(domain);
|
||||
if (!public_suffix.has_value() || !domain.ends_with(*public_suffix))
|
||||
return { scheme, domain, remainder };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue