mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
AK+Userland: Make AK::decode_base64 return ErrorOr
This commit is contained in:
parent
f590cd1850
commit
c388a879d7
11 changed files with 31 additions and 43 deletions
|
@ -340,7 +340,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::atob)
|
|||
return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::BadArgCountOne, "atob");
|
||||
auto string = TRY(vm.argument(0).to_string(global_object));
|
||||
auto decoded = decode_base64(StringView(string));
|
||||
if (!decoded.has_value())
|
||||
if (decoded.is_error())
|
||||
return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::InvalidFormat, "Base64");
|
||||
|
||||
// decode_base64() returns a byte string. LibJS uses UTF-8 for strings. Use Latin1Decoder to convert bytes 128-255 to UTF-8.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue