Files
im/uni_modules/network-manage/utssdk/app-harmony/network/mime.uts
T
2025-12-27 07:08:30 +08:00

18 lines
693 B
Plaintext

export function lookupExt(contentType: string): string | undefined {
const rawContentType = contentType.split(';')[0].trim().toLowerCase()
return (UTSHarmony.getExtensionFromMimeType(rawContentType) as string | null) || undefined
}
export function lookupContentTypeWithUri(uri: string): string | undefined {
const uriArr = uri.split('.')
if (uriArr.length <= 1) {
return undefined
}
const ext = uriArr.pop() as string
return (UTSHarmony.getMimeTypeFromExtension(ext) as string | null) || undefined
}
export function lookupContentType(ext: string): string | undefined {
return (UTSHarmony.getMimeTypeFromExtension(ext) as string | null) || undefined
}