28 lines
387 B
JavaScript
28 lines
387 B
JavaScript
const fileType = (typeString) => {
|
|
let type = 'unknown'
|
|
|
|
if (typeString.match(/text\/html/)) {
|
|
type = 'html'
|
|
}
|
|
|
|
if (typeString.match(/image/)) {
|
|
type = 'image'
|
|
}
|
|
|
|
if (typeString.match(/video/)) {
|
|
type = 'video'
|
|
}
|
|
|
|
if (typeString.match(/audio/)) {
|
|
type = 'audio'
|
|
}
|
|
|
|
return type
|
|
}
|
|
|
|
const fileTypeService = {
|
|
fileType
|
|
}
|
|
|
|
export default fileTypeService
|