From 405773312de57c35a7c22111358dc94ec1fd786e Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Wed, 19 Feb 2025 00:03:35 -0500 Subject: [PATCH] Fixed RSoD error with moduleproperty filter operator --- core/modules/filters/moduleproperty.js | 10 +++++++--- editions/test/tiddlers/tests/test-filters.js | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/modules/filters/moduleproperty.js b/core/modules/filters/moduleproperty.js index 8f3559b09..3086d9e94 100644 --- a/core/modules/filters/moduleproperty.js +++ b/core/modules/filters/moduleproperty.js @@ -18,9 +18,13 @@ Export our filter function exports.moduleproperty = function(source,operator,options) { var results = []; source(function(tiddler,title) { - var value = require(title)[operator.operand || ""]; - if(value !== undefined) { - results.push(value); + try { + var value = require(title)[operator.operand || ""]; + if(value !== undefined) { + results.push(value); + } + } catch(e) { + // Do nothing. It probably wasn't a module. } }); results.sort(); diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index 727f64ca4..fee196afb 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -1134,6 +1134,14 @@ Tests the filtering mechanism. expect(wiki.filterTiddlers("[[<>:\"/\\|?*]encodeuricomponent[]]").join(",")).toBe("%3C%3E%3A%22%2F%5C%7C%3F%2A"); }); + it("should handle the moduleproperty operator", function() { + // We don't need to confirm them all, only it it finds at least one module name that we're sure is there. + expect(wiki.filterTiddlers("[[macro]modules[]moduleproperty[name]]")).toContain("qualify"); + // No such property. Nothing to return. + 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); + }); } });