Skip to content

Commit

Permalink
Fixes error handling in core Base64 to Uint8Array converter (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
amorey authored Oct 23, 2024
1 parent fd72d1a commit 785f622
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shared/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export function utoa(input: Uint8Array): string {

/**
* Decode base64 string into Uint8Array
* @param {string} input - The data to be converted from base64 to Uint8Array
* @param {string} inputB64 - The data to be converted from base64 to Uint8Array
*/
export function atou(inputB64: string): Uint8Array {
let inputStr: string;

try {
inputStr = atob(inputB64);
} catch (error: unknown) {
if (error instanceof DOMException && error.name === 'InvalidCharacterError') {
if (error instanceof Error && error.name === 'InvalidCharacterError') {
return new Uint8Array();
}
throw error;
Expand Down

0 comments on commit 785f622

Please sign in to comment.