File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 1- import { proxify } from '../utils/proxify.ts' ;
1+ import { proxify , proxifyImage } from '../utils/proxify.ts' ;
22import type { ActionAdapter } from './ActionConfig.ts' ;
33import type {
44 ActionError ,
@@ -37,7 +37,7 @@ export class Action {
3737 }
3838
3939 public get icon ( ) {
40- return proxify ( this . _data . icon ) . toString ( ) ;
40+ return proxifyImage ( this . _data . icon ) . toString ( ) ;
4141 }
4242
4343 public get title ( ) {
Original file line number Diff line number Diff line change @@ -21,13 +21,30 @@ export function setProxyUrl(url: string): void {
2121
2222export function proxify ( url : string ) : URL {
2323 const baseUrl = new URL ( url ) ;
24- if ( baseUrl . hostname === 'localhost' || baseUrl . hostname === '127.0.0.1' ) {
24+ if ( shouldIgnoreProxy ( baseUrl ) ) {
2525 return baseUrl ;
2626 }
27- if ( ! proxyUrl ) {
27+ const proxifiedUrl = new URL ( proxyUrl ! ) ;
28+ proxifiedUrl . searchParams . set ( 'url' , url ) ;
29+ return proxifiedUrl ;
30+ }
31+
32+ export function proxifyImage ( url : string ) : URL {
33+ const baseUrl = new URL ( url ) ;
34+ if ( shouldIgnoreProxy ( baseUrl ) ) {
2835 return baseUrl ;
2936 }
30- const proxifiedUrl = new URL ( proxyUrl ) ;
37+ const proxifiedUrl = new URL ( ` ${ proxyUrl ! } /image` ) ;
3138 proxifiedUrl . searchParams . set ( 'url' , url ) ;
3239 return proxifiedUrl ;
3340}
41+
42+ function shouldIgnoreProxy ( url : URL ) : boolean {
43+ if ( url . hostname === 'localhost' || url . hostname === '127.0.0.1' ) {
44+ return true ;
45+ }
46+ if ( ! proxyUrl ) {
47+ return true ;
48+ }
49+ return false ;
50+ }
You can’t perform that action at this time.
0 commit comments