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.

simplify

Steven Teyf51b699d1b77
diff --git a/apps/web/lib/actions/partners/update-online-presence.ts b/apps/web/lib/actions/partners/update-online-presence.ts
index cb6512a251..6ba78669bf 100644
--- a/apps/web/lib/actions/partners/update-online-presence.ts
+++ b/apps/web/lib/actions/partners/update-online-presence.ts
@@ -6,7 +6,7 @@ import {
} from "@/lib/api/oauth/utils";
import { parseUrlSchemaAllowEmpty } from "@/lib/zod/schemas/utils";
import { prisma } from "@dub/prisma";
-import { PARTNERS_DOMAIN_WITH_NGROK } from "@dub/utils";
+import { isValidUrl, PARTNERS_DOMAIN_WITH_NGROK } from "@dub/utils";
import { cookies } from "next/headers";
import { v4 as uuid } from "uuid";
import { z } from "zod";
@@ -32,20 +32,29 @@ const updateOnlinePresenceResponseSchema = updateOnlinePresenceSchema.merge(
export const updateOnlinePresenceAction = authPartnerActionClient
.schema(
- updateOnlinePresenceSchema.refine(
- (data) => {
- return (
- data.youtube ||
- data.twitter ||
- data.linkedin ||
- data.instagram ||
- data.tiktok
- );
- },
- {
- message: "At least one social platform is required.",
- },
- ),
+ updateOnlinePresenceSchema
+ .refine(
+ (data) => {
+ return !data.website || isValidUrl(data.website);
+ },
+ {
+ message: "Invalid website URL.",
+ },
+ )
+ .refine(
+ (data) => {
+ return (
+ data.youtube ||
+ data.twitter ||
+ data.linkedin ||
+ data.instagram ||
+ data.tiktok
+ );
+ },
+ {
+ message: "At least one social platform is required.",
+ },
+ ),
)
.action(async ({ ctx, parsedInput }) => {
const { partner } = ctx;
diff --git a/apps/web/lib/zod/schemas/utils.ts b/apps/web/lib/zod/schemas/utils.ts
index cc8602eb61..f8d783dec5 100644
--- a/apps/web/lib/zod/schemas/utils.ts
+++ b/apps/web/lib/zod/schemas/utils.ts
@@ -25,11 +25,7 @@ export const parseUrlSchemaAllowEmpty = ({
});
}
- return schema
- .transform((v) => getUrlFromString(v))
- .refine((v) => !v || isValidUrl(v), {
- message: "Invalid URL.",
- });
+ return schema.transform((v) => getUrlFromString(v));
};
export const parseDateSchema = z