Replace hard coded impl in getImageMimeType

Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
Yukai Huang 2020-12-23 15:43:14 +08:00
parent 7a88f9d95a
commit c1a22a5318
No known key found for this signature in database
GPG Key ID: D4D3B2F0E99D4914
1 changed files with 2 additions and 17 deletions

View File

@ -2,29 +2,14 @@
const fs = require('fs')
const path = require('path')
const bodyParser = require('body-parser')
const mime = require('mime-types')
exports.isSQLite = function isSQLite (sequelize) {
return sequelize.options.dialect === 'sqlite'
}
exports.getImageMimeType = function getImageMimeType (imagePath) {
const fileExtension = /[^.]+$/.exec(imagePath)
switch (fileExtension[0]) {
case 'bmp':
return 'image/bmp'
case 'gif':
return 'image/gif'
case 'jpg':
case 'jpeg':
return 'image/jpeg'
case 'png':
return 'image/png'
case 'tiff':
return 'image/tiff'
default:
return undefined
}
return mime.contentType(path.extname(imagePath))
}
exports.isRevealTheme = function isRevealTheme (theme) {