fix(preview): show image preview instead of 'Conversion complete' for blob URLs

canBrowserPreview() was checking for a file extension in blob: URLs, which
have none (blob:http://localhost:1349/<uuid>). This caused the optimize-for-web
live preview — which stores a blob: URL in processedUrl — to always return false
and show the 'Conversion complete' fallback card instead of the BeforeAfterSlider.

Fix: blob: URLs are always renderable in <img> tags; short-circuit the extension
check with `if (url.startsWith('blob:')) return true` in both tool-page.tsx and
multi-image-viewer.tsx.
This commit is contained in:
Siddharth Kumar Sah
2026-04-15 18:52:36 +08:00
parent d4ac116c15
commit 0cf7156b7e
2 changed files with 4 additions and 1 deletions
@@ -18,6 +18,7 @@ const BROWSER_PREVIEWABLE_EXTS = new Set([
]);
function canBrowserPreview(url: string): boolean {
if (url.startsWith("blob:")) return true;
const ext = decodeURIComponent(url).split(".").pop()?.toLowerCase() ?? "";
return BROWSER_PREVIEWABLE_EXTS.has(ext);
}
+3 -1
View File
@@ -41,7 +41,9 @@ const BROWSER_PREVIEWABLE_EXTS = new Set([
]);
function canBrowserPreview(url: string, filename?: string | null): boolean {
// For blob URLs from batch processing, check the real filename instead
// Blob URLs are always renderable in <img> tags — no extension to check
if (url.startsWith("blob:")) return true;
// For batch results, check the stored filename (has extension) rather than the blob URL
const source = filename ?? url;
const ext = decodeURIComponent(source).split(".").pop()?.toLowerCase() ?? "";
return BROWSER_PREVIEWABLE_EXTS.has(ext);