2022-02-07 16:52:09 +00:00
|
|
|
import { ImageOrVideo } from 'react-native-image-crop-picker';
|
|
|
|
|
2024-01-25 14:11:07 +00:00
|
|
|
import { isIOS } from '../../../lib/methods/helpers';
|
2022-02-07 16:52:09 +00:00
|
|
|
|
|
|
|
const regex = new RegExp(/\.[^/.]+$/); // Check from last '.' of the string
|
|
|
|
|
|
|
|
export const forceJpgExtension = (attachment: ImageOrVideo): ImageOrVideo => {
|
|
|
|
if (isIOS && attachment.mime === 'image/jpeg' && attachment.filename) {
|
|
|
|
// Replace files extension that mime type is 'image/jpeg' to .jpg;
|
|
|
|
attachment.filename = attachment.filename.replace(regex, '.jpg');
|
|
|
|
}
|
|
|
|
return attachment;
|
|
|
|
};
|