MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / doesPluginMatchFilter

Function doesPluginMatchFilter

src/sidebarApps/extensions/index.js:631–654  ·  view source on GitHub ↗
(plugin, filterState)

Source from the content-addressed store, hash-verified

629}
630
631function doesPluginMatchFilter(plugin, filterState) {
632 if (!plugin) return false;
633
634 switch (filterState.type) {
635 case "verified":
636 return Boolean(plugin.author_verified);
637 case "author": {
638 const authorName = getPluginAuthorName(plugin);
639 if (!authorName) return false;
640 return authorName.toLowerCase().includes(filterState.value);
641 }
642 case "keywords": {
643 const pluginKeywords = getPluginKeywords(plugin)
644 .map((keyword) => keyword.toLowerCase())
645 .filter(Boolean);
646 if (!pluginKeywords.length) return false;
647 return filterState.value.some((keyword) =>
648 pluginKeywords.some((pluginKeyword) => pluginKeyword.includes(keyword)),
649 );
650 }
651 default:
652 return true;
653 }
654}
655
656function getPluginAuthorName(plugin) {
657 const { author } = plugin || {};

Callers 1

getFilteredPluginsFunction · 0.85

Calls 2

getPluginAuthorNameFunction · 0.85
getPluginKeywordsFunction · 0.85

Tested by

no test coverage detected