From f6519073d05d7269d16f2d63016e80bb81a2ccc0 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 21 Apr 2021 02:00:13 +0200 Subject: [PATCH] Small workaround if data is already parsed, fix #249 --- index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index d145cd1ae..e5383347c 100644 --- a/index.ts +++ b/index.ts @@ -84,13 +84,17 @@ if (layoutFromBase64.startsWith("http")) { success: (data) => { try { - const parsed = JSON.parse(data); + console.log("Received ", data) + let parsed = data; + if(typeof parsed == "string"){ + parsed = JSON.parse(data); + } // Overwrite the id to the wiki:value parsed.id = link; const layout = new LayoutConfig(parsed, false); InitUiElements.InitAll(layout, layoutFromBase64, testing, layoutFromBase64, btoa(data)); } catch (e) { - new FixedUiElement(`${link} is invalid:
${e}
Go back")`) + new FixedUiElement(`${link} is invalid:
${e}
Go back`) .SetClass("clickable") .AttachTo("centermessage"); console.error("Could not parse the text", data)