mirror of https://github.com/status-im/codimd.git
Replace hard coded impl in getImageMimeType
Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
parent
7a88f9d95a
commit
c1a22a5318
19
lib/utils.js
19
lib/utils.js
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue