summaryrefslogtreecommitdiff
path: root/packages/client/src/scripts/media-proxy.ts
blob: 506cb7829136b1c693be4adcdbdb28718f63088a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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,
		...(type ? { [type]: "1" } : {}),
	})}`;
}

export function getProxiedImageUrlNullable(imageUrl: string | null | undefined, type?: 'preview'): string | null {
	if (imageUrl == null) return null;
	return getProxiedImageUrl(imageUrl, type);
}