From 8f4e15666a9118641d2ff6c81bb88ede0248dd2b Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sat, 15 Jan 2022 13:13:11 +0000 Subject: [PATCH] Fix typo --- boot/boot.js | 6 +++++- core/modules/deserializers.js | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 065e2861e..781081f1d 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -414,7 +414,11 @@ $tw.utils.parseJSONSafe = function(text,defaultJSON) { try { return JSON.parse(text); } catch(e) { - return defaultJSON || {}; + if(typeof defaultJSON === "function") { + return defaultJSON(e); + } else { + return defaultJSON || {}; + } } }; diff --git a/core/modules/deserializers.js b/core/modules/deserializers.js index 21dcbe28b..bff4aaea1 100644 --- a/core/modules/deserializers.js +++ b/core/modules/deserializers.js @@ -17,12 +17,13 @@ exports["application/x-tiddler-html-div"] = function(text,fields) { }; exports["application/json"] = function(text,fields) { - var incoming, - results = []; - incoming = $tw.utils.parseJSONSafe(text,[{ - title: "JSON error: " + e, - text: "" - }]); + var results = [], + incoming = $tw.utils.parseJSONSafe(text,function(err) { + return [{ + title: "JSON error: " + err, + text: "" + }]; + }); if(!$tw.utils.isArray(incoming)) { incoming = [incoming]; }