1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-08 14:55:17 +00:00

Fixed RSoD error with moduleproperty filter operator

This commit is contained in:
Cameron Fischer 2025-02-19 00:03:35 -05:00
parent 228c82e1db
commit 405773312d
2 changed files with 15 additions and 3 deletions

View File

@ -18,10 +18,14 @@ Export our filter function
exports.moduleproperty = function(source,operator,options) { exports.moduleproperty = function(source,operator,options) {
var results = []; var results = [];
source(function(tiddler,title) { source(function(tiddler,title) {
try {
var value = require(title)[operator.operand || ""]; var value = require(title)[operator.operand || ""];
if(value !== undefined) { if(value !== undefined) {
results.push(value); results.push(value);
} }
} catch(e) {
// Do nothing. It probably wasn't a module.
}
}); });
results.sort(); results.sort();
return results; return results;

View File

@ -1134,6 +1134,14 @@ Tests the filtering mechanism.
expect(wiki.filterTiddlers("[[<>:\"/\\|?*]encodeuricomponent[]]").join(",")).toBe("%3C%3E%3A%22%2F%5C%7C%3F%2A"); 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);
});
} }
}); });