build: 为项目创建单元测试框架 #45
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user