LibURL+LibWebView: Move public suffix data to LibURL

This commit is contained in:
Sam Atkins 2024-11-26 16:27:08 +00:00 committed by Andreas Kling
parent edcdcea92d
commit 3124dca528
Notes: github-actions[bot] 2024-11-30 11:24:22 +00:00
10 changed files with 36 additions and 36 deletions

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
* Copyright (c) 2024, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -14,6 +15,10 @@
#include <LibURL/Parser.h>
#include <LibURL/URL.h>
#if defined(ENABLE_PUBLIC_SUFFIX)
# include <LibURL/PublicSuffixData.h>
#endif
namespace URL {
// FIXME: It could make sense to force users of URL to use URL::Parser::basic_parse() explicitly instead of using a constructor.
@ -498,4 +503,22 @@ ByteString percent_decode(StringView input)
return builder.to_byte_string();
}
bool is_public_suffix([[maybe_unused]] StringView host)
{
#if defined(ENABLE_PUBLIC_SUFFIX)
return PublicSuffixData::the()->is_public_suffix(host);
#else
return false;
#endif
}
Optional<String> get_public_suffix([[maybe_unused]] StringView host)
{
#if defined(ENABLE_PUBLIC_SUFFIX)
return MUST(PublicSuffixData::the()->get_public_suffix(host));
#else
return {};
#endif
}
}