mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
19 lines
479 B
TypeScript
19 lines
479 B
TypeScript
import type { NormalizedSearchQuery } from './types.js';
|
|
|
|
export function normalizeSearchQuery(queryText: string): NormalizedSearchQuery {
|
|
const terms = queryText
|
|
.toLowerCase()
|
|
.split(/[^a-z0-9_]+/u)
|
|
.map((term) => term.trim())
|
|
.filter(Boolean);
|
|
|
|
return {
|
|
raw: queryText,
|
|
normalized: terms.join(' '),
|
|
terms,
|
|
};
|
|
}
|
|
|
|
export function defaultLaneCandidatePoolLimit(finalLimit: number): number {
|
|
return Math.max(25, Math.max(1, finalLimit) * 3);
|
|
}
|