The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Test for public link creation
Kiran K40ee93c8f7a4
diff --git a/apps/web/lib/api/links/utils.ts b/apps/web/lib/api/links/utils.tsindex 19490912be..5699ae55b4 100644--- a/apps/web/lib/api/links/utils.ts+++ b/apps/web/lib/api/links/utils.ts@@ -150,6 +150,6 @@ export const transformLink = (link: LinkWithTags) => {tagId: tags?.[0]?.id ?? null, // backwards compatibilitytags,qrCode: `https://api.dub.co/qr?url=${qrLink}`,- workspaceId: `ws_${link.projectId}`,+ workspaceId: link.projectId ? `ws_${link.projectId}` : null,};};diff --git a/apps/web/tests/links/create-link.test.ts b/apps/web/tests/links/create-link.test.tsindex 2d84d2e4df..3539a4f241 100644--- a/apps/web/tests/links/create-link.test.ts+++ b/apps/web/tests/links/create-link.test.ts@@ -14,6 +14,34 @@ describe.sequential("POST /links", async () => {const { workspaceId } = workspace;const projectId = workspaceId.replace("ws_", "");+ test("public link", async () => {+ const { status, data: link } = await http.post<Link>({+ path: "/links",+ body: {+ url,+ domain: "dub.sh",+ publicStats: true,+ },+ headers: {+ Authorization: "",+ },+ });++ expect(status).toEqual(200);+ expect(link).toStrictEqual({+ ...expectedLink,+ url,+ publicStats: true,+ rewrite: false,+ userId: null,+ projectId: null,+ workspaceId: null,+ shortLink: `https://${domain}/${link.key}`,+ qrCode: `https://api.dub.co/qr?url=https://${domain}/${link.key}?qr=1`,+ tags: [],+ });+ });+test("default domain", async () => {const externalId = randomId();