diff --git a/src/services/image-utils.ts b/src/services/image-utils.ts index 3ff1365..009253e 100644 --- a/src/services/image-utils.ts +++ b/src/services/image-utils.ts @@ -2,21 +2,16 @@ export function getCdnUrl(): string { return 'https://cdn.weeb.vip'; } +/** + * Build a CDN URL for an image key. + * + * `src` is a record id — anime, character, staff. Images used to be keyed by a + * slug derived from the title, which meant lowercasing, underscoring and + * escaping it here to match how the sync services stored it. Ids need none of + * that. + */ export function getSafeImageUrl(src: string, path?: string): string { const cdnUrl = getCdnUrl(); - console.log("src", src, path); - // Replace %20 with + to match React SafeImage behavior exactly - const encodedSrc = src.toLowerCase().replace(/%20/g, "+"); - // Path handling - add trailing slash if path exists const pathPrefix = path ? `${path}/` : ""; - - // Return the properly encoded URL - only single encodeURIComponent like React - return `${cdnUrl}/${pathPrefix}${encodeURIComponent(escapeUri(encodedSrc))}`; -} - -function escapeUri(str: string): string { - return encodeURIComponent(str) - .replace(/[!'()*]/g, char => - '%' + char.charCodeAt(0).toString(16).toUpperCase() - ); + return `${cdnUrl}/${pathPrefix}${encodeURIComponent(src)}`; } diff --git a/src/views/index.tsx b/src/views/index.tsx index cc8fd49..30f4a50 100644 --- a/src/views/index.tsx +++ b/src/views/index.tsx @@ -179,11 +179,11 @@ function Index() {