mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Fixed join filter operator to never returns null (#4396)
If the operator were passed an empty list, it would return null which could cause some proceeding operators to crash.
This commit is contained in:
parent
43fdb553b7
commit
65347ae858
@ -70,7 +70,7 @@ function makeStringReducingOperator(fnCalc,initialValue) {
|
||||
});
|
||||
return [result.reduce(function(accumulator,currentValue) {
|
||||
return fnCalc(accumulator,currentValue,operator.operand || "");
|
||||
},initialValue)];
|
||||
},initialValue) || ""];
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -450,6 +450,10 @@ function runTests(wiki) {
|
||||
expect(wiki.filterTiddlers("[[John. Paul. George. Ringo.]] +[split[.]trim[]]").join(",")).toBe("John,Paul,George,Ringo,");
|
||||
expect(wiki.filterTiddlers("John Paul George Ringo +[split[e]]").join(",")).toBe("John,Paul,G,org,,Ringo");
|
||||
expect(wiki.filterTiddlers("John Paul George Ringo +[join[ ]split[e]join[ee]split[ ]]").join(",")).toBe("John,Paul,Geeorgee,Ringo");
|
||||
// Ensure that join doesn't return null if passed empty list
|
||||
expect(wiki.filterTiddlers("Test +[butlast[]join[ ]]")).toEqual([""]);
|
||||
// Ensure that join correctly handles empty strings in source
|
||||
expect(wiki.filterTiddlers("[[]] Paul +[join[-]]").join(",")).toBe("-Paul");
|
||||
expect(wiki.filterTiddlers("[[ John ]] [[Paul ]] [[ George]] Ringo +[trim[]join[-]]").join(",")).toBe("John-Paul-George-Ringo");
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user