Minor fixes to proxying

This commit is contained in:
WardPearce
2024-08-26 09:24:24 +12:00
parent daef9d3587
commit 7d342de970
2 changed files with 14 additions and 2 deletions
+9 -1
View File
@@ -171,7 +171,15 @@ export function proxyVideoUrl(source: string): string {
}
export function proxyGoogleImage(source: string): string {
return `${get(instanceStore)}/ggpht${new URL(source).pathname}`;
let path: string | undefined;
try {
path = new URL(source).pathname;
} catch { }
if (typeof path === 'undefined') return '';
return `${get(instanceStore)}/ggpht${path}`;
}
export function unsafeRandomItem(array: any[]): any {
@@ -79,7 +79,11 @@
<div class="padding">
{#if data.channel.authorBanners.length > 0}
<img src={data.channel.authorBanners[0].url} width="100%" alt="Channel banner" />
<img
src={proxyGoogleImage(data.channel.authorBanners[0].url)}
width="100%"
alt="Channel banner"
/>
{/if}
<div class="description">
<img