Sync latest web IM fixes
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
function configuredProxyHosts() {
|
||||
const configured = window.JC_WEB_IM_CONFIG?.mediaProxyHosts;
|
||||
const values = Array.isArray(configured)
|
||||
? configured
|
||||
: String(configured || '').split(/[\s,]+/);
|
||||
return new Set(
|
||||
values
|
||||
.map(value => String(value || '').trim().toLowerCase().replace(/\.$/, ''))
|
||||
.filter(Boolean)
|
||||
);
|
||||
}
|
||||
|
||||
export function imageDisplayUrl(value) {
|
||||
const source = String(value || '').trim();
|
||||
if (!source || source.startsWith('blob:') || source.startsWith('data:')) {
|
||||
return source;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(source, window.location.origin);
|
||||
if (url.protocol !== 'https:' || !configuredProxyHosts().has(url.hostname.toLowerCase())) {
|
||||
return source;
|
||||
}
|
||||
const proxyUrl = new URL('/api/media_proxy.php', window.location.origin);
|
||||
proxyUrl.searchParams.set('url', url.toString());
|
||||
return proxyUrl.toString();
|
||||
} catch (error) {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user