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.

Block program creation for a workspace with a reserved slug

Rafi471c9d26605c
diff --git a/apps/web/lib/actions/partners/create-program.ts b/apps/web/lib/actions/partners/create-program.ts
index 6976394a5f..ad5e992bb7 100644
--- a/apps/web/lib/actions/partners/create-program.ts
+++ b/apps/web/lib/actions/partners/create-program.ts
@@ -27,6 +27,7 @@ import {
isLegacyBusinessPlan,
log,
nanoid,
+ RESERVED_SLUGS,
} from "@dub/utils";
import { Program, Project, User } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
@@ -71,6 +72,14 @@ export const createProgram = async ({
);
}
+ // the program takes the workspace slug, and a workspace can have a slug that
+ // was reserved later for a partners.dub.co page (for example /earnings)
+ if (RESERVED_SLUGS.includes(workspace.slug)) {
+ throw new Error(
+ `The workspace slug "${workspace.slug}" is reserved. Change the workspace slug in your workspace settings, then create the program again.`,
+ );
+ }
+
const store = workspace.store as Record<string, any>;
if (!store.programOnboarding) {
throw new Error("Program onboarding data not found");