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.

exclude invalid chars

Steven Teyc2b48a2ba0d7
diff --git a/apps/web/app/api/links/crawl/bitly/route.ts b/apps/web/app/api/links/crawl/bitly/route.ts
index 7fca67d292..e7da83c463 100644
--- a/apps/web/app/api/links/crawl/bitly/route.ts
+++ b/apps/web/app/api/links/crawl/bitly/route.ts
@@ -14,6 +14,13 @@ export const POST = async (req: Request) => {
})
.parse(body);
+ // bitly doesn't support the following characters: ` ~ , . < > ; ‘ : “ / \ [ ] ^ { } ( ) = + ! * @ & $ £ ? % # |
+ // @see: https://support.bitly.com/hc/en-us/articles/360030780892-What-characters-are-supported-when-customizing-links
+ const invalidBitlyKeyRegex = /[`~,.<>;':"/\\[\]^{}()=+!*@&$£?%#|]/;
+ if (invalidBitlyKeyRegex.test(key)) {
+ return NextResponse.json({ error: "Invalid key" }, { status: 400 });
+ }
+
const link = await crawlBitlyLink({ domain, key, workspaceId });
return link