perf(projects): 增强文件校验的兼容性 (#1931)

This commit is contained in:
青菜白玉汤
2024-11-10 17:02:31 +08:00
committed by GitHub
parent 7d9af64f6d
commit f63803529a
5 changed files with 21 additions and 17 deletions
+16 -12
View File
@@ -106,17 +106,21 @@ export const getUrl = (url) => {
}
}
export const isVideoExt = (url) =>
url.endsWith('.mp4') ||
url.endsWith('.mov') ||
url.endsWith('.webm') ||
url.endsWith('.ogg')
const VIDEO_EXTENSIONS = ['.mp4', '.mov', '.webm', '.ogg']
const VIDEO_MIME_TYPES = ['video/mp4', 'video/webm', 'video/ogg']
const IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/svg+xml']
export const isVideoMime = (type) =>
type == 'video/mp4' || type == 'video/webm' || type == 'video/ogg'
export const isVideoExt = (url) => {
const urlLower = url?.toLowerCase() || ''
return urlLower !== '' && VIDEO_EXTENSIONS.some(ext => urlLower.endsWith(ext))
}
export const isImageMime = (type) =>
type == 'image/jpeg' ||
type == 'image/png' ||
type == 'image/webp' ||
type == 'image/svg+xml'
export const isVideoMime = (type) => {
const typeLower = type?.toLowerCase() || ''
return typeLower !== '' && VIDEO_MIME_TYPES.includes(typeLower)
}
export const isImageMime = (type) => {
const typeLower = type?.toLowerCase() || ''
return typeLower !== '' && IMAGE_MIME_TYPES.includes(typeLower)
}