fix: 修改文件拓展名获取逻辑
All checks were successful
deploy to server / build-and-deploy (push) Successful in 4m18s
All checks were successful
deploy to server / build-and-deploy (push) Successful in 4m18s
- 若无扩展名则返回空字符串
This commit is contained in:
@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user