Skip to content

Commit

Permalink
fix(animegarden): normalize filter options word
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Oct 8, 2023
1 parent ed15952 commit 6245899
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/animegarden/src/garden/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ export function makeResourcesFilter(
if (resolved.search) {
include.push(resolved.search);
}
for (const arr of include) {
arr.splice(0, arr.length, ...arr.map((k) => normalizeTitle(k).toLowerCase()));
}
chains.push((r) => {
// @ts-expect-error
const titleAlt: string = r.titleAlt || normalizeTitle(r.title);
const titleAlt = normalizeTitle(r.title).toLowerCase();
return include.every((keys) => keys.some((key) => titleAlt.indexOf(key) !== -1));
});
}
if (resolved.exclude) {
const exclude = resolved.exclude;
const exclude = resolved.exclude.map((k) => normalizeTitle(k).toLowerCase());
chains.push((r) => {
// @ts-expect-error
const titleAlt: string = r.titleAlt || normalizeTitle(r.title);
const titleAlt = normalizeTitle(r.title).toLowerCase();
return exclude.every((key) => titleAlt.indexOf(key) === -1);
});
}
Expand Down
7 changes: 7 additions & 0 deletions packages/animegarden/src/garden/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ export function parseSearchURL(
if (newExclude.length > 0) {
filtered.exclude = newExclude;
}
} else {
if (filtered.include) {
filtered.include = filtered.include.map((arr) => arr.map((t) => normalizeTitle(t)));
}
if (filtered.exclude) {
filtered.exclude = filtered.exclude.map((t) => normalizeTitle(t));
}
}

const isNaN = (d: unknown): boolean => d === undefined || d === null || Number.isNaN(d);
Expand Down

0 comments on commit 6245899

Please sign in to comment.