Skip to content

Commit

Permalink
$mol_base64_decode: safe support
Browse files Browse the repository at this point in the history
  • Loading branch information
jin committed Nov 4, 2023
1 parent 9d90e9f commit 1b1d0de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base64/decode/decode.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace $ {
export function $mol_base64_decode_node(base64Str: string): Uint8Array {

base64Str = base64Str.replace( /-/g, '+' ).replace( /_/g, '/' )

// without Uint8Array breaks $mol_compare_deep
const buffer = Buffer.from(base64Str, 'base64')

Expand Down
1 change: 1 addition & 0 deletions base64/decode/decode.web.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace $ {

export function $mol_base64_decode_web(base64Str: string): Uint8Array {
base64Str = base64Str.replace( /-/g, '+' ).replace( /_/g, '/' )
return new Uint8Array($mol_dom_context.atob(base64Str).split('').map(c => c.charCodeAt(0)))
}

Expand Down

0 comments on commit 1b1d0de

Please sign in to comment.