Skip to content

Commit 9eac3fe

Browse files
committed
fix: search missing results due to escaping
When you use shell-escape, it wraps the query in single quotes, so "Toggle Goyo" becomes "'Toggle Goyo'", and then you interpolate that into a regex pattern, which doesn't match anything. Instead of escaping the query as a shell argument, you should escape it for use inside the regex pattern, and interpolate it directly.
1 parent b577163 commit 9eac3fe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/api/search.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default defineEventHandlerWithError(async (event): Promise<SearchResult[]
2121
}
2222

2323
const results: SearchResult[] = []
24-
const query = escape([rawQuery.replace(/[^\w\- ]/g, '')])
24+
const query = rawQuery.replace(/[^\w\- ]/g, '').replace(/([.*+?^${}()|[\]\\])/g, '\\$1') // escape regex special chars
2525
const osPlatform = platform()
2626

2727
// 3. Optimized content search

0 commit comments

Comments
 (0)