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.

Update route.ts

Kiran Ke19519f6eb8d
diff --git a/apps/web/app/api/links/crawl/bitly/route.ts b/apps/web/app/api/links/crawl/bitly/route.ts
index 5eefb3998c..ddcdedfecc 100644
--- a/apps/web/app/api/links/crawl/bitly/route.ts
+++ b/apps/web/app/api/links/crawl/bitly/route.ts
@@ -1,3 +1,4 @@
+import { encodeKeyIfCaseSensitive } from "@/lib/api/case-sensitive-short-links";
import { createId } from "@/lib/api/create-id";
import { ExpandedLink } from "@/lib/api/links";
import { conn } from "@/lib/planetscale";
@@ -8,11 +9,15 @@ import { waitUntil } from "@vercel/functions";
import { NextResponse } from "next/server";
import { z } from "zod";
+const workspaceId = "cm05wnnpo000711ztj05wwdbu";
+const userId = "cm05wnd49000411ztg2xbup0i";
+const folderId = "fold_LIZsdjTgFVbQVGYSUmYAi5vT";
+
// POST /api/links/crawl/bitly – crawl a bitly link
export const POST = async (req: Request) => {
const body = await req.json();
- const { domain, key } = z
+ let { domain, key } = z
.object({
domain: z.string(),
key: z.string(),
@@ -30,10 +35,6 @@ export const POST = async (req: Request) => {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
- const workspaceId = "cm05wnnpo000711ztj05wwdbu";
- const userId = "cm05wnd49000411ztg2xbup0i";
- const folderId = "fold_LIZsdjTgFVbQVGYSUmYAi5vT";
-
const link = await crawlBitlyLink({ domain, key, workspaceId });
if (!link) {
@@ -46,6 +47,11 @@ export const POST = async (req: Request) => {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
+ key = encodeKeyIfCaseSensitive({
+ domain,
+ key,
+ });
+
const newLink = {
id: createId({ prefix: "link_" }),
projectId: workspaceId,