From 75d4d40d39637a0639922f1fa588810d4bd645b7 Mon Sep 17 00:00:00 2001 From: R2m1liA <15258427350@163.com> Date: Sat, 25 Oct 2025 15:30:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=8B=93=E5=B1=95=E5=90=8D=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 若无扩展名则返回空字符串 --- app/utils/file.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/utils/file.ts b/app/utils/file.ts index f21e33a..0193c98 100644 --- a/app/utils/file.ts +++ b/app/utils/file.ts @@ -11,7 +11,9 @@ export function formatFileSize(sizeInBytes: number): 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 {