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
Notes: sideshowbarker 2024-07-17 11:33:34 +09:00
11 changed files with 44 additions and 39 deletions

View file

@ -1455,7 +1455,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
// true, set authorizationValue to httpRequests current URL, converted to an `Authorization` value.
else if (http_request->current_url().includes_credentials() && is_authentication_fetch == IsAuthenticationFetch::Yes) {
auto const& url = http_request->current_url();
auto payload = TRY_OR_THROW_OOM(vm, String::formatted("{}:{}", url.username(), url.password()));
auto payload = MUST(String::formatted("{}:{}", MUST(url.username()), MUST(url.password())));
authorization_value = TRY_OR_THROW_OOM(vm, encode_base64(payload.bytes()));
}
@ -1612,10 +1612,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
auto password = DeprecatedString::empty();
// 3. Set the username given requests current URL and username.
request->current_url().set_username(move(username));
MUST(request->current_url().set_username(username));
// 4. Set the password given requests current URL and password.
request->current_url().set_password(move(password));
MUST(request->current_url().set_password(password));
}
// 4. Set response to the result of running HTTP-network-or-cache fetch given fetchParams and true.