fix(images): ship Linux codecs and preserve original-image fallback

Vendor the locked sharp Linux runtime and verify it during Docker builds. Add complete image response lengths and persistent frontend fallbacks, with real-codec HTTP and isolated release regression tests. Refresh tested API, admin and customer release artifacts.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
mahmood
2026-11-26 18:12:21 +03:30
co-authored by Claude Code
parent a085c279f8
commit 3e9f532c6c
346 changed files with 33359 additions and 240 deletions
+29 -1
View File
@@ -1,3 +1,5 @@
import { shallowRef } from 'vue'
// Uploaded images through the API's resize endpoint (GET /api/img/:file?w=).
// Anything that is not a plain upload path (blob:, data:, bundled assets,
// absolute URLs) is returned untouched.
@@ -11,6 +13,32 @@ export function imageUrl(url: string | null | undefined, width: ImageWidth): str
const prefix = UPLOAD_PREFIXES.find((p) => url.startsWith(p))
if (!prefix) return url
const name = url.slice(prefix.length)
if (!name || name.includes('/')) return url
// Preserve encoded names, query strings and fragments as actual original URLs.
if (!name || /[/\\%?#]/.test(name)) return url
return `/api/img/${encodeURIComponent(name)}?w=${width}`
}
/** Only invert our generated resize URLs, never external/blob/data images. */
export function originalImageUrl(url: string): string | undefined {
const prefix = '/api/img/'
if (!url.startsWith(prefix)) return undefined
try {
const name = decodeURIComponent(url.slice(prefix.length).split(/[?#]/, 1)[0] ?? '')
if (!name || name === '.' || name === '..' || /[/\\\u0000]/.test(name)) return undefined
return `/uploads/${encodeURIComponent(name)}`
} catch {
return undefined
}
}
/** Reactive state prevents a later render from restoring a failed thumbnail. */
export function useImageFallback() {
const failed = shallowRef<ReadonlySet<string>>(new Set())
const imageSource = (url: string | undefined): string | undefined =>
url && failed.value.has(url) ? originalImageUrl(url) ?? url : url
function imageFailed(url: string | undefined) {
if (!url || failed.value.has(url) || !originalImageUrl(url)) return
failed.value = new Set([...failed.value, url])
}
return { imageSource, imageFailed }
}