Skip to content

Commit

Permalink
Fixed base64 conversion problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Apr 18, 2024
1 parent f9a6425 commit 834aa77
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions DupeNukem/Script.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ var __dupeNukem_Messenger__ =
};

this.constructArray__ = arr => {
const base64 = btoa(new TextDecoder().decode(arr));
// https://developer.mozilla.org/en-US/docs/Glossary/Base64
const base64 = btoa(Array.from(arr, byte => String.fromCodePoint(byte)).join(""));
return {
__type__: "byteArray",
__body__: base64
Expand Down Expand Up @@ -163,7 +164,8 @@ var __dupeNukem_Messenger__ =
case "byteArray":
if (obj.__body__ !== null) {
const base64 = obj.__body__;
const arr = new TextEncoder().encode(atob(base64));
// https://developer.mozilla.org/en-US/docs/Glossary/Base64
const arr = Uint8Array.from(atob(base64), m => m.codePointAt(0));
return arr.buffer;
} else {
return null;
Expand Down

0 comments on commit 834aa77

Please sign in to comment.