mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +00:00
LibURL+LibWebView: Move public suffix data to LibURL
This commit is contained in:
parent
edcdcea92d
commit
3124dca528
Notes:
github-actions[bot]
2024-11-30 11:24:22 +00:00
Author: https://github.com/AtkinsSJ
Commit: 3124dca528
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2610
Reviewed-by: https://github.com/shannonbooth ✅
10 changed files with 36 additions and 36 deletions
|
@ -1,8 +1,12 @@
|
|||
include(public_suffix)
|
||||
|
||||
set(SOURCES
|
||||
Origin.cpp
|
||||
Parser.cpp
|
||||
URL.cpp
|
||||
${PUBLIC_SUFFIX_SOURCES}
|
||||
)
|
||||
|
||||
serenity_lib(LibURL url)
|
||||
target_link_libraries(LibURL PRIVATE LibUnicode LibTextCodec)
|
||||
target_compile_definitions(LibURL PRIVATE ENABLE_PUBLIC_SUFFIX=$<BOOL:${ENABLE_PUBLIC_SUFFIX_DOWNLOAD}>)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -199,6 +199,9 @@ URL create_with_url_or_path(ByteString const&);
|
|||
URL create_with_file_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {});
|
||||
URL create_with_data(StringView mime_type, StringView payload, bool is_base64 = false);
|
||||
|
||||
bool is_public_suffix(StringView host);
|
||||
Optional<String> get_public_suffix(StringView host);
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue