The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
handle both array & string for tagIds
Steven Teyf456661aa1ff
diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.tsindex 77df0e6165..cb3a604fe4 100644--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@ -11,7 +11,7 @@ import {import { APP_DOMAIN_WITH_NGROK, LOCALHOST_IP } from "@dub/utils";import { NextResponse } from "next/server";-// GET /api/links – get all user links+// GET /api/links – get all links for a projectexport const GET = withAuth(async ({ headers, searchParams, project }) => {const {domain,diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.tsindex 839641de19..515c915b96 100644--- a/apps/web/lib/api/links.ts+++ b/apps/web/lib/api/links.ts@@ -48,7 +48,7 @@ export async function getLinksForProject({}: Omit<z.infer<typeof getLinksQuerySchema>, "projectSlug"> & {projectId: string;}): Promise<LinkProps[]> {- const finalTagIds = combineTagIds({ tagId, tagIds });+ const combinedTagIds = combineTagIds({ tagId, tagIds });const links = await prisma.link.findMany({where: {@@ -70,8 +70,8 @@ export async function getLinksForProject({some: {},},}),- ...(finalTagIds.length > 0 && {- tags: { some: { tagId: { in: finalTagIds } } },+ ...(combinedTagIds.length > 0 && {+ tags: { some: { tagId: { in: combinedTagIds } } },}),...(userId && { userId }),},@@ -121,10 +121,10 @@ export async function getLinksCount({projectId: string;userId?: string | null;}) {- const { groupBy, search, domain, tagId, showArchived, withTags } =+ const { groupBy, search, domain, tagId, tagIds, showArchived, withTags } =searchParams;- const tagIds = tagId ? tagId.split(",") : [];+ const combinedTagIds = combineTagIds({ tagId, tagIds });const linksWhere = {projectId,@@ -168,7 +168,7 @@ export async function getLinksCount({some: {},},}),- ...(tagIds.length > 0 && {+ ...(combinedTagIds.length > 0 && {tags: {some: {tagId: {diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex 6111e39ad7..bdab11d396 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -22,8 +22,8 @@ const LinksQuerySchema = {).openapi({ deprecated: true }),tagIds: z- .string()- .transform((v) => v.split(",").filter(Boolean))+ .union([z.string(), z.array(z.string())])+ .transform((v) => (Array.isArray(v) ? v : v.split(","))).optional().describe("The tag IDs to filter the links by."),search: z