import { ALLOWED_EXTENSIONS } from './constants' export function getFileName(filePath: string): string { return filePath.split(/[/\\]/).pop() || filePath } export function isAllowedFile(filePath: string): boolean { const ext = getFileExtension(filePath) return (ALLOWED_EXTENSIONS as readonly string[]).includes(ext) } // L-07: 无扩展名文件正确返回空字符串 export function getFileExtension(filePath: string): string { const name = filePath.split(/[/\\]/).pop() || filePath const dotIndex = name.lastIndexOf('.') if (dotIndex <= 0) return '' // 无扩展名或以 . 开头的隐藏文件 return name.substring(dotIndex).toLowerCase() }