rudeshark.net/packages/client/src/scripts/media-proxy.ts

19 lines
478 B
TypeScript
Raw Normal View History

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