1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-29 16:53:14 +00:00
TiddlyWiki5/core/modules/filters/prefix.js
Jermolene 112a9a95d9 Make prefix/suffix operators be case sensitive
I think it was a mistake for them to be case insensitive in the first
place.

https://groups.google.com/d/topic/tiddlywiki/dzpFsRCC5D8/discussion

If case insensitivity is required then regexps can be used instead.
2014-08-28 15:27:10 +01:00

37 lines
717 B
JavaScript

/*\
title: $:/core/modules/filters/prefix.js
type: application/javascript
module-type: filteroperator
Filter operator for checking if a title starts with a prefix
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.prefix = function(source,operator,options) {
var results = [];
if(operator.prefix === "!") {
source(function(tiddler,title) {
if(title.substr(0,operator.operand.length) !== operator.operand) {
results.push(title);
}
});
} else {
source(function(tiddler,title) {
if(title.substr(0,operator.operand.length) === operator.operand) {
results.push(title);
}
});
}
return results;
};
})();