@@ -14,37 +14,27 @@ function getFileStorageBaseUrl(): string {
1414 return getConfigValue ( 'APPFLOWY_BASE_URL' , '' ) + '/api/file_storage' ;
1515}
1616
17- let cachedAppflowyOrigin : string | null | undefined ;
18- let cachedFileStoragePathname : string | null | undefined ;
19-
2017function resolveAppflowyOriginAndPathname ( ) : { origin : string | null ; pathname : string | null } {
21- if ( cachedAppflowyOrigin !== undefined && cachedFileStoragePathname !== undefined ) {
22- return { origin : cachedAppflowyOrigin , pathname : cachedFileStoragePathname } ;
23- }
24-
2518 const baseUrl = getConfigValue ( 'APPFLOWY_BASE_URL' , '' ) . trim ( ) ;
2619
2720 if ( baseUrl ) {
2821 try {
2922 const parsed = new URL ( baseUrl ) ;
3023
31- cachedAppflowyOrigin = parsed . origin ;
32- cachedFileStoragePathname = `${ parsed . pathname . replace ( / \/ $ / , '' ) } /api/file_storage` ;
33- return { origin : cachedAppflowyOrigin , pathname : cachedFileStoragePathname } ;
24+ return {
25+ origin : parsed . origin ,
26+ pathname : `${ parsed . pathname . replace ( / \/ $ / , '' ) } /api/file_storage` ,
27+ } ;
3428 } catch ( error ) {
3529 console . warn ( 'Invalid APPFLOWY_BASE_URL provided:' , error ) ;
3630 }
3731 }
3832
3933 if ( typeof window !== 'undefined' && window . location ?. origin ) {
40- cachedAppflowyOrigin = window . location . origin ;
41- cachedFileStoragePathname = '/api/file_storage' ;
42- return { origin : cachedAppflowyOrigin , pathname : cachedFileStoragePathname } ;
34+ return { origin : window . location . origin , pathname : '/api/file_storage' } ;
4335 }
4436
45- cachedAppflowyOrigin = null ;
46- cachedFileStoragePathname = null ;
47- return { origin : cachedAppflowyOrigin , pathname : cachedFileStoragePathname } ;
37+ return { origin : null , pathname : null } ;
4838}
4939
5040
0 commit comments