rudeshark.net/packages/client/src/scripts/media-proxy.ts
ThatOneCalculator dc0243b8ea
fix
2023-02-01 11:55:45 -08:00

19 lines
478 B
TypeScript

import { query } from "@/scripts/url";
import { url } from "@/config";
export function getProxiedImageUrl(imageUrl: string, type?: "preview"): string {
return `${url}/proxy/image.webp?${query({
url: imageUrl,
fallback: "1",
...(type ? { [type]: "1" } : {}),
})}`;
}
export function getProxiedImageUrlNullable(
imageUrl: string | null | undefined,
type?: "preview",
): string | null {
if (imageUrl == null) return null;
return getProxiedImageUrl(imageUrl, type);
}