Recover home previews through the documented storage alias

This commit is contained in:
Codex 2026-11-03 09:26:31 +08:00
parent e6c6e19e5a
commit dfab95a654

View File

@ -12,9 +12,24 @@ type HomeImageProps = {
onUnavailable?: () => void;
};
function imageCandidates(source: string) {
// These two domains are documented aliases for the same gongxiangpan store.
// Do not rewrite other buckets, providers, signed URLs or user-supplied hosts.
try {
const url = new URL(source);
if (url.origin === "https://s3.yydd.ai" &&
url.pathname.startsWith("/gongxiangpan/") && !url.search && !url.hash) {
return [`https://s3.jiansun.vip${url.pathname}`, source];
}
} catch { /* Relative site assets need no host rewrite. */ }
return [source];
}
/** Keep failed image elements out of view, trying each distinct source once. */
export function HomeImage(props: HomeImageProps) {
const sources = [...new Set(props.sources.filter((url): url is string => Boolean(url?.trim())))];
const sources = [...new Set(props.sources
.filter((url): url is string => Boolean(url?.trim()))
.flatMap(imageCandidates))];
return <HomeImageAttempt key={JSON.stringify(sources)} {...props} sources={sources} />;
}