Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
markwylde committed Dec 4, 2023
1 parent 059cce8 commit 25b1b3c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/utils/decode_base64.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
export function decodeBase64(b64: string): Uint8Array {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
let base64 = b64.replace(/-/g, '+').replace(/_/g, '/');
const chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
let base64 = b64.replace(/-/g, "+").replace(/_/g, "/");

while (base64.length % 4) {
base64 += '=';
base64 += "=";
}

let bitString = '';
let bitString = "";
for (let i = 0; i < base64.length; i++) {
const char = base64.charAt(i);
if (char !== '=') {
const charIndex = chars.indexOf(char);
bitString += charIndex.toString(2).padStart(6, '0');
}
const char = base64.charAt(i);
if (char !== "=") {
const charIndex = chars.indexOf(char);
bitString += charIndex.toString(2).padStart(6, "0");
}
}

const bytes = new Uint8Array(bitString.length / 8);
for (let i = 0; i < bytes.length; i++) {
bytes[i] = parseInt(bitString.substring(8 * i, 8 * (i + 1)), 2);
bytes[i] = parseInt(bitString.substring(8 * i, 8 * (i + 1)), 2);
}

return bytes;
Expand Down

0 comments on commit 25b1b3c

Please sign in to comment.