mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
AK: Port URL::m_fragment from DeprecatedString to String
This commit is contained in:
parent
5663a2d3b4
commit
9d60f23abc
21 changed files with 68 additions and 76 deletions
24
AK/URL.cpp
24
AK/URL.cpp
|
@ -62,11 +62,6 @@ DeprecatedString URL::basename() const
|
|||
return percent_decode(last_segment);
|
||||
}
|
||||
|
||||
DeprecatedString URL::fragment() const
|
||||
{
|
||||
return m_fragment;
|
||||
}
|
||||
|
||||
// NOTE: This only exists for compatibility with the existing URL tests which check for both .is_null() and .is_empty().
|
||||
static DeprecatedString deprecated_string_percent_encode(DeprecatedString const& input, URL::PercentEncodeSet set = URL::PercentEncodeSet::Userinfo, URL::SpaceAsPlus space_as_plus = URL::SpaceAsPlus::No)
|
||||
{
|
||||
|
@ -135,11 +130,6 @@ void URL::append_path(StringView path)
|
|||
m_paths.append(deprecated_string_percent_encode(path, PercentEncodeSet::Path));
|
||||
}
|
||||
|
||||
void URL::set_fragment(StringView fragment)
|
||||
{
|
||||
m_fragment = fragment;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
|
||||
bool URL::cannot_have_a_username_or_password_or_port() const
|
||||
{
|
||||
|
@ -215,7 +205,8 @@ URL URL::create_with_file_scheme(DeprecatedString const& path, DeprecatedString
|
|||
url.set_paths(lexical_path.parts());
|
||||
if (path.ends_with('/'))
|
||||
url.append_slash();
|
||||
url.set_fragment(fragment);
|
||||
if (!fragment.is_null())
|
||||
url.set_fragment(String::from_deprecated_string(fragment).release_value_but_fixme_should_propagate_errors());
|
||||
return url;
|
||||
}
|
||||
|
||||
|
@ -232,7 +223,8 @@ URL URL::create_with_help_scheme(DeprecatedString const& path, DeprecatedString
|
|||
url.set_paths(lexical_path.parts());
|
||||
if (path.ends_with('/'))
|
||||
url.append_slash();
|
||||
url.set_fragment(fragment);
|
||||
if (!fragment.is_null())
|
||||
url.set_fragment(String::from_deprecated_string(fragment).release_value_but_fixme_should_propagate_errors());
|
||||
return url;
|
||||
}
|
||||
|
||||
|
@ -337,9 +329,9 @@ DeprecatedString URL::serialize(ExcludeFragment exclude_fragment) const
|
|||
}
|
||||
|
||||
// 6. If exclude fragment is false and url’s fragment is non-null, then append U+0023 (#), followed by url’s fragment, to output.
|
||||
if (exclude_fragment == ExcludeFragment::No && !m_fragment.is_null()) {
|
||||
if (exclude_fragment == ExcludeFragment::No && m_fragment.has_value()) {
|
||||
output.append('#');
|
||||
output.append(m_fragment);
|
||||
output.append(*m_fragment);
|
||||
}
|
||||
|
||||
// 7. Return output.
|
||||
|
@ -381,9 +373,9 @@ DeprecatedString URL::serialize_for_display() const
|
|||
builder.append(*m_query);
|
||||
}
|
||||
|
||||
if (!m_fragment.is_null()) {
|
||||
if (m_fragment.has_value()) {
|
||||
builder.append('#');
|
||||
builder.append(m_fragment);
|
||||
builder.append(*m_fragment);
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue