1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-15 03:30:33 +02:00

fix(web+mobile): consistent filename handling (#2534)

This commit is contained in:
Michel Heusschen
2023-05-28 03:53:29 +02:00
committed by GitHub
parent 6c6c5ef651
commit 7f0ad8e2d2
5 changed files with 78 additions and 25 deletions

View File

@ -108,8 +108,17 @@ export async function bulkDownload(
* an empty string when not found.
*/
export function getFilenameExtension(filename: string): string {
const lastIndex = filename.lastIndexOf('.');
return filename.slice(lastIndex + 1).toLowerCase();
const lastIndex = Math.max(0, filename.lastIndexOf('.'));
const startIndex = (lastIndex || Infinity) + 1;
return filename.slice(startIndex).toLowerCase();
}
/**
* Returns the filename of an asset including file extension
*/
export function getAssetFilename(asset: AssetResponseDto): string {
const fileExtension = getFilenameExtension(asset.originalPath);
return `${asset.originalFileName}.${fileExtension}`;
}
/**