The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/tests/mocks/client/blobUrls.ts

23 lines
537 B

import uuid from 'uuid';
export const enableBlobUrlsMock = (): void => {
const urlByBlob = new WeakMap<Blob, string>();
const blobByUrl = new Map<string, Blob>();
window.URL.createObjectURL = (blob: Blob): string => {
const url = urlByBlob.get(blob) ?? `blob://${uuid.v4()}`;
urlByBlob.set(blob, url);
blobByUrl.set(url, blob);
return url;
};
window.URL.revokeObjectURL = (url: string): void => {
const blob = blobByUrl.get(url);
if (!blob) {
return;
}
urlByBlob.delete(blob);
blobByUrl.delete(url);
};
};