From f483262b7dedcc422effc63b81b23bcc4f4ff0f3 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Wed, 23 Aug 2023 19:26:42 +0200 Subject: [PATCH] base64 --- src/main.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index da80637..ab42b5f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -578,8 +578,9 @@ export class Editor { if (url !== null) { const universeParam = url.get("universe"); if (universeParam !== null) { - new_universe = JSON.parse(universeParam); + new_universe = JSON.parse(atob(universeParam)); this.loadUniverse("imported", new_universe["universe"]); + this.emptyUrl(); } } } @@ -610,13 +611,15 @@ export class Editor { }; parseHash = (hash: string) => { - return JSON.parse(atob(hash)); + return JSON.parse(hash); }; share() { - const hashed_table = JSON.stringify({ - universe: this.settings.universes[this.selected_universe], - }); + const hashed_table = btoa(JSON.stringify( + { + universe: this.settings.universes[this.selected_universe], + } + )); const url = new URL(window.location.href); url.searchParams.set("universe", hashed_table); window.history.replaceState({}, "", url.toString());