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

Kiran Kbdf59309edc0
diff --git a/apps/web/lib/api/links/get-links-for-workspace.ts b/apps/web/lib/api/links/get-links-for-workspace.ts
index b7831f1b63..5a410ba113 100644
--- a/apps/web/lib/api/links/get-links-for-workspace.ts
+++ b/apps/web/lib/api/links/get-links-for-workspace.ts
@@ -1,6 +1,7 @@
import z from "@/lib/zod";
import { getLinksQuerySchemaExtended } from "@/lib/zod/schemas/links";
import { prisma } from "@dub/prisma";
+import { encodeKeyIfCaseSensitive } from "../case-sensitive-short-links";
import { combineTagIds } from "../tags/combine-tag-ids";
import { transformLink } from "./utils";
@@ -39,8 +40,24 @@ export async function getLinksForWorkspace({
sortBy = sort;
}
- // TODO:
- // Make sure the search work for case sensitive short links
+ if (searchMode === "exact" && search) {
+ try {
+ const url = new URL(search);
+ const domain = url.hostname;
+ const key = url.pathname.slice(1);
+
+ if (key) {
+ const encodedKey = encodeKeyIfCaseSensitive({
+ domain,
+ key,
+ });
+
+ search = search.replace(key, encodedKey);
+ }
+ } catch (e) {
+ //
+ }
+ }
const links = await prisma.link.findMany({
where: {