1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +00:00

fix heic format rotate image (#7430)

This commit is contained in:
Michael An
2025-02-06 10:50:09 +08:00
committed by GitHub
parent fef0d63712
commit a96990ebbc
3 changed files with 66 additions and 2 deletions

View File

@@ -27,7 +27,8 @@ const ImageDialog = ({ enableRotate: oldEnableRotate, imageItems, imageIndex, cl
// The backend server does not support rotating HEIC images
let enableRotate = oldEnableRotate;
const suffix = mainImg.src.slice(mainImg.src.lastIndexOf('.') + 1, mainImg.src.lastIndexOf('?')).toLowerCase();
const urlParts = mainImg.src.split('?')[0].split('.');
const suffix = urlParts[urlParts.length - 1];
if (suffix === 'heic') {
enableRotate = false;
}

View File

@@ -0,0 +1,63 @@
import { Utils } from "../../utils/utils";
describe('getFileExtension', () => {
it('should return the file extension with dot', () => {
const fileName = 'document.pdf';
const result = Utils.getFileExtension(fileName, false);
expect(result).toBe('.pdf');
});
it('should return the file extension without dot', () => {
const fileName = 'image.jpeg';
const result = Utils.getFileExtension(fileName, true);
expect(result).toBe('jpeg');
});
it('should handle filenames with multiple dots', () => {
const fileName = 'archive.tar.gz';
const resultWithDot = Utils.getFileExtension(fileName, false);
const resultWithoutDot = Utils.getFileExtension(fileName, true);
expect(resultWithDot).toBe('.gz');
expect(resultWithoutDot).toBe('gz');
});
it('should handle filenames with upper case extensions', () => {
const fileName = 'movie.MP4';
const result = Utils.getFileExtension(fileName, true);
expect(result).toBe('mp4');
});
it('should handle file name with special characters', () => {
const fileName = '/repo/349d72de-e342-4461-a10a-45265c9cb4c2/raw/HEIC/arec4-j1qmq%20(1).heic';
const result = Utils.getFileExtension(fileName, true);
expect(result).toBe('heic');
});
});
describe('bytesToSize', () => {
it('should return empty string if bytes is undefined', () => {
const result = Utils.bytesToSize(undefined);
expect(result).toBe(' ');
});
it('should return double dash if bytes is negative', () => {
const result = Utils.bytesToSize(-1);
expect(result).toBe('--');
});
it('should return bytes with unit if bytes is 0', () => {
const result = Utils.bytesToSize(0);
expect(result).toBe('0 B');
});
it('should return bytes with unit if bytes is positive', () => {
const result = Utils.bytesToSize(1000);
expect(result).toBe('1.0 KB');
});
it('should handle different units', () => {
const result = Utils.bytesToSize(1000 * 1000);
expect(result).toBe('1.0 MB');
});
it('should handle different units', () => {
const result = Utils.bytesToSize(1000 * 1000 * 1000);
expect(result).toBe('1.0 GB');
});
it('should handle different units', () => {
const result = Utils.bytesToSize(1000 * 1000 * 1000 * 1000);
expect(result).toBe('1.0 TB');
});
});

View File

@@ -4,7 +4,7 @@ export const defaultContentForSDoc = {
};
export const dirPath = '/';
export const gettext = window.gettext;
export const gettext = window.gettext || ((str) => str);
export const internalFilePath = '/_Internal/seatable-integration.json';