refactor(books): shared search normalisation and debounce helpers + migrate command palette to server-side queries (#2232)

This commit is contained in:
Alex
2026-09-21 13:01:56 +01:00
committed by GitHub
parent 7ed1c35ca0
commit 04467d7d68
9 changed files with 339 additions and 83 deletions
@@ -0,0 +1,18 @@
export const SEARCH_DEBOUNCE_MS = 200;
export function normalizeRemoteSearchTerm(str: string): string {
return str
.replace(/[!@$%^&*_=|~`<>?/";']/g, '')
.replace(/\s+/g, ' ')
.trim();
}
export function normalizeLocalSearchTerm(str: string): string {
const folded = str.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
.replace(/ø/gi, 'o')
.replace(/ł/gi, 'l')
.replace(/æ/gi, 'ae')
.replace(/œ/gi, 'oe')
.replace(/ß/g, 'ss');
return normalizeRemoteSearchTerm(folded).toLowerCase();
}