mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +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
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
|
||||
* Copyright (c) 2023-2024, Shannon Booth <shannon@serenityos.org>
|
||||
* Copyright (c) 2023-2025, Shannon Booth <shannon@serenityos.org>
|
||||
* Copyright (c) 2024, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibURL/Host.h>
|
||||
#include <LibURL/PublicSuffixData.h>
|
||||
#include <LibURL/URL.h>
|
||||
|
||||
namespace URL {
|
||||
|
@ -193,7 +194,7 @@ Optional<String> Host::public_suffix() const
|
|||
// 3. Let publicSuffix be the public suffix determined by running the Public Suffix List algorithm with host as domain. [PSL]
|
||||
// NOTE: The spec algorithm for the public suffix returns "*" by default, but get_public_suffix() returns an empty Optional.
|
||||
// Remove the `value_or()` if and when we update it.
|
||||
auto public_suffix = get_public_suffix(host_string.bytes_as_string_view()).value_or("*"_string);
|
||||
auto public_suffix = PublicSuffixData::the()->get_public_suffix(host_string).value_or("*"_string);
|
||||
|
||||
// 4. Assert: publicSuffix is an ASCII string that does not end with ".".
|
||||
VERIFY(public_suffix.is_ascii());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue