mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Port URL m_paths to String
This commit is contained in:
parent
e9670862a0
commit
ef27750982
Notes:
sideshowbarker
2024-07-17 01:23:08 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/ef27750982 Pull-request: https://github.com/SerenityOS/serenity/pull/21119 Reviewed-by: https://github.com/kemzeb
3 changed files with 10 additions and 10 deletions
|
@ -113,13 +113,13 @@ void URL::set_paths(Vector<DeprecatedString> const& paths)
|
|||
m_paths.clear_with_capacity();
|
||||
m_paths.ensure_capacity(paths.size());
|
||||
for (auto const& segment : paths)
|
||||
m_paths.unchecked_append(percent_encode(segment, PercentEncodeSet::Path));
|
||||
m_paths.unchecked_append(String::from_deprecated_string(percent_encode(segment, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors());
|
||||
m_valid = compute_validity();
|
||||
}
|
||||
|
||||
void URL::append_path(StringView path)
|
||||
{
|
||||
m_paths.append(percent_encode(path, PercentEncodeSet::Path));
|
||||
m_paths.append(String::from_deprecated_string(percent_encode(path, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
|
||||
|
@ -253,7 +253,7 @@ DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding
|
|||
// 1. If url has an opaque path, then return url’s path.
|
||||
// FIXME: Reimplement this step once we modernize the URL implementation to meet the spec.
|
||||
if (cannot_be_a_base_url())
|
||||
return m_paths[0];
|
||||
return m_paths[0].to_deprecated_string();
|
||||
|
||||
// 2. Let output be the empty string.
|
||||
StringBuilder output;
|
||||
|
@ -261,7 +261,7 @@ DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding
|
|||
// 3. For each segment of url’s path: append U+002F (/) followed by segment to output.
|
||||
for (auto const& segment : m_paths) {
|
||||
output.append('/');
|
||||
output.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(segment) : segment);
|
||||
output.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(segment) : segment.to_deprecated_string());
|
||||
}
|
||||
|
||||
// 4. Return output.
|
||||
|
|
4
AK/URL.h
4
AK/URL.h
|
@ -104,7 +104,7 @@ public:
|
|||
void append_slash()
|
||||
{
|
||||
// NOTE: To indicate that we want to end the path with a slash, we have to append an empty path segment.
|
||||
m_paths.append("");
|
||||
m_paths.append(String {});
|
||||
}
|
||||
|
||||
enum class ApplyPercentDecoding {
|
||||
|
@ -177,7 +177,7 @@ private:
|
|||
|
||||
// A URL’s path is either a URL path segment or a list of zero or more URL path segments, usually identifying a location. It is initially « ».
|
||||
// A URL path segment is an ASCII string. It commonly refers to a directory or a file, but has no predefined meaning.
|
||||
Vector<DeprecatedString> m_paths;
|
||||
Vector<String> m_paths;
|
||||
|
||||
// A URL’s query is either null or an ASCII string. It is initially null.
|
||||
Optional<String> m_query;
|
||||
|
|
|
@ -1523,7 +1523,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
buffer.append(':');
|
||||
}
|
||||
// 2. Append buffer to url’s path.
|
||||
url->m_paths.append(buffer.string_view());
|
||||
url->m_paths.append(buffer.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
// 5. Set buffer to the empty string.
|
||||
|
@ -1561,7 +1561,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
|
||||
// 1. If c is U+003F (?), then set url’s query to the empty string and state to query state.
|
||||
if (code_point == '?') {
|
||||
url->m_paths[0] = buffer.string_view();
|
||||
url->m_paths[0] = buffer.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
url->m_query = String {};
|
||||
buffer.clear();
|
||||
state = State::Query;
|
||||
|
@ -1569,7 +1569,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
// 2. Otherwise, if c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
|
||||
else if (code_point == '#') {
|
||||
// NOTE: This needs to be percent decoded since the member variables contain decoded data.
|
||||
url->m_paths[0] = buffer.string_view();
|
||||
url->m_paths[0] = buffer.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
url->m_fragment = String {};
|
||||
buffer.clear();
|
||||
state = State::Fragment;
|
||||
|
@ -1588,7 +1588,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
if (code_point != end_of_file) {
|
||||
URL::append_percent_encoded_if_necessary(buffer, code_point, URL::PercentEncodeSet::C0Control);
|
||||
} else {
|
||||
url->m_paths[0] = buffer.string_view();
|
||||
url->m_paths[0] = buffer.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
buffer.clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue