Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: handle subdomains & scroll for custom domain dialog (#889)

Ameer Al Ashhabd70e25bf2da9
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/VerifyStep.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/VerifyStep.tsx
index 3b0e40df1..defcb5cf7 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/VerifyStep.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/VerifyStep.tsx
@@ -3,6 +3,7 @@ import clsx from "clsx";
import { Check, Copy } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "sonner";
+import { parse } from "tldts";
import { useDashboardContext } from "@/app/(org)/dashboard/Contexts";
import type { DomainConfig, DomainVerification } from "./types";
@@ -54,6 +55,25 @@ const VerifyStep = ({
return [];
};
+ const isSubdomain = (raw: string): boolean => {
+ // Normalize and extract host (no scheme, path, port, or trailing dot)
+ const input =
+ raw
+ .trim()
+ .replace(/^https?:\/\//i, "")
+ .split("/")[0] ?? "";
+ if (!input) return false;
+ const host = (input.replace(/\.$/, "").split(":")[0] || "").toLowerCase();
+ try {
+ // Prefer PSL-backed parsing for correctness (e.g., co.uk, com.au)
+ const { subdomain } = parse(host);
+ return Boolean(subdomain);
+ } catch {
+ // Fallback: conservative heuristic
+ const parts = host.split(".");
+ return parts.length > 2;
+ }
+ };
const recommendedAValues = getRecommendedAValues();
// Check if DNS records are already correctly configured
@@ -63,8 +83,8 @@ const VerifyStep = ({
const cnameConfigured =
recommendedCnames.length > 0 &&
recommendedCnames.some((rec) => currentCnames.includes(rec.value));
-
- const showARecord = recommendedARecord && !aRecordConfigured;
+ const showARecord =
+ recommendedAValues.length > 0 && !aRecordConfigured && !isSubdomain(domain);
const showCNAMERecord = hasRecommendedCNAME && !cnameConfigured;
const showTXTRecord = hasTXTVerification && !isVerified;
@@ -124,7 +144,7 @@ const VerifyStep = ({
) : (
!isVerified &&
domainConfig && (
- <div className="space-y-4">
+ <div className="custom-scroll px-1 h-full max-h-[300px] space-y-4">
{/* TXT Record Configuration for Verification */}
{showTXTRecord && (
<div className="overflow-hidden rounded-lg border border-gray-4">
diff --git a/apps/web/app/api/playlist/route.ts b/apps/web/app/api/playlist/route.ts
index 59fd563ef..b9330229a 100644
--- a/apps/web/app/api/playlist/route.ts
+++ b/apps/web/app/api/playlist/route.ts
@@ -41,7 +41,7 @@ class Api extends HttpApi.make("CapWebApi").add(
.addError(HttpApiError.InternalServerError)
.addError(HttpApiError.NotFound),
),
-) { }
+) {}
const ApiLive = HttpApiBuilder.api(Api).pipe(
Layer.provide(
@@ -198,11 +198,13 @@ const getPlaylistResponse = (
const generatedPlaylist = generateMasterPlaylist(
videoMetadata?.Metadata?.resolution ?? "",
videoMetadata?.Metadata?.bandwidth ?? "",
- `${serverEnv().WEB_URL}/api/playlist?userId=${video.ownerId
+ `${serverEnv().WEB_URL}/api/playlist?userId=${
+ video.ownerId
}&videoId=${video.id}&videoType=video`,
audioMetadata
- ? `${serverEnv().WEB_URL}/api/playlist?userId=${video.ownerId
- }&videoId=${video.id}&videoType=audio`
+ ? `${serverEnv().WEB_URL}/api/playlist?userId=${
+ video.ownerId
+ }&videoId=${video.id}&videoType=audio`
: null,
);
diff --git a/apps/web/app/api/video/delete/route.ts b/apps/web/app/api/video/delete/route.ts
index f4e3657ea..b2bde7d11 100644
--- a/apps/web/app/api/video/delete/route.ts
+++ b/apps/web/app/api/video/delete/route.ts
@@ -6,7 +6,6 @@ import {
HttpApiEndpoint,
HttpApiError,
HttpApiGroup,
- HttpServerResponse,
} from "@effect/platform";
import { Effect, Layer, Schema } from "effect";
import { apiToHandler } from "@/lib/server";
@@ -19,7 +18,7 @@ class Api extends HttpApi.make("Api").add(
.addError(HttpApiError.Forbidden)
.addError(HttpApiError.NotFound),
),
-) { }
+) {}
const ApiLive = HttpApiBuilder.api(Api).pipe(
Layer.provide(
diff --git a/apps/web/package.json b/apps/web/package.json
index f0f9c754a..56307e69a 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -113,6 +113,7 @@
"subtitles-parser-vtt": "^0.1.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
+ "tldts": "^7.0.11",
"uuid": "^9.0.1",
"zod": "^3.25.76"
},
diff --git a/packages/web-backend/src/S3Buckets/index.ts b/packages/web-backend/src/S3Buckets/index.ts
index 9a74178aa..0d4507d8e 100644
--- a/packages/web-backend/src/S3Buckets/index.ts
+++ b/packages/web-backend/src/S3Buckets/index.ts
@@ -13,28 +13,26 @@ export class S3Buckets extends Effect.Service<S3Buckets>()("S3Buckets", {
const repo = yield* S3BucketsRepo;
const defaultConfigs = {
- publicEndpoint:
- yield* Config.string("S3_PUBLIC_ENDPOINT").pipe(
- Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
- Config.option,
- Effect.flatten,
- Effect.catchTag("NoSuchElementException", () =>
- Effect.dieMessage(
- "Neither S3_PUBLIC_ENDPOINT nor CAP_AWS_ENDPOINT provided",
- ),
+ publicEndpoint: yield* Config.string("S3_PUBLIC_ENDPOINT").pipe(
+ Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
+ Config.option,
+ Effect.flatten,
+ Effect.catchTag("NoSuchElementException", () =>
+ Effect.dieMessage(
+ "Neither S3_PUBLIC_ENDPOINT nor CAP_AWS_ENDPOINT provided",
),
),
- internalEndpoint:
- yield* Config.string("S3_INTERNAL_ENDPOINT").pipe(
- Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
- Config.option,
- Effect.flatten,
- Effect.catchTag("NoSuchElementException", () =>
- Effect.dieMessage(
- "Neither S3_INTERNAL_ENDPOINT nor CAP_AWS_ENDPOINT provided",
- ),
+ ),
+ internalEndpoint: yield* Config.string("S3_INTERNAL_ENDPOINT").pipe(
+ Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
+ Config.option,
+ Effect.flatten,
+ Effect.catchTag("NoSuchElementException", () =>
+ Effect.dieMessage(
+ "Neither S3_INTERNAL_ENDPOINT nor CAP_AWS_ENDPOINT provided",
),
),
+ ),
region: yield* Config.string("CAP_AWS_REGION"),
accessKey: yield* Config.string("CAP_AWS_ACCESS_KEY"),
secretKey: yield* Config.string("CAP_AWS_SECRET_KEY"),
@@ -181,4 +179,4 @@ export class S3Buckets extends Effect.Service<S3Buckets>()("S3Buckets", {
};
}),
dependencies: [S3BucketsRepo.Default],
-}) { }
+}) {}
diff --git a/packages/web-backend/src/Videos/index.ts b/packages/web-backend/src/Videos/index.ts
index 44fe2e622..81d8bc031 100644
--- a/packages/web-backend/src/Videos/index.ts
+++ b/packages/web-backend/src/Videos/index.ts
@@ -18,10 +18,12 @@ export class Videos extends Effect.Service<Videos>()("Videos", {
// This is only for external use since it does an access check,
// internal use should prefer the repo directly
getById: (id: Video.VideoId) =>
- repo.getById(id).pipe(
- Policy.withPublicPolicy(policy.canView(id)),
- Effect.withSpan("Videos.getById"),
- ),
+ repo
+ .getById(id)
+ .pipe(
+ Policy.withPublicPolicy(policy.canView(id)),
+ Effect.withSpan("Videos.getById"),
+ ),
/*
* Delete a video. Will fail if the user does not have access.
@@ -104,4 +106,4 @@ export class Videos extends Effect.Service<Videos>()("Videos", {
};
}),
dependencies: [VideosPolicy.Default, VideosRepo.Default, S3Buckets.Default],
-}) { }
+}) {}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d886fd36b..6a8feac05 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -726,6 +726,9 @@ importers:
tailwindcss-animate:
specifier: ^1.0.7
+ tldts:
+ specifier: ^7.0.11
+ version: 7.0.11
uuid:
specifier: ^9.0.1
version: 9.0.1
@@ -12713,10 +12716,17 @@ packages:
resolution: {integrity: sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==}
+ resolution: {integrity: sha512-65eeOpBwWBabh0XqT+zB0vEllq/V3XcrF2fhgMXWWFfNw1yxEjeYg9Vv/B/UNozd0CTR/TohO1ubfn6O6mBW3w==}
+
resolution: {integrity: sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==}
hasBin: true
+ resolution: {integrity: sha512-7k7JV/LZpGhFUu2t+YDaMZ1wdPPRNpaCYNQ0NQbSLY3Rbgy+XbCdkXyqRiS9TLXiYAsrv0yiA0OvnxmgRFCdNA==}
+ hasBin: true
+
resolution: {integrity: sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==}
@@ -22224,8 +22234,8 @@ snapshots:
'@typescript-eslint/parser': 5.62.0([email protected]([email protected]))([email protected])
eslint: 9.30.1([email protected])
eslint-import-resolver-node: 0.3.9
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
eslint-plugin-jsx-a11y: 6.10.2([email protected]([email protected]))
eslint-plugin-react: 7.37.5([email protected]([email protected]))
eslint-plugin-react-hooks: 4.6.2([email protected]([email protected]))
@@ -22253,33 +22263,33 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.0([email protected])
- eslint: 9.30.1([email protected])
+ eslint: 8.57.1
get-tsconfig: 4.10.0
is-bun-module: 2.0.0
stable-hash: 0.0.5
tinyglobby: 0.2.13
unrs-resolver: 1.7.2
optionalDependencies:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.0([email protected])
- eslint: 8.57.1
+ eslint: 9.30.1([email protected])
get-tsconfig: 4.10.0
is-bun-module: 2.0.0
stable-hash: 0.0.5
tinyglobby: 0.2.13
unrs-resolver: 1.7.2
optionalDependencies:
transitivePeerDependencies:
- supports-color
@@ -22294,14 +22304,14 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 5.62.0([email protected]([email protected]))([email protected])
eslint: 9.30.1([email protected])
eslint-import-resolver-node: 0.3.9
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
transitivePeerDependencies:
- supports-color
@@ -22345,7 +22355,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8
@@ -22356,7 +22366,7 @@ snapshots:
doctrine: 2.1.0
eslint: 9.30.1([email protected])
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.16.1
is-glob: 4.0.3
@@ -27848,10 +27858,16 @@ snapshots:
+
dependencies:
tldts-core: 6.1.86
+ dependencies:
+ tldts-core: 7.0.11
+
dependencies:
tmp: 0.2.3