Skip to content

Commit

Permalink
Don't disable fetching internal: yet
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Sep 26, 2024
1 parent a3a72bc commit 68f4c89
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app/pipe/thumbnail.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class ThumbnailPipe implements PipeTransform {
) { }

transform(refs: (Ref | undefined)[], force = false): Observable<string> {
refs = refs.filter(ref => !ref?.url.startsWith('data:') && !ref?.url.startsWith('comment:') && !ref?.url.startsWith('internal:'));
for (const ref of refs) {
if (!ref) continue;
for (const plugin of ['plugin/thumbnail', 'plugin/image', 'plugin/video']) {
Expand All @@ -35,15 +34,16 @@ export class ThumbnailPipe implements PipeTransform {
}),
);
}
if (!this.validUrl(ref.url)) continue;
const embedPlugins = this.admin.getEmbeds(ref);
for (const plugin of ['plugin/image', 'plugin/video']) {
if (embedPlugins.includes(plugin)) return of(this.fetchUrl(ref.url, plugin));
}
}
if (force) {
for (const ref of refs) {
if (!ref) continue;
return of(this.fetchUrl(ref.url, 'plugin/image'));
if (!this.validUrl(ref?.url)) continue;
return of(this.fetchUrl(ref!.url, 'plugin/image'));
}
}
return of('');
Expand All @@ -57,6 +57,13 @@ export class ThumbnailPipe implements PipeTransform {
return url;
}

private validUrl(url?: string) {
return url
&& !url.startsWith('data:')
&& !url.startsWith('comment:')
// TODO: stop requesting internal: after cache migrates to cache: scheme
// && !url.startsWith('internal:');
}
}

function refUrl(ref: Ref, plugin: string) {
Expand Down

0 comments on commit 68f4c89

Please sign in to comment.