提交
This commit is contained in:
+12
@@ -103,6 +103,18 @@ export function activityUrl(env: Env, activityId: string): string {
|
||||
return `${baseUrl(env)}/activities/${activityId}`;
|
||||
}
|
||||
|
||||
export function mediaCdnBaseUrl(env: Env): string | null {
|
||||
const value = (env.MEDIA_BASE_URL ?? "").trim();
|
||||
if (!value) return null;
|
||||
return value.replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
export function mediaUrl(env: Env, r2Key: string): string {
|
||||
const cdn = mediaCdnBaseUrl(env);
|
||||
if (cdn) return `${cdn}/${r2Key.split("/").map(encodeURIComponent).join("/")}`;
|
||||
return `${baseUrl(env)}/media/${encodeURIComponent(r2Key)}`;
|
||||
}
|
||||
|
||||
export function isLocalActor(env: Env, actorId: string): boolean {
|
||||
try {
|
||||
return new URL(actorId).host === hostFromBaseUrl(env);
|
||||
|
||||
Reference in New Issue
Block a user