1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:37:45 +00:00

AK: Port URL username/password from DeprecatedString to String

And for cases that just need to check whether the password/username is
empty, add a raw_{password,username} helper to avoid any allocation.
This commit is contained in:
Shannon Booth 2023-08-12 16:52:38 +12:00 committed by Andrew Kaster
parent 6b29dc3e46
commit 55a01e72ca
11 changed files with 44 additions and 39 deletions

View file

@ -77,8 +77,8 @@ public:
No
};
DeprecatedString const& scheme() const { return m_scheme; }
DeprecatedString username() const;
DeprecatedString password() const;
ErrorOr<String> username() const;
ErrorOr<String> password() const;
Host const& host() const { return m_host; }
ErrorOr<String> serialized_host() const;
DeprecatedString basename() const;
@ -98,8 +98,8 @@ public:
bool is_special() const { return is_special_scheme(m_scheme); }
void set_scheme(DeprecatedString);
void set_username(StringView);
void set_password(StringView);
ErrorOr<void> set_username(StringView);
ErrorOr<void> set_password(StringView);
void set_host(Host);
void set_port(Optional<u16>);
void set_paths(Vector<DeprecatedString> const&);
@ -151,6 +151,9 @@ public:
static bool code_point_is_in_percent_encode_set(u32 code_point, URL::PercentEncodeSet);
String const& raw_username() const { return m_username; }
String const& raw_password() const { return m_password; }
private:
bool compute_validity() const;
@ -163,10 +166,10 @@ private:
DeprecatedString m_scheme;
// A URLs username is an ASCII string identifying a username. It is initially the empty string.
DeprecatedString m_username;
String m_username;
// A URLs password is an ASCII string identifying a password. It is initially the empty string.
DeprecatedString m_password;
String m_password;
// A URLs host is null or a host. It is initially null.
Host m_host;