Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fixes

Richie McIlroy582406a8d3ea
diff --git a/apps/desktop/src/routes/(window-chrome)/onboarding.tsx b/apps/desktop/src/routes/(window-chrome)/onboarding.tsx
index 6a84061a3..b6383987a 100644
--- a/apps/desktop/src/routes/(window-chrome)/onboarding.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/onboarding.tsx
@@ -968,7 +968,7 @@ function ShortcutsStep(props: { active: boolean }) {
},
{
title: "Custom Domain",
- desc: "Use your own domain for shareable links instead of cap.link",
+ desc: "Use your own domain for shareable links instead of cap.so",
},
{
title: "Recording Preferences",
@@ -1443,7 +1443,7 @@ function InstantMockup(props: { active: boolean }) {
<div class="flex items-center gap-2 w-full">
<div class="flex-1 flex items-center px-3 py-2 rounded-lg bg-white dark:bg-gray-3 border border-gray-4">
<span class="text-[11px] text-gray-11 font-mono">
- cap.link/m4k92x
+ cap.so/s/m4k92x
</span>
</div>
<div
diff --git a/apps/web/__tests__/unit/og-images.test.ts b/apps/web/__tests__/unit/og-images.test.ts
index 898095f7c..f026e1a36 100644
--- a/apps/web/__tests__/unit/og-images.test.ts
+++ b/apps/web/__tests__/unit/og-images.test.ts
@@ -5,6 +5,7 @@ import { signOgParams, verifyOgSignature } from "../../lib/og/signature";
import { ogImageUrl } from "../../lib/og/url";
import { formatDuration, renderVideoOg } from "../../lib/og/video-og";
import {
+ canonicalVideoShareUrl,
richVideoLinkHtml,
videoPreviewImageUrl,
} from "../../lib/video-share-clipboard";
@@ -119,6 +120,21 @@ describe("video og", () => {
});
describe("rich share link", () => {
+ it("canonicalizes legacy video share links", () => {
+ expect(canonicalVideoShareUrl("https://cap.link/abc123")).toBe(
+ "https://cap.so/s/abc123",
+ );
+ expect(canonicalVideoShareUrl("https://cap.link/abc123?t=42")).toBe(
+ "https://cap.so/s/abc123?t=42",
+ );
+ expect(canonicalVideoShareUrl("https://cap.link/video/demo.mp4")).toBe(
+ "https://cap.link/video/demo.mp4",
+ );
+ expect(canonicalVideoShareUrl("https://team.example/s/abc123")).toBe(
+ "https://team.example/s/abc123",
+ );
+ });
+
it("builds the preview image url", () => {
expect(videoPreviewImageUrl("https://cap.so", "abc123")).toBe(
"https://cap.so/api/video/preview?videoId=abc123&fallback=og",
diff --git a/apps/web/actions/video/create-for-processing.ts b/apps/web/actions/video/create-for-processing.ts
index 281f7a78f..a3acda737 100644
--- a/apps/web/actions/video/create-for-processing.ts
+++ b/apps/web/actions/video/create-for-processing.ts
@@ -4,8 +4,8 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { videos, videoUploads } from "@cap/database/schema";
-import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";
-import { dub, userIsPro } from "@cap/utils";
+import { serverEnv } from "@cap/env";
+import { userIsPro } from "@cap/utils";
import { Storage as StorageService } from "@cap/web-backend";
import {
type Folder,
@@ -108,18 +108,6 @@ export async function createVideoForServerProcessing({
rawFileKey,
});
- if (buildEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production") {
- await dub()
- .links.create({
- url: `${serverEnv().WEB_URL}/s/${videoId}`,
- domain: "cap.link",
- key: videoId,
- })
- .catch((err) => {
- console.error("Dub link create failed", err);
- });
- }
-
revalidatePath("/dashboard/caps");
revalidatePath("/dashboard/folder");
revalidatePath("/dashboard/spaces");
diff --git a/apps/web/actions/video/upload.ts b/apps/web/actions/video/upload.ts
index f2be03256..43fe9d1fa 100644
--- a/apps/web/actions/video/upload.ts
+++ b/apps/web/actions/video/upload.ts
@@ -4,8 +4,8 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { videos, videoUploads } from "@cap/database/schema";
-import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";
-import { dub, userIsPro } from "@cap/utils";
+import { serverEnv } from "@cap/env";
+import { userIsPro } from "@cap/utils";
import { Storage as StorageService } from "@cap/web-backend";
import {
type Folder,
@@ -234,18 +234,6 @@ export async function createVideoAndGetUploadUrl({
videoId: idToUse,
});
- if (buildEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production") {
- await dub()
- .links.create({
- url: `${serverEnv().WEB_URL}/s/${idToUse}`,
- domain: "cap.link",
- key: idToUse,
- })
- .catch((err) => {
- console.error("Dub link create failed", err);
- });
- }
-
revalidatePath("/dashboard/caps");
revalidatePath("/dashboard/folder");
revalidatePath("/dashboard/spaces");
diff --git a/apps/web/app/api/desktop/[...route]/video.ts b/apps/web/app/api/desktop/[...route]/video.ts
index 02a932091..4d22e637b 100644
--- a/apps/web/app/api/desktop/[...route]/video.ts
+++ b/apps/web/app/api/desktop/[...route]/video.ts
@@ -11,8 +11,8 @@ import {
videoUploads,
} from "@cap/database/schema";
import type { VideoMetadata } from "@cap/database/types";
-import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";
-import { dub, userIsPro } from "@cap/utils";
+import { serverEnv } from "@cap/env";
+import { userIsPro } from "@cap/utils";
import { Storage } from "@cap/web-backend";
import { Organisation, Video } from "@cap/web-domain";
import { zValidator } from "@hono/zod-validator";
@@ -283,13 +283,6 @@ app.get(
mode: "singlepart",
});
- if (buildEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production")
- await dub().links.create({
- url: `${serverEnv().WEB_URL}/s/${idToUse}`,
- domain: "cap.link",
- key: idToUse,
- });
-
try {
const videoCount = await db()
.select({ count: count() })
@@ -301,9 +294,7 @@ app.get(
"[SendFirstShareableLinkEmail] Sending first shareable link email with 5-minute delay",
);
- const videoUrl = buildEnv.NEXT_PUBLIC_IS_CAP
- ? `https://cap.link/${idToUse}`
- : `${serverEnv().WEB_URL}/s/${idToUse}`;
+ const videoUrl = `${serverEnv().WEB_URL}/s/${idToUse}`;
await sendEmail({
email: user.email,
diff --git a/apps/web/components/pages/HomePage/InstantModeDetail.tsx b/apps/web/components/pages/HomePage/InstantModeDetail.tsx
index f67b1fdd0..f5483ae1d 100644
--- a/apps/web/components/pages/HomePage/InstantModeDetail.tsx
+++ b/apps/web/components/pages/HomePage/InstantModeDetail.tsx
@@ -229,7 +229,7 @@ const MockSharePage = () => {
</>
) : (
<>
- cap.link/m4k92x
+ cap.so/s/m4k92x
<Copy className="size-3 text-gray-9" />
</>
)}
diff --git a/apps/web/lib/Notification.ts b/apps/web/lib/Notification.ts
index 986387548..4a6482224 100644
--- a/apps/web/lib/Notification.ts
+++ b/apps/web/lib/Notification.ts
@@ -4,7 +4,7 @@ import { FirstView } from "@cap/database/emails/first-view";
import { NewComment } from "@cap/database/emails/new-comment";
import { nanoId } from "@cap/database/helpers";
import { comments, notifications, users, videos } from "@cap/database/schema";
-import { buildEnv, serverEnv } from "@cap/env";
+import { serverEnv } from "@cap/env";
import type { Notification, NotificationBase } from "@cap/web-api-contract";
import { Comment, User, Video } from "@cap/web-domain";
import { and, eq, gte, isNull, ne, or, sql } from "drizzle-orm";
@@ -307,9 +307,7 @@ async function sendNewCommentEmail(params: {
const commenterName = commenter?.name || "Someone";
- const videoUrl = buildEnv.NEXT_PUBLIC_IS_CAP
- ? `https://cap.link/${params.videoId}`
- : `${serverEnv().WEB_URL}/s/${params.videoId}`;
+ const videoUrl = `${serverEnv().WEB_URL}/s/${params.videoId}`;
await sendEmail({
email: recipient.email,
@@ -464,9 +462,7 @@ export async function sendFirstViewEmail(
viewerName = viewer?.name || viewer?.email || "Someone";
}
- const videoUrl = buildEnv.NEXT_PUBLIC_IS_CAP
- ? `https://cap.link/${params.videoId}`
- : `${serverEnv().WEB_URL}/s/${params.videoId}`;
+ const videoUrl = `${serverEnv().WEB_URL}/s/${params.videoId}`;
const displayName = videoWithOwner.videoName || "Untitled Video";
diff --git a/apps/web/lib/video-share-clipboard.ts b/apps/web/lib/video-share-clipboard.ts
index a7685abdf..2f39f39f9 100644
--- a/apps/web/lib/video-share-clipboard.ts
+++ b/apps/web/lib/video-share-clipboard.ts
@@ -9,6 +9,14 @@ const escapeHtml = (value: string) =>
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
+export const canonicalVideoShareUrl = (url: string) => {
+ const match = url.match(
+ /^https?:\/\/(?:www\.)?cap\.link\/([^/?#]+)([?#].*)?$/,
+ );
+ if (!match) return url;
+ return `https://cap.so/s/${match[1]}${match[2] ?? ""}`;
+};
+
export type RichVideoLink = {
/** The share URL to copy (may include ?t= timestamp). */
url: string;
@@ -28,7 +36,7 @@ export const richVideoLinkHtml = ({
title,
previewImageUrl,
}: RichVideoLink) => {
- const safeUrl = escapeHtml(url);
+ const safeUrl = escapeHtml(canonicalVideoShareUrl(url));
const safeTitle = escapeHtml(title);
const safeImage = escapeHtml(previewImageUrl);
// Keep the markup minimal and inline-styled — email clients strip most
@@ -50,6 +58,11 @@ export const richVideoLinkHtml = ({
* falling back to plain text. Must be called from a user gesture.
*/
export const copyRichVideoLink = async (link: RichVideoLink) => {
+ const canonicalLink = {
+ ...link,
+ url: canonicalVideoShareUrl(link.url),
+ };
+
try {
if (
typeof ClipboardItem !== "undefined" &&
@@ -57,8 +70,10 @@ export const copyRichVideoLink = async (link: RichVideoLink) => {
) {
await navigator.clipboard.write([
new ClipboardItem({
- "text/plain": new Blob([link.url], { type: "text/plain" }),
- "text/html": new Blob([richVideoLinkHtml(link)], {
+ "text/plain": new Blob([canonicalLink.url], {
+ type: "text/plain",
+ }),
+ "text/html": new Blob([richVideoLinkHtml(canonicalLink)], {
type: "text/html",
}),
}),
@@ -68,5 +83,5 @@ export const copyRichVideoLink = async (link: RichVideoLink) => {
} catch {
// Rich copy denied or unsupported — fall through to plain text.
}
- await navigator.clipboard.writeText(link.url);
+ await navigator.clipboard.writeText(canonicalLink.url);
};
diff --git a/packages/utils/src/lib/dub.ts b/packages/utils/src/lib/dub.ts
index b8f0383f8..64993a9ec 100644
--- a/packages/utils/src/lib/dub.ts
+++ b/packages/utils/src/lib/dub.ts
@@ -1,7 +1,5 @@
-import { serverEnv } from "@cap/env";
-import { Dub } from "dub";
-
-export const dub = () =>
- new Dub({
- token: serverEnv().DUB_API_KEY,
- });
+export const dub = () => ({
+ links: {
+ create: () => Promise.resolve(),
+ },
+});