mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix(web+mobile): consistent filename handling (#2534)
This commit is contained in:
parent
6c6c5ef651
commit
7f0ad8e2d2
5 changed files with 78 additions and 25 deletions
|
|
@ -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}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue