Skip to content

Commit

Permalink
remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Sep 23, 2024
1 parent 700f8ec commit 3f8d65d
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions src/shared/utils/Encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,6 @@ export function arrayBufferToBase64(arrayBuffer: ArrayBufferLike): string {
return base64;
}

/**
* From: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
*/
export function base64Encode(str) {
// first we use encodeURIComponent to get percent-encoded UTF-8,
// then we convert the percent encodings into raw bytes which
// can be fed into btoa.
return btoa(
encodeURIComponent(str).replace(
/%([0-9A-F]{2})/g,
function toSolidBytes(_match, p1) {
return String.fromCharCode(('0x' as any) + p1);
},
),
);
}

export function base64Decode(str) {
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(
atob(str)
.split('')
.map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
})
.join(''),
);
}

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986
export function encodeRFC3986URIComponent(str: string): string {
return encodeURIComponent(str).replace(
Expand Down

0 comments on commit 3f8d65d

Please sign in to comment.