1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-29 12:17:36 +00:00

AK: Port URL scheme from DeprecatedString to String

This commit is contained in:
Shannon Booth 2023-08-12 16:52:41 +12:00 committed by Andrew Kaster
parent 21fe86d235
commit c25485700a
16 changed files with 30 additions and 30 deletions

View file

@ -80,7 +80,7 @@ static DeprecatedString deprecated_string_percent_encode(DeprecatedString const&
return URL::percent_encode(input.view(), set, space_as_plus);
}
void URL::set_scheme(DeprecatedString scheme)
void URL::set_scheme(String scheme)
{
m_scheme = move(scheme);
m_valid = compute_validity();
@ -213,7 +213,7 @@ URL URL::create_with_file_scheme(DeprecatedString const& path, DeprecatedString
return {};
URL url;
url.set_scheme("file");
url.set_scheme("file"_string);
// NOTE: If the hostname is localhost (or null, which implies localhost), it should be set to the empty string.
// This is because a file URL always needs a non-null hostname.
url.set_host(hostname.is_null() || hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors());
@ -229,7 +229,7 @@ URL URL::create_with_help_scheme(DeprecatedString const& path, DeprecatedString
LexicalPath lexical_path(path);
URL url;
url.set_scheme("help");
url.set_scheme("help"_string);
// NOTE: If the hostname is localhost (or null, which implies localhost), it should be set to the empty string.
// This is because a file URL always needs a non-null hostname.
url.set_host(hostname.is_null() || hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors());
@ -255,7 +255,7 @@ URL URL::create_with_data(StringView mime_type, StringView payload, bool is_base
{
URL url;
url.set_cannot_be_a_base_url(true);
url.set_scheme("data"sv);
url.set_scheme("data"_string);
StringBuilder builder;
builder.append(mime_type);

View file

@ -76,7 +76,7 @@ public:
Yes,
No
};
DeprecatedString const& scheme() const { return m_scheme; }
String const& scheme() const { return m_scheme; }
ErrorOr<String> username() const;
ErrorOr<String> password() const;
Host const& host() const { return m_host; }
@ -97,7 +97,7 @@ public:
bool includes_credentials() const { return !m_username.is_empty() || !m_password.is_empty(); }
bool is_special() const { return is_special_scheme(m_scheme); }
void set_scheme(DeprecatedString);
void set_scheme(String);
ErrorOr<void> set_username(StringView);
ErrorOr<void> set_password(StringView);
void set_host(Host);
@ -163,7 +163,7 @@ private:
bool m_valid { false };
// A URLs scheme is an ASCII string that identifies the type of URL and can be used to dispatch a URL for further processing after parsing. It is initially the empty string.
DeprecatedString m_scheme;
String m_scheme;
// A URLs username is an ASCII string identifying a username. It is initially the empty string.
String m_username;

View file

@ -850,7 +850,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
}
// 2. Set urls scheme to buffer.
url->m_scheme = buffer.to_deprecated_string();
url->m_scheme = buffer.to_string().release_value_but_fixme_should_propagate_errors();
// 3. If state override is given, then:
if (state_override.has_value()) {
@ -1281,7 +1281,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
// -> file state, https://url.spec.whatwg.org/#file-state
case State::File:
// 1. Set urls scheme to "file".
url->m_scheme = "file";
url->m_scheme = String::from_utf8("file"sv).release_value_but_fixme_should_propagate_errors();
// 2. Set urls host to the empty string.
url->m_host = String {};