Recover home previews through the documented storage alias
This commit is contained in:
parent
e6c6e19e5a
commit
dfab95a654
@ -12,9 +12,24 @@ type HomeImageProps = {
|
|||||||
onUnavailable?: () => void;
|
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. */
|
/** Keep failed image elements out of view, trying each distinct source once. */
|
||||||
export function HomeImage(props: HomeImageProps) {
|
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} />;
|
return <HomeImageAttempt key={JSON.stringify(sources)} {...props} sources={sources} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user