AK: Remove deprecated m_path member variable from URL

The m_path member variable has been superseded by m_paths. Thus, it has
been removed. The path() getter will continue to exist as a convenience
method for getting the path joined together as a string.
This commit is contained in:
Max Wipfli 2021-05-27 21:40:02 +02:00 committed by Andreas Kling
parent b7c6af0a04
commit 522ef53b98
Notes: sideshowbarker 2024-07-18 17:03:59 +09:00
2 changed files with 18 additions and 33 deletions

View File

@ -50,8 +50,6 @@ String URL::path() const
{
if (cannot_be_a_base_url())
return paths()[0];
if (!m_path.is_null())
return m_path;
StringBuilder builder;
for (auto& path : m_paths) {
builder.append('/');
@ -102,12 +100,6 @@ void URL::set_port(const u16 port)
m_valid = compute_validity();
}
void URL::set_path(const String& path)
{
m_path = path;
m_valid = compute_validity();
}
void URL::set_paths(const Vector<String>& paths)
{
m_paths = paths;
@ -180,9 +172,16 @@ u16 URL::default_port_for_scheme(const StringView& scheme)
URL URL::create_with_file_scheme(const String& path, const String& fragment)
{
LexicalPath lexical_path(path);
if (!lexical_path.is_valid() || !lexical_path.is_absolute())
return {};
URL url;
url.set_scheme("file");
url.set_path(path);
url.set_host(String::empty());
url.set_paths(lexical_path.parts());
// NOTE: To indicate that we want to end the path with a slash, we have to append an empty path segment.
if (path.ends_with('/'))
url.append_path("");
url.set_fragment(fragment);
return url;
}
@ -262,16 +261,11 @@ String URL::serialize(ExcludeFragment exclude_fragment) const
if (cannot_be_a_base_url()) {
builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path));
} else {
// FIXME: Temporary m_path hack
if (!m_path.is_null()) {
builder.append(path());
} else {
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
builder.append("/.");
for (auto& segment : m_paths) {
builder.append('/');
builder.append(percent_encode(segment, PercentEncodeSet::Path));
}
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
builder.append("/.");
for (auto& segment : m_paths) {
builder.append('/');
builder.append(percent_encode(segment, PercentEncodeSet::Path));
}
}
@ -311,16 +305,11 @@ String URL::serialize_for_display() const
if (cannot_be_a_base_url()) {
builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path));
} else {
// FIXME: Temporary m_path hack
if (!m_path.is_null()) {
builder.append(path());
} else {
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
builder.append("/.");
for (auto& segment : m_paths) {
builder.append('/');
builder.append(percent_encode(segment, PercentEncodeSet::Path));
}
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
builder.append("/.");
for (auto& segment : m_paths) {
builder.append('/');
builder.append(percent_encode(segment, PercentEncodeSet::Path));
}
}
@ -348,9 +337,6 @@ String URL::basename() const
{
if (!m_valid)
return {};
// FIXME: Temporary m_path hack
if (!m_path.is_null())
return LexicalPath(m_path).basename();
if (m_paths.is_empty())
return {};
return m_paths.last();

View File

@ -68,7 +68,6 @@ public:
void set_password(const String&);
void set_host(const String&);
void set_port(const u16);
void set_path(const String&);
void set_paths(const Vector<String>&);
void set_query(const String&);
void set_fragment(const String&);