Skip to content

Commit b1e2931

Browse files
committed
feat(vercel): extract buildVercelDeploymentUrl helper
Introduce buildVercelDeploymentUrl to centralize construction of Vercel deployment URLs and replace inline URL building in presenters. - Add buildVercelDeploymentUrl to vercelProjectIntegrationSchema.ts. It strips the "dpl_" prefix from integrationDeploymentId and returns the canonical Vercel URL. - Update DeploymentListPresenter and DeploymentPresenter to import and use the new helper instead of duplicating string assembly. This reduces duplicated logic, ensures consistent URL formatting, and makes future URL-related changes easier to maintain.
1 parent d4c1b4d commit b1e2931

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

apps/webapp/app/presenters/v3/DeploymentListPresenter.server.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
1010
import { type User } from "~/models/user.server";
1111
import { processGitMetadata } from "./BranchesPresenter.server";
1212
import { BranchTrackingConfigSchema, getTrackedBranchForEnvironment } from "~/v3/github";
13-
import { VercelProjectIntegrationDataSchema } from "~/v3/vercel/vercelProjectIntegrationSchema";
13+
import {
14+
VercelProjectIntegrationDataSchema,
15+
buildVercelDeploymentUrl,
16+
} from "~/v3/vercel/vercelProjectIntegrationSchema";
1417

1518
const pageSize = 20;
1619

@@ -232,8 +235,11 @@ LIMIT ${pageSize} OFFSET ${pageSize * (page - 1)};`;
232235

233236
let vercelDeploymentUrl: string | null = null;
234237
if (hasVercelIntegration && deployment.integrationDeploymentId && vercelTeamSlug && vercelProjectName) {
235-
const vercelId = deployment.integrationDeploymentId.replace(/^dpl_/, "");
236-
vercelDeploymentUrl = `https://vercel.com/${vercelTeamSlug}/${vercelProjectName}/${vercelId}`;
238+
vercelDeploymentUrl = buildVercelDeploymentUrl(
239+
vercelTeamSlug,
240+
vercelProjectName,
241+
deployment.integrationDeploymentId
242+
);
237243
}
238244

239245
return {

apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
1212
import { type User } from "~/models/user.server";
1313
import { getUsername } from "~/utils/username";
1414
import { processGitMetadata } from "./BranchesPresenter.server";
15-
import { VercelProjectIntegrationDataSchema } from "~/v3/vercel/vercelProjectIntegrationSchema";
15+
import {
16+
VercelProjectIntegrationDataSchema,
17+
buildVercelDeploymentUrl,
18+
} from "~/v3/vercel/vercelProjectIntegrationSchema";
1619
import { S2 } from "@s2-dev/streamstore";
1720
import { env } from "~/env.server";
1821
import { createRedisClient } from "~/redis.server";
@@ -201,8 +204,11 @@ export class DeploymentPresenter {
201204
});
202205

203206
if (integrationDeployment) {
204-
const vercelId = integrationDeployment.integrationDeploymentId.replace(/^dpl_/, "");
205-
vercelDeploymentUrl = `https://vercel.com/${parsed.data.vercelTeamSlug}/${parsed.data.vercelProjectName}/${vercelId}`;
207+
vercelDeploymentUrl = buildVercelDeploymentUrl(
208+
parsed.data.vercelTeamSlug,
209+
parsed.data.vercelProjectName,
210+
integrationDeployment.integrationDeploymentId
211+
);
206212
}
207213
}
208214
}

apps/webapp/app/v3/vercel/vercelProjectIntegrationSchema.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ export function shouldSyncEnvVarForAnyEnvironment(
202202
return false;
203203
}
204204

205+
export function buildVercelDeploymentUrl(
206+
vercelTeamSlug: string | undefined,
207+
vercelProjectName: string,
208+
integrationDeploymentId: string
209+
): string {
210+
const vercelId = integrationDeploymentId.replace(/^dpl_/, "");
211+
return `https://vercel.com/${vercelTeamSlug}/${vercelProjectName}/${vercelId}`;
212+
}
213+
205214
export function isPullEnvVarsEnabledForEnvironment(
206215
pullEnvVarsBeforeBuild: EnvSlug[] | null | undefined,
207216
environmentType: TriggerEnvironmentType

0 commit comments

Comments
 (0)