Skip to content

Commit 2faa05f

Browse files
committed
Normalize base64 input to accept both default and URL-safe encoding
1 parent e2beba1 commit 2faa05f

5 files changed

Lines changed: 9 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bun.lockb

60.2 KB
Binary file not shown.

src/common/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export const zeroPad = (num: number, places: number) => {
3535
return Array(+(zero > 0 && zero)).join('0') + num;
3636
};
3737

38+
export const normalizeBase64 = (base64str: string) => {
39+
return base64str.replace(/_/g, '/').replace(/-/g, '+');
40+
};
41+
3842
const BLOB_PART = /\/blob\//;
3943
const EVERSCAN_CONTRACT_PATH = /^\/contracts\/([0-9a-fA-F]{64})\/?$/;
4044
export const rewriteAbiUrl = (address: URL) => {

src/components/DeserializerWorkspace.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { ref, shallowRef, watch, watchEffect } from 'vue';
33
import * as core from '@core';
44
5-
import { convertError } from '../common';
5+
import { convertError, normalizeBase64 } from '../common';
66
import { useTvmConnect } from '../providers/useTvmConnect';
77
88
enum Tabs {
@@ -60,7 +60,7 @@ watchEffect(() => {
6060
watch([bocInput, abiState, partial, selectedStructure], async ([bocInput, { abi }, partial, selectedStructure], _, onCleanup) => {
6161
if (activeTab.value === Tabs.BlockStructures) {
6262
try {
63-
let r = JSON.parse(core.deserialize(bocInput, selectedStructure));
63+
let r = JSON.parse(core.deserialize(normalizeBase64(bocInput), selectedStructure));
6464
bocState.value = {
6565
decoded: JSON.stringify(r, (key, value) =>
6666
typeof value === 'bigint'

src/components/VisualizerWorkspace.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { ref } from 'vue';
33
import * as core from '@core';
4+
import { normalizeBase64 } from "../common"
45
56
const input = ref('');
67
const state = ref({ decoded: undefined, error: undefined });
@@ -9,7 +10,7 @@ const decode = (e: Event) => {
910
const boc = (e.target as HTMLInputElement).value;
1011
try {
1112
state.value = {
12-
decoded: core.visualize(boc),
13+
decoded: core.visualize(normalizeBase64(boc)),
1314
error: undefined
1415
};
1516
} catch (e: any) {

0 commit comments

Comments
 (0)