Implement accent-insensitive search in global and library-specific search

This commit is contained in:
aditya.chandel
2025-07-14 10:44:03 -06:00
committed by Aditya Chandel
parent c0e993c37a
commit 451d0b6e50
3 changed files with 22 additions and 14 deletions
@@ -157,11 +157,15 @@ export class BookService {
if (query.length < 2) {
return [];
}
const normalize = (str: string): string => str.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
const normalizedQuery = normalize(query);
const state = this.bookStateSubject.value;
return (state.books || []).filter(book =>
book.metadata?.title?.toLowerCase().includes(query.toLowerCase()) ||
book.metadata?.authors?.some(author => author.toLowerCase().includes(query.toLowerCase()))
);
return (state.books || []).filter(book => {
const title = book.metadata?.title;
const authors = book.metadata?.authors || [];
return (title && normalize(title).includes(normalizedQuery)) ||
authors.some(author => normalize(author).includes(normalizedQuery));
});
}
getFileContent(bookId: number): Observable<Blob> {