(plugin, filterState)
| 542 | } |
| 543 | |
| 544 | function matchesFilter(plugin, filterState) { |
| 545 | if (!plugin) return false; |
| 546 | |
| 547 | switch (filterState.type) { |
| 548 | case "verified": |
| 549 | return Boolean(plugin.author_verified); |
| 550 | case "author": { |
| 551 | const authorName = normalizePluginAuthor(plugin); |
| 552 | if (!authorName) return false; |
| 553 | return authorName.toLowerCase().includes(filterState.value); |
| 554 | } |
| 555 | case "keywords": { |
| 556 | const pluginKeywords = normalizePluginKeywords(plugin) |
| 557 | .map((keyword) => keyword.toLowerCase()) |
| 558 | .filter(Boolean); |
| 559 | if (!pluginKeywords.length) return false; |
| 560 | return filterState.value.some((keyword) => |
| 561 | pluginKeywords.some((pluginKeyword) => |
| 562 | pluginKeyword.includes(keyword), |
| 563 | ), |
| 564 | ); |
| 565 | } |
| 566 | default: |
| 567 | return true; |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | function normalizePluginAuthor(plugin) { |
| 572 | const { author } = plugin || {}; |
no test coverage detected