From df0a1a7c4285ef36217813374ddc84fec19a3bc3 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 24 Aug 2013 16:51:54 +0100 Subject: [PATCH] Fix problem with wiki.search() incorrectly searching missing tiddlers --- core/modules/wiki.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 69a29408d..d4358623a 100644 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -724,24 +724,29 @@ exports.search = function(text,options) { flags = options.caseSensitive ? "" : "i"; if(options.literal) { if(text.length === 0) { - return []; + searchTermsRegExps = null; + } else { + searchTermsRegExps = [new RegExp("(" + $tw.utils.escapeRegExp(text) + ")",flags)]; } - searchTermsRegExps = [new RegExp("(" + $tw.utils.escapeRegExp(text) + ")",flags)]; } else { terms = text.replace(/( +)/g," ").split(" "); - searchTermsRegExps = []; - if(terms.length === 0) { - return []; - } - for(t=0; t