Add ISAC registry search controls
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user