Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix search function

Steven Tey8f8ae8f1f838
diff --git a/lib/api/links.ts b/lib/api/links.ts
index 5e44d90c4b..a41ca59a75 100644
--- a/lib/api/links.ts
+++ b/lib/api/links.ts
@@ -33,9 +33,15 @@ export async function getLinksForProject({
archived: showArchived ? undefined : false,
...(domain && { domain }),
...(search && {
- // if search query is 4 characters or shorter, only search for exact matches, else use MySQL fullTextSearch
- key: search.length <= 4 ? { contains: search } : { search },
- url: search.length <= 4 ? { contains: search } : { search },
+ OR: [
+ // if search query is 4 characters or shorter, only search for exact matches, else use MySQL fullTextSearch
+ {
+ key: search.length <= 4 ? { contains: search } : { search },
+ },
+ {
+ url: search.length <= 4 ? { contains: search } : { search },
+ },
+ ],
}),
...(tagId && { tagId }),
...(userId && { userId }),
@@ -72,9 +78,15 @@ export async function getLinksCount({
archived: showArchived ? undefined : false,
...(userId && { userId }),
...(search && {
- // if search query is 4 characters or shorter, only search for exact matches, else use MySQL fullTextSearch
- key: search.length <= 4 ? { contains: search } : { search },
- url: search.length <= 4 ? { contains: search } : { search },
+ OR: [
+ // if search query is 4 characters or shorter, only search for exact matches, else use MySQL fullTextSearch
+ {
+ key: search.length <= 4 ? { contains: search } : { search },
+ },
+ {
+ url: search.length <= 4 ? { contains: search } : { search },
+ },
+ ],
}),
// when filtering by domain, only filter by domain if the filter group is not "Domains"
...(domain &&