mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 19:17:50 +00:00
Fixes: https://github.com/jitsi/jitsi-meet/issues/8510
This basically reverts
a3fb996ff0
while retaining the same properties that prompted it's original intent, namely
avoiding sending the Referrer header.
28 lines
599 B
JavaScript
28 lines
599 B
JavaScript
|
|
// @flow
|
|
|
|
import { isIconUrl } from './functions';
|
|
|
|
/**
|
|
* Tries to preload an image.
|
|
*
|
|
* @param {string | Object} src - Source of the avatar.
|
|
* @returns {Promise}
|
|
*/
|
|
export function preloadImage(src: string | Object): Promise<string> {
|
|
if (isIconUrl(src)) {
|
|
return Promise.resolve(src);
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
const image = document.createElement('img');
|
|
|
|
image.onload = () => resolve(src);
|
|
image.onerror = reject;
|
|
|
|
// $FlowExpectedError
|
|
image.referrerPolicy = 'no-referrer';
|
|
image.src = src;
|
|
});
|
|
}
|