refactor(search,auth): export pure helpers for direct testing

encodeCursor/decodeCursor/firstSnippet (opensearch) and
decodeJwtPayload (verify) become public exports so tests can
hit them without round-tripping through fetch.
This commit is contained in:
Julien Calixte
2026-06-07 22:06:49 +02:00
parent 01048c753e
commit 49608cff20
2 changed files with 4 additions and 4 deletions

View File

@@ -139,7 +139,7 @@ export type SearchOptions = {
limit: number;
};
const decodeCursor = (cursor: string): [number, string] | undefined => {
export const decodeCursor = (cursor: string): [number, string] | undefined => {
try {
const parsed = JSON.parse(atob(cursor));
if (
@@ -157,10 +157,10 @@ const decodeCursor = (cursor: string): [number, string] | undefined => {
return undefined;
};
const encodeCursor = (score: number, rkey: string): string =>
export const encodeCursor = (score: number, rkey: string): string =>
btoa(JSON.stringify([score, rkey]));
const firstSnippet = (
export const firstSnippet = (
highlight: Record<string, string[]> | undefined,
source: { content?: string; title?: string },
): string => {