Skip to content

Commit

Permalink
fix: correctly encode and decode base64 on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Satont committed Sep 18, 2023
1 parent cde34d0 commit 231af70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/dashboard/src/api/registry/overlays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { protectedApiClient } from '@/api/twirp';

function b64EncodeUnicode(str: string) {
return btoa(
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(_, p1) {
return String.fromCharCode(parseInt('0x' + p1));
}),
);
Expand Down
14 changes: 7 additions & 7 deletions frontend/overlays/src/pages/overlaysRegistry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ export const OverlaysRegistry: React.FC = () => {
};


function b64EncodeUnicode(str: string) {
return btoa(
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
return String.fromCharCode(parseInt('0x' + p1));
}),
);
}
// function b64EncodeUnicode(str: string) {
// return btoa(
// encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(_, p1) {
// return String.fromCharCode(parseInt('0x' + p1));
// }),
// );
// }

function b64DecodeUnicode(str: string) {
return decodeURIComponent(
Expand Down

0 comments on commit 231af70

Please sign in to comment.