Skip to content

Commit

Permalink
fix: network searchbar
Browse files Browse the repository at this point in the history
  • Loading branch information
fraxken committed Dec 8, 2024
1 parent bd099fa commit f3cf02a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion public/components/searchbar/searchbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ div.search-result-pannel .package>b {
}

div.search-result-pannel .package.hide {
display: none;
display: none !important;
}

div.search-result-pannel .package+.package {
Expand Down
24 changes: 13 additions & 11 deletions public/components/searchbar/searchbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ const kHelpersTemplateName = {
const fragment = document.createDocumentFragment();
const items = new Set();

for (const { license } of linker.values()) {
if (typeof license === "string") {
items.add("Unknown");
continue;
}
license.uniqueLicenseIds.forEach((ext) => items.add(ext));
for (const { uniqueLicenseIds = [] } of linker.values()) {
uniqueLicenseIds.forEach((ext) => items.add(ext));
}
[...items].forEach((value) => fragment.appendChild(createLineElement(value)));

Expand Down Expand Up @@ -56,7 +52,10 @@ const kHelpersTemplateName = {
const fragment = document.createDocumentFragment();
const items = new Set();
for (const { author } of linker.values()) {
items.add(typeof author === "string" ? author : author.name);
if (author === null) {
continue;
}
items.add(author.name);
}
[...items].forEach((value) => fragment.appendChild(createLineElement(value)));

Expand Down Expand Up @@ -438,8 +437,9 @@ export class SearchBar {
break;
}
case "license": {
const licences = typeof opt.license === "string" ? ["Unknown"] : [...new Set(opt.license.uniqueLicenseIds)];
const hasMatchingLicense = licences.some((value) => new RegExp(inputValue, "gi").test(value));
const hasMatchingLicense = opt.uniqueLicenseIds.some(
(value) => new RegExp(inputValue, "gi").test(value)
);
if (hasMatchingLicense) {
matchingIds.add(String(id));
}
Expand Down Expand Up @@ -474,8 +474,10 @@ export class SearchBar {
case "author": {
const authorRegex = new RegExp(inputValue, "gi");

if ((typeof opt.author === "string" && authorRegex.test(opt.author)) ||
(opt.author.name && authorRegex.test(opt.author.name))) {
if (
(typeof opt.author === "string" && authorRegex.test(opt.author)) ||
(opt.author !== null && "name" in opt.author && authorRegex.test(opt.author.name))
) {
matchingIds.add(String(id));
}
break;
Expand Down

0 comments on commit f3cf02a

Please sign in to comment.