mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWebView: Wrap retrieving public suffix data in a helper
This lets outside callers use this API but primarily is to fix the build when the ENABLE_PUBLIC_SUFFIX_DOWNLOAD CMake option is disabled.
This commit is contained in:
parent
b4296e1c9b
commit
ae3e0d97b5
Notes:
sideshowbarker
2024-07-16 20:21:48 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/ae3e0d97b5 Pull-request: https://github.com/SerenityOS/serenity/pull/21515
2 changed files with 11 additions and 4 deletions
|
@ -26,7 +26,6 @@ static Optional<URL> query_public_suffix_list(StringView url_string)
|
|||
if (!url.is_valid())
|
||||
return {};
|
||||
|
||||
#if defined(ENABLE_PUBLIC_SUFFIX)
|
||||
if (url.host().has<URL::IPv4Address>() || url.host().has<URL::IPv6Address>())
|
||||
return url;
|
||||
|
||||
|
@ -36,7 +35,7 @@ static Optional<URL> query_public_suffix_list(StringView url_string)
|
|||
if (url.host().has<String>()) {
|
||||
auto const& host = url.host().get<String>();
|
||||
|
||||
if (auto public_suffix = MUST(PublicSuffixData::the()->get_public_suffix(host)); public_suffix.has_value())
|
||||
if (auto public_suffix = get_public_suffix(host); public_suffix.has_value())
|
||||
return url;
|
||||
|
||||
if (host.ends_with_bytes(".local"sv) || host.ends_with_bytes("localhost"sv))
|
||||
|
@ -44,8 +43,14 @@ static Optional<URL> query_public_suffix_list(StringView url_string)
|
|||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<String> get_public_suffix([[maybe_unused]] StringView host)
|
||||
{
|
||||
#if defined(ENABLE_PUBLIC_SUFFIX)
|
||||
return MUST(PublicSuffixData::the()->get_public_suffix(host));
|
||||
#else
|
||||
return url;
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -95,7 +100,7 @@ static URLParts break_web_url_into_parts(URL const& url, StringView url_string)
|
|||
{
|
||||
auto host = MUST(url.serialized_host());
|
||||
|
||||
auto public_suffix = MUST(PublicSuffixData::the()->get_public_suffix(host));
|
||||
auto public_suffix = get_public_suffix(host);
|
||||
if (!public_suffix.has_value())
|
||||
return {};
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace WebView {
|
||||
|
||||
Optional<String> get_public_suffix(StringView host);
|
||||
|
||||
enum class AppendTLD {
|
||||
No,
|
||||
Yes,
|
||||
|
|
Loading…
Reference in a new issue