The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add DESTINATION_URL_MAX_LENGTH
Kiran Kdb82a1178312
diff --git a/apps/web/lib/zod/schemas/groups.ts b/apps/web/lib/zod/schemas/groups.tsindex 5e9feee511..37baf5f563 100644--- a/apps/web/lib/zod/schemas/groups.ts+++ b/apps/web/lib/zod/schemas/groups.ts@@ -4,6 +4,7 @@ import { validDomainRegex, validSlugRegex } from "@dub/utils";import slugify from "@sindresorhus/slugify";import { z } from "zod";import { DiscountSchema } from "./discount";+import { DESTINATION_URL_MAX_LENGTH } from "./links";import { booleanQuerySchema, getPaginationQuerySchema } from "./misc";import { RewardSchema } from "./rewards";import { parseUrlSchema } from "./utils";@@ -60,7 +61,7 @@ export const GroupSchemaExtended = GroupSchema.extend({});export const createOrUpdateDefaultLinkSchema = z.object({- url: parseUrlSchema({ maxLength: 32000 }),+ url: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }),});export const createGroupSchema = z.object({@@ -100,7 +101,7 @@ export const updateGroupSchema = createGroupSchema.partial().extend({export const PartnerGroupDefaultLinkSchema = z.object({id: z.string(),domain: z.string(),- url: parseUrlSchema({ maxLength: 32000 }),+ url: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }),});export const getGroupsQuerySchema = zdiff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex fdd2a15ecc..7c39b21d59 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -27,6 +27,7 @@ export const getDomainQuerySchema = z.object({export const MIN_TEST_PERCENTAGE = 10;export const MAX_TEST_COUNT = 4;+export const DESTINATION_URL_MAX_LENGTH = 32000;export const ABTestVariantsSchema = z.array(@@ -222,7 +223,7 @@ export const domainKeySchema = z.object({});export const createLinkBodySchema = z.object({- url: parseUrlSchemaAllowEmpty({ maxLength: 32000 })+ url: parseUrlSchemaAllowEmpty({ maxLength: DESTINATION_URL_MAX_LENGTH }).describe("The destination URL of the short link.").openapi({example: "https://google.com",@@ -316,7 +317,7 @@ export const createLinkBodySchema = z.object({.string().nullish().describe("The date and time when the short link will expire at."),- expiredUrl: parseUrlSchema({ maxLength: 32000 })+ expiredUrl: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }).nullish().describe("The URL to redirect to when the short link has expired."),password: z@@ -361,18 +362,21 @@ export const createLinkBodySchema = z.object({.describe("Whether the short link uses link cloaking. Defaults to `false` if not provided.",),- ios: parseUrlSchema({ maxLength: 32000 })+ ios: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }).nullish().describe("The iOS destination URL for the short link for iOS device targeting.",),- android: parseUrlSchema({ maxLength: 32000 })+ android: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }).nullish().describe("The Android destination URL for the short link for Android device targeting.",),geo: z- .record(z.string(), parseUrlSchema({ maxLength: 32000 }))+ .record(+ z.string(),+ parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }),+ ).nullish().describe("Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. See https://d.to/geo for more information.",@@ -497,7 +501,7 @@ export const bulkUpdateLinksBodySchema = z.object({}).merge(z.object({- url: parseUrlSchema({ maxLength: 32000 })+ url: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }).describe("The destination URL of the short link.").openapi({example: "https://google.com",diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.tsindex a0ca33bacd..de974ca6a9 100644--- a/apps/web/lib/zod/schemas/partners.ts+++ b/apps/web/lib/zod/schemas/partners.ts@@ -13,7 +13,7 @@ import {import { z } from "zod";import { analyticsQuerySchema } from "./analytics";import { analyticsResponse } from "./analytics-response";-import { createLinkBodySchema } from "./links";+import { createLinkBodySchema, DESTINATION_URL_MAX_LENGTH } from "./links";import {base64ImageSchema,booleanQuerySchema,@@ -529,7 +529,7 @@ export const createPartnerLinkSchema = z.describe("The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown.",),- url: parseUrlSchema({ maxLength: 32000 })+ url: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }).describe("The URL to shorten (if not provided, the program's default URL will be used). Will throw an error if the domain doesn't match the program's default URL domain.",)@@ -551,7 +551,7 @@ export const createPartnerLinkSchema = zexport const upsertPartnerLinkSchema = createPartnerLinkSchema.merge(z.object({- url: parseUrlSchema({ maxLength: 32000 }).describe(+ url: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }).describe("The URL to upsert for. Will throw an error if the domain doesn't match the program's default URL domain.",),}),diff --git a/apps/web/lib/zod/schemas/program-onboarding.ts b/apps/web/lib/zod/schemas/program-onboarding.tsindex 8771d9fc98..037f118c15 100644--- a/apps/web/lib/zod/schemas/program-onboarding.ts+++ b/apps/web/lib/zod/schemas/program-onboarding.ts@@ -1,6 +1,7 @@import { PROGRAM_ONBOARDING_PARTNERS_LIMIT } from "@/lib/partners/constants";import { PartnerLinkStructure, RewardStructure } from "@dub/prisma/client";import { z } from "zod";+import { DESTINATION_URL_MAX_LENGTH } from "./links";import { maxDurationSchema } from "./misc";import { updateProgramSchema } from "./programs";import { parseUrlSchema } from "./utils";@@ -10,7 +11,7 @@ export const programInfoSchema = z.object({name: z.string().max(100),logo: z.string(),domain: z.string(),- url: parseUrlSchema({ maxLength: 32000 }).nullable(),+ url: parseUrlSchema({ maxLength: DESTINATION_URL_MAX_LENGTH }).nullable(),linkStructure: z.nativeEnum(PartnerLinkStructure).default("short"),linkParameter: z.string().nullish(),});