migrate to typescript

This commit is contained in:
MaysWind
2024-12-29 14:24:37 +08:00
parent b638a73e4d
commit 2560a70e5e
171 changed files with 3402 additions and 2557 deletions
+29
View File
@@ -0,0 +1,29 @@
import { isString } from './common.ts';
export function getFileExtension(filename: string): string {
if (!filename || !isString(filename)) {
return '';
}
const parts = filename.split('.');
return parts[parts.length - 1];
}
export function isFileExtensionSupported(filename: string, supportedExtensions: string): boolean {
if (!supportedExtensions) {
return false;
}
const supportedExtensionsArray = supportedExtensions.split(',');
const fileExtension = getFileExtension(filename).toLowerCase();
for (let i = 0; i < supportedExtensionsArray.length; i++) {
const supportedExtension = getFileExtension(supportedExtensionsArray[i]).toLowerCase();
if (supportedExtension === fileExtension) {
return true;
}
}
return false;
}