LibURL: Remove the implicit URL constructors

All URLs are now either constucted through the URL Parser or by
default constructing a URL, and setting each of the fields of that
URL manually. This makes it much more difficult to create invalid
URLs.
This commit is contained in:
Shannon Booth 2025-02-22 21:52:44 +13:00 committed by Tim Flynn
commit de89f5af6d
Notes: github-actions[bot] 2025-03-04 21:25:54 +00:00
2 changed files with 2 additions and 22 deletions

View file

@ -2,6 +2,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>
* Copyright (c) 2023-2025, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -21,18 +22,6 @@
namespace URL {
// FIXME: It could make sense to force users of URL to use URL::Parser::basic_parse() explicitly instead of using a constructor.
URL::URL(StringView string)
: URL(Parser::basic_parse(string).value_or(URL {}))
{
if constexpr (URL_PARSER_DEBUG) {
if (m_data->valid)
dbgln("URL constructor: Parsed URL to be '{}'.", serialize());
else
dbgln("URL constructor: Parsed URL to be invalid.");
}
}
Optional<URL> URL::complete_url(StringView relative_url) const
{
if (!is_valid())