mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Split operator: Remove empty strings when splitting
See the discussion on 9b2d527; thanks @kookma
This commit is contained in:
parent
6ff7a7d261
commit
9d7d3fefa0
@ -35,7 +35,7 @@ exports.concat = makeStringBinaryOperator(
|
|||||||
);
|
);
|
||||||
|
|
||||||
exports.split = makeStringBinaryOperator(
|
exports.split = makeStringBinaryOperator(
|
||||||
function(a,b) {return ("" + a).split(b);}
|
function(a,b) {return ("" + a).split(b).filter(function(str) {return !!str;});}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.join = makeStringArrayOperator(
|
exports.join = makeStringArrayOperator(
|
||||||
|
@ -368,7 +368,8 @@ describe("Filter tests", function() {
|
|||||||
expect(wiki.filterTiddlers("John Paul George Ringo +[lowercase[]]").join(",")).toBe("john,paul,george,ringo");
|
expect(wiki.filterTiddlers("John Paul George Ringo +[lowercase[]]").join(",")).toBe("john,paul,george,ringo");
|
||||||
expect(wiki.filterTiddlers("John Paul George Ringo +[concat[y]]").join(",")).toBe("Johny,Pauly,Georgey,Ringoy");
|
expect(wiki.filterTiddlers("John Paul George Ringo +[concat[y]]").join(",")).toBe("Johny,Pauly,Georgey,Ringoy");
|
||||||
expect(wiki.filterTiddlers("John Paul George Ringo +[split[]]").join(",")).toBe("J,o,h,n,P,a,u,l,G,e,o,r,g,e,R,i,n,g,o");
|
expect(wiki.filterTiddlers("John Paul George Ringo +[split[]]").join(",")).toBe("J,o,h,n,P,a,u,l,G,e,o,r,g,e,R,i,n,g,o");
|
||||||
expect(wiki.filterTiddlers("John Paul George Ringo +[split[e]]").join(",")).toBe("John,Paul,G,org,,Ringo");
|
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");
|
expect(wiki.filterTiddlers("John Paul George Ringo +[join[ ]split[e]join[ee]split[ ]]").join(",")).toBe("John,Paul,Geeorgee,Ringo");
|
||||||
expect(wiki.filterTiddlers("[[ John ]] [[Paul ]] [[ George]] Ringo +[trim[]join[-]]").join(",")).toBe("John-Paul-George-Ringo");
|
expect(wiki.filterTiddlers("[[ John ]] [[Paul ]] [[ George]] Ringo +[trim[]join[-]]").join(",")).toBe("John-Paul-George-Ringo");
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user