返回 presentation-ai
title-search-query.ts
根目录 / src / lib / presentation / title-search-query.ts
1 export function getPresentationTitleSearchQuery(title: string | null): string {
2 const trimmedTitle = title?.trim() ?? "";
3 if (!trimmedTitle) return "";
4
5 const colonIndex = trimmedTitle.indexOf(":");
6 if (colonIndex > 0) {
7 return trimmedTitle.slice(0, colonIndex).trim();
8 }
9
10 return trimmedTitle.split(/\s+/)[0] ?? "";
11 }
12
12 lines TYPESCRIPT