Fix to check if searchTerm is not "undefined" before trying to use it to filter search results.
Signed-off-by: Florent Viard <fviard@lacie.com>pull/1882/head
parent
c4fcedbb8d
commit
6f478c4de1
|
@ -79,10 +79,12 @@ exports.search = function(searchTerm, maxCacheAge, cb) {
|
||||||
exports.getAvailablePlugins(maxCacheAge, function(er, results) {
|
exports.getAvailablePlugins(maxCacheAge, function(er, results) {
|
||||||
if(er) return cb && cb(er);
|
if(er) return cb && cb(er);
|
||||||
var res = {};
|
var res = {};
|
||||||
searchTerm = searchTerm.toLowerCase();
|
if (searchTerm)
|
||||||
|
searchTerm = searchTerm.toLowerCase();
|
||||||
for (var pluginName in results) { // for every available plugin
|
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(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];
|
res[pluginName] = results[pluginName];
|
||||||
}
|
}
|
||||||
cb && cb(null, res)
|
cb && cb(null, res)
|
||||||
|
|
Loading…
Reference in New Issue