1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +00:00

AK: Port percent_encode_after_encoding to String

This commit is contained in:
Shannon Booth 2023-08-14 18:49:23 +12:00 committed by Andrew Kaster
parent cb4c279e90
commit 50d8ef94ba
3 changed files with 7 additions and 7 deletions

View file

@ -670,7 +670,7 @@ constexpr bool is_double_dot_path_segment(StringView input)
}
// https://url.spec.whatwg.org/#string-percent-encode-after-encoding
DeprecatedString URLParser::percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus)
ErrorOr<String> URLParser::percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus)
{
// NOTE: This is written somewhat ad-hoc since we don't yet implement the Encoding spec.
@ -701,7 +701,7 @@ DeprecatedString URLParser::percent_encode_after_encoding(StringView input, URL:
}
// 6. Return output.
return output.to_deprecated_string();
return output.to_string();
}
// https://url.spec.whatwg.org/#concept-basic-url-parser
@ -1597,7 +1597,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
auto query_percent_encode_set = url->is_special() ? URL::PercentEncodeSet::SpecialQuery : URL::PercentEncodeSet::Query;
// 2. Percent-encode after encoding, with encoding, buffer, and queryPercentEncodeSet, and append the result to urls query.
url->m_query = String::from_deprecated_string(percent_encode_after_encoding(buffer.string_view(), query_percent_encode_set)).release_value_but_fixme_should_propagate_errors();
url->m_query = percent_encode_after_encoding(buffer.string_view(), query_percent_encode_set).release_value_but_fixme_should_propagate_errors();
// 3. Set buffer to the empty string.
buffer.clear();
@ -1639,7 +1639,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
// NOTE: The percent-encode is done on EOF on the entire buffer.
buffer.append_code_point(code_point);
} else {
url->m_fragment = String::from_deprecated_string(percent_encode_after_encoding(buffer.string_view(), URL::PercentEncodeSet::Fragment)).release_value_but_fixme_should_propagate_errors();
url->m_fragment = percent_encode_after_encoding(buffer.string_view(), URL::PercentEncodeSet::Fragment).release_value_but_fixme_should_propagate_errors();
buffer.clear();
}
break;