fix: 修改文件拓展名获取逻辑
All checks were successful
deploy to server / build-and-deploy (push) Successful in 4m18s

- 若无扩展名则返回空字符串
This commit is contained in:
2025-10-25 15:30:23 +08:00
parent f2634ca0f4
commit 75d4d40d39

View File

@ -11,7 +11,9 @@ export function formatFileSize(sizeInBytes: number): string {
} }
export function getFileExtension(filename: string): string { export function getFileExtension(filename: string): string {
return filename.split('.').pop() || ''; const lastDotIndex = filename.lastIndexOf('.');
if (lastDotIndex === -1) return ''; // 找不到拓展名
return filename.slice(lastDotIndex + 1);
} }
export function formatFileExtension(ext: string): string { export function formatFileExtension(ext: string): string {