Merge pull request #1882 from fviard/develop

Fix to check if searchTerm is not "undefined" before trying to use it to...
pull/1883/head
Marcel Klehr 2013-09-12 05:50:39 -07:00
commit 8073c62de3
1 changed files with 4 additions and 2 deletions

View File

@ -79,10 +79,12 @@ exports.search = function(searchTerm, maxCacheAge, cb) {
exports.getAvailablePlugins(maxCacheAge, function(er, results) {
if(er) return cb && cb(er);
var res = {};
searchTerm = searchTerm.toLowerCase();
if (searchTerm)
searchTerm = searchTerm.toLowerCase();
for (var pluginName in results) { // for every available plugin
if (pluginName.indexOf(plugins.prefix) != 0) continue; // TODO: Also search in keywords here!
if(pluginName.indexOf(searchTerm) < 0 && results[pluginName].description.indexOf(searchTerm) < 0) continue;
if(searchTerm && pluginName.indexOf(searchTerm) < 0 && results[pluginName].description.indexOf(searchTerm) < 0) continue;
res[pluginName] = results[pluginName];
}
cb && cb(null, res)