mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 06:51:13 -05:00
Refactor: Update CDN image delivery URLs
This commit is contained in:
@@ -12,17 +12,16 @@ export type CloudflareVariant =
|
||||
| 'logo'
|
||||
| 'public';
|
||||
|
||||
const CLOUDFLARE_ACCOUNT_HASH = import.meta.env.VITE_CLOUDFLARE_ACCOUNT_HASH;
|
||||
|
||||
/**
|
||||
* Build a Cloudflare image URL with specified variant
|
||||
* Uses CDN proxy for branded URLs
|
||||
*/
|
||||
export function getCloudflareImageUrl(
|
||||
imageId: string | undefined,
|
||||
variant: CloudflareVariant = 'public'
|
||||
): string | undefined {
|
||||
if (!imageId) return undefined;
|
||||
return `https://imagedelivery.net/${CLOUDFLARE_ACCOUNT_HASH}/${imageId}/${variant}`;
|
||||
return `https://cdn.thrillwiki.com/images/${imageId}/${variant}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,9 +52,14 @@ export function getBannerUrls(imageId: string | undefined) {
|
||||
|
||||
/**
|
||||
* Extract Cloudflare image ID from various URL formats
|
||||
* Supports both old imagedelivery.net and new CDN URLs
|
||||
*/
|
||||
export function extractCloudflareImageId(url: string): string | null {
|
||||
// Match imagedelivery.net URLs
|
||||
const match = url.match(/imagedelivery\.net\/[^\/]+\/([a-f0-9-]+)\//i);
|
||||
return match ? match[1] : null;
|
||||
// Match old imagedelivery.net URLs
|
||||
const deliveryMatch = url.match(/imagedelivery\.net\/[^\/]+\/([a-f0-9-]+)\//i);
|
||||
if (deliveryMatch) return deliveryMatch[1];
|
||||
|
||||
// Match new cdn.thrillwiki.com URLs
|
||||
const cdnMatch = url.match(/cdn\.thrillwiki\.com\/images\/([a-f0-9-]+)\//i);
|
||||
return cdnMatch ? cdnMatch[1] : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user