Add ISAC registry search controls

This commit is contained in:
JB
2026-07-25 21:18:11 -04:00
parent 6d2e8176ee
commit 65aa6361a6
21 changed files with 172 additions and 65 deletions
+9
View File
@@ -2,6 +2,15 @@ import type { URL } from 'node:url';
export const PAGE_SIZE_PRESETS = [10, 25, 50, 100] as const;
export function getRegistrySearch(url: URL, namespace = '') {
const key = namespace ? `${namespace}Q` : 'q';
const search = String(url.searchParams.get(key) ?? '').normalize('NFKC').trim().slice(0, 80);
return {
search,
pattern: `%${search.replaceAll('\\', '\\\\').replaceAll('%', '\\%').replaceAll('_', '\\_')}%`
};
}
export function getPagination(url: URL, total: number, namespace = '') {
const pageKey = namespace ? `${namespace}Page` : 'page';
const perPageKey = namespace ? `${namespace}PerPage` : 'perPage';