mirror of
https://github.com/ngthanhvu/kr-phim.git
synced 2026-08-10 17:27:47 +00:00
21 lines
581 B
TypeScript
21 lines
581 B
TypeScript
/**
|
|
* Transform image URLs to use the internal image proxy.
|
|
* This converts remote images to WebP format for faster loading.
|
|
*/
|
|
export function proxyImageUrl(url: string): string {
|
|
if (!url) return ''
|
|
if (url.startsWith('/api/image-proxy')) return url
|
|
|
|
// Nếu đã có sẵn query params
|
|
const separator = url.includes('?') ? '&' : '?'
|
|
return `/api/image-proxy?url=${encodeURIComponent(url)}`
|
|
}
|
|
|
|
export function proxyThumbUrl(url: string): string {
|
|
return proxyImageUrl(url)
|
|
}
|
|
|
|
export function proxyPosterUrl(url: string): string {
|
|
return proxyImageUrl(url)
|
|
}
|