hedgedoc/lib/utils.js
pierreozoux afc801b1c3 Makes the mime also work with upper case extension
Signed-off-by: pierreozoux <pierre@ozoux.net>
2020-11-12 21:06:09 +01:00

27 lines
587 B
JavaScript

'use strict'
exports.isSQLite = function isSQLite (sequelize) {
return sequelize.options.dialect === 'sqlite'
}
exports.getImageMimeType = function getImageMimeType (imagePath) {
var fileExtension = /[^.]+$/.exec(imagePath)
switch (fileExtension[0].toLowerCase()) {
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'
case 'svg':
return 'image/svg+xml'
default:
return undefined
}
}