mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
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:
parent
b7c6af0a04
commit
522ef53b98
Notes:
sideshowbarker
2024-07-18 17:03:59 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/522ef53b981 Pull-request: https://github.com/SerenityOS/serenity/pull/7478 Reviewed-by: https://github.com/awesomekling
50
AK/URL.cpp
50
AK/URL.cpp
@ -50,8 +50,6 @@ String URL::path() const
|
|||||||
{
|
{
|
||||||
if (cannot_be_a_base_url())
|
if (cannot_be_a_base_url())
|
||||||
return paths()[0];
|
return paths()[0];
|
||||||
if (!m_path.is_null())
|
|
||||||
return m_path;
|
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
for (auto& path : m_paths) {
|
for (auto& path : m_paths) {
|
||||||
builder.append('/');
|
builder.append('/');
|
||||||
@ -102,12 +100,6 @@ void URL::set_port(const u16 port)
|
|||||||
m_valid = compute_validity();
|
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)
|
void URL::set_paths(const Vector<String>& paths)
|
||||||
{
|
{
|
||||||
m_paths = 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)
|
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 url;
|
||||||
url.set_scheme("file");
|
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);
|
url.set_fragment(fragment);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -262,16 +261,11 @@ String URL::serialize(ExcludeFragment exclude_fragment) const
|
|||||||
if (cannot_be_a_base_url()) {
|
if (cannot_be_a_base_url()) {
|
||||||
builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path));
|
builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path));
|
||||||
} else {
|
} else {
|
||||||
// FIXME: Temporary m_path hack
|
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
|
||||||
if (!m_path.is_null()) {
|
builder.append("/.");
|
||||||
builder.append(path());
|
for (auto& segment : m_paths) {
|
||||||
} else {
|
builder.append('/');
|
||||||
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
|
builder.append(percent_encode(segment, PercentEncodeSet::Path));
|
||||||
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()) {
|
if (cannot_be_a_base_url()) {
|
||||||
builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path));
|
builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path));
|
||||||
} else {
|
} else {
|
||||||
// FIXME: Temporary m_path hack
|
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
|
||||||
if (!m_path.is_null()) {
|
builder.append("/.");
|
||||||
builder.append(path());
|
for (auto& segment : m_paths) {
|
||||||
} else {
|
builder.append('/');
|
||||||
if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty())
|
builder.append(percent_encode(segment, PercentEncodeSet::Path));
|
||||||
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)
|
if (!m_valid)
|
||||||
return {};
|
return {};
|
||||||
// FIXME: Temporary m_path hack
|
|
||||||
if (!m_path.is_null())
|
|
||||||
return LexicalPath(m_path).basename();
|
|
||||||
if (m_paths.is_empty())
|
if (m_paths.is_empty())
|
||||||
return {};
|
return {};
|
||||||
return m_paths.last();
|
return m_paths.last();
|
||||||
|
1
AK/URL.h
1
AK/URL.h
@ -68,7 +68,6 @@ public:
|
|||||||
void set_password(const String&);
|
void set_password(const String&);
|
||||||
void set_host(const String&);
|
void set_host(const String&);
|
||||||
void set_port(const u16);
|
void set_port(const u16);
|
||||||
void set_path(const String&);
|
|
||||||
void set_paths(const Vector<String>&);
|
void set_paths(const Vector<String>&);
|
||||||
void set_query(const String&);
|
void set_query(const String&);
|
||||||
void set_fragment(const String&);
|
void set_fragment(const String&);
|
||||||
|
Loading…
Reference in New Issue
Block a user