deer social fork for personal usage. but you might see a use idk. github mirror
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

shutupup

Signed-off-by: ayla <ayla-git.barcode041@silomails.com>

ayla ae1f670d dbf0801d

+19 -17
+19 -17
src/lib/media/util.ts
··· 1 1 export function extractDataUriMime(uri: string): string { 2 - return uri.substring(uri.indexOf(':') + 1, uri.indexOf(';')) 2 + return uri.substring(uri.indexOf(":") + 1, uri.indexOf(";")); 3 3 } 4 4 5 5 // Fairly accurate estimate that is more performant 6 6 // than decoding and checking length of URI 7 7 export function getDataUriSize(uri: string): number { 8 - return Math.round((uri.length * 3) / 4) 8 + return Math.round((uri.length * 3) / 4); 9 9 } 10 10 11 11 export function isUriImage(uri: string): boolean { 12 - return /\.(jpg|jpeg|png|webp).*$/.test(uri) 12 + return /\.(jpg|jpeg|png|webp).*$/.test(uri); 13 13 } 14 14 15 15 export function blobToDataUri(blob: Blob): Promise<string> { 16 - return new Promise((resolve, reject) => { 17 - const reader = new FileReader() 18 - reader.onloadend = () => { 19 - if (typeof reader.result === 'string') { 20 - resolve(reader.result) 21 - } else { 22 - reject(new Error('Failed to read blob')) 23 - } 24 - } 25 - reader.onerror = reject 26 - reader.readAsDataURL(blob) 27 - }) 16 + return new Promise((resolve, reject) => { 17 + const reader = new FileReader(); 18 + reader.onloadend = () => { 19 + if (typeof reader.result === "string") { 20 + resolve(reader.result); 21 + } else { 22 + reject(new Error("Failed to read blob")); 23 + } 24 + }; 25 + reader.onerror = reject; 26 + reader.readAsDataURL(blob); 27 + }); 28 28 } 29 29 30 30 export function modifyImageFormat(uri: string, format: string) { 31 - const sliced = uri.slice(0, -4) 32 - return sliced.at(-1) === '@' ? sliced + format : `${uri}@${format}` 31 + const atPosition = uri.lastIndexOf("@"); 32 + return atPosition === -1 33 + ? `${uri}@${format}` 34 + : uri.slice(0, atPosition + 1) + format; 33 35 }