From 494bce97a291c81ca4870226225857335a129a50 Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Fri, 21 Feb 2025 00:01:27 -0500 Subject: [PATCH] No RSoD when getting non-string objects as well --- core/modules/filters/moduleproperty.js | 3 +++ editions/test/tiddlers/tests/test-filters.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/core/modules/filters/moduleproperty.js b/core/modules/filters/moduleproperty.js index 3086d9e94..2aa0e6a0c 100644 --- a/core/modules/filters/moduleproperty.js +++ b/core/modules/filters/moduleproperty.js @@ -21,6 +21,9 @@ exports.moduleproperty = function(source,operator,options) { try { var value = require(title)[operator.operand || ""]; if(value !== undefined) { + if(typeof value !== "string") { + value = JSON.stringify(value); + } results.push(value); } } catch(e) { diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index fee196afb..5626db4f8 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -1141,6 +1141,8 @@ Tests the filtering mechanism. expect(wiki.filterTiddlers("[[macro]modules[]moduleproperty[nonexistent]]").length).toBe(0); // No such tiddlers. Nothing to return. expect(wiki.filterTiddlers("[[nonexistent]moduleproperty[name]]").length).toBe(0); + // Non string properties should get toStringed. + expect(wiki.filterTiddlers("[[$:/core/modules/commands/init.js]moduleproperty[info]]").join(" ")).toBe('{"name":"init","synchronous":true}'); }); }