Skip to content

Commit

Permalink
Fix accessing on empty JS object
Browse files Browse the repository at this point in the history
  • Loading branch information
oclero committed Nov 17, 2023
1 parent 8d1a377 commit 10a7935
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions docs/assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,24 @@ function ensureIndexFetched() {
if (fetchedList !== null) return;

fetchJsonIndex(INDEX_URL, (data) => {
const normalizedList = data.icons.map((item) => {
return {
name: item.name,
normalizedName: normalizeString(item.name),
path: item.path,
freedesktop: item.freedesktop,
tags: item.tags,
};
});
fetchedList = normalizedList;

if (searchText.length > MIN_SEARCH_TEXT_LENGTH) {
triggerSearch();
if (data && data.hasOwnProperty('icons')) {
const normalizedList = data.icons.map((item) => {
return {
name: item.name,
normalizedName: normalizeString(item.name),
path: item.path,
freedesktop: item.freedesktop,
tags: item.tags,
};
});
fetchedList = normalizedList;

if (searchText.length > MIN_SEARCH_TEXT_LENGTH) {
triggerSearch();
}
} else {
fetchedList = null;
searchText = '';
}
});
}
Expand Down

0 comments on commit 10a7935

Please sign in to comment.