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 edit link API endpoint

Steven Teyef5e2c6acb4a
diff --git a/pages/api/links/[key]/index.ts b/pages/api/links/[key]/index.ts
index 7b804dc77d..211e3bd277 100644
--- a/pages/api/links/[key]/index.ts
+++ b/pages/api/links/[key]/index.ts
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next";
import { deleteLink, editLink } from "@/lib/api/links";
import { Session, withUserAuth } from "@/lib/auth";
import prisma from "@/lib/prisma";
-import { isBlacklistedDomain } from "@/lib/utils";
+import { isBlacklistedDomain, isBlacklistedKey } from "@/lib/utils";
export const config = {
api: {
@@ -42,6 +42,10 @@ export default withUserAuth(
.status(400)
.json({ error: "Missing key or url or title or timestamp" });
}
+ const keyBlacklisted = await isBlacklistedKey(key);
+ if (keyBlacklisted) {
+ return res.status(400).json({ error: "Invalid key" });
+ }
const domainBlacklisted = await isBlacklistedDomain(url);
if (domainBlacklisted) {
return res.status(400).json({ error: "Invalid url" });