1 parent 21ae750 commit 5841ef0Copy full SHA for 5841ef0
1 file changed
apps/docs/app/api/search/route.ts
@@ -1,4 +1,5 @@
1
import { createLogger } from '@sim/logger'
2
+import { truncateAtCodePoint } from '@sim/utils/string'
3
import { sql } from 'drizzle-orm'
4
import { type NextRequest, NextResponse } from 'next/server'
5
import { db, docsEmbeddings } from '@/lib/db'
@@ -30,7 +31,11 @@ function getSearchLimit(value: unknown): number {
30
31
function getSearchParams(request: NextRequest) {
32
const searchParams = request.nextUrl.searchParams
33
return {
- query: (searchParams.get('query') || searchParams.get('q') || '').slice(0, MAX_QUERY_LENGTH),
34
+ query: truncateAtCodePoint(
35
+ searchParams.get('query') || searchParams.get('q') || '',
36
+ MAX_QUERY_LENGTH,
37
+ ''
38
+ ),
39
limit: getSearchLimit(searchParams.get('limit')),
40
}
41
0 commit comments