|
|
@ -19,11 +19,7 @@ const isImage = (name: string, mimetype?: string) => { |
|
|
|
return imageExt.some((e) => name?.toLowerCase().endsWith(`.${e}`)) || mimetype?.startsWith('image/') |
|
|
|
return imageExt.some((e) => name?.toLowerCase().endsWith(`.${e}`)) || mimetype?.startsWith('image/') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isImageUrl = (url: string) => { |
|
|
|
export { isImage, imageExt } |
|
|
|
return imageExt.some((e) => url?.toLowerCase().endsWith(`.${e}`)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export { isImage, imageExt, isImageUrl } |
|
|
|
|
|
|
|
// Ref : https://stackoverflow.com/a/12002275
|
|
|
|
// Ref : https://stackoverflow.com/a/12002275
|
|
|
|
|
|
|
|
|
|
|
|
// Tested in Mozilla Firefox browser, Chrome
|
|
|
|
// Tested in Mozilla Firefox browser, Chrome
|
|
|
@ -83,6 +79,8 @@ export function extractImageSrcFromRawHtml(rawText: string) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function populateUniqueFileName(fn: string, attachments: any[], mimeType: string) { |
|
|
|
export function populateUniqueFileName(fn: string, attachments: any[], mimeType: string) { |
|
|
|
|
|
|
|
if (!mimeType) return fn |
|
|
|
|
|
|
|
|
|
|
|
// If the image extension is not present, the while loop will go into an infinite loop. So, add the extension first if not present.
|
|
|
|
// If the image extension is not present, the while loop will go into an infinite loop. So, add the extension first if not present.
|
|
|
|
if (!fn?.endsWith(mimeType.split('/')[1])) { |
|
|
|
if (!fn?.endsWith(mimeType.split('/')[1])) { |
|
|
|
fn = `${fn}.${mimeType.split('/')[1]}` |
|
|
|
fn = `${fn}.${mimeType.split('/')[1]}` |
|
|
|