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.

limit key length

Steven Tey6bba15b90397
diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.ts
index 62b27a998a..d35475be15 100644
--- a/apps/web/lib/api/links.ts
+++ b/apps/web/lib/api/links.ts
@@ -349,6 +349,18 @@ export async function processLink({
if (!key) {
key = await getRandomKey(domain, payload["prefix"]);
+
+ // restrict key length to at least 4 characters for free plan
+ } else if (
+ isDubDomain(domain) &&
+ key.length <= 3 &&
+ (!project || project.plan === "free")
+ ) {
+ return {
+ link: payload,
+ error: `You can only use keys shorter than 3 characters on a Pro plan and above. Upgrade to Pro to register a ${key.length}-character key.`,
+ code: "forbidden",
+ };
}
if (bulk) {