mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -05:00
Fix checkUploadType after upgrade to file-type 17
This package is now ESM-only, so we need to `import()` it and raise the oldest supported Node version. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
b6a2a618bb
commit
6acb23f26d
2 changed files with 3 additions and 3 deletions
|
@ -3,7 +3,6 @@
|
|||
const Router = require('express').Router
|
||||
const formidable = require('formidable')
|
||||
const path = require('path')
|
||||
const FileType = require('file-type')
|
||||
const fs = require('fs')
|
||||
const os = require('os')
|
||||
const rimraf = require('rimraf')
|
||||
|
@ -17,7 +16,8 @@ const imageRouter = (module.exports = Router())
|
|||
|
||||
async function checkUploadType (filePath) {
|
||||
const extension = path.extname(filePath).toLowerCase()
|
||||
let typeFromMagic = await FileType.fromFile(filePath)
|
||||
const FileType = await import('file-type')
|
||||
let typeFromMagic = await FileType.fileTypeFromFile(filePath)
|
||||
if (extension === '.svg' && (typeFromMagic === undefined || typeFromMagic.mime === 'application/xml')) {
|
||||
const fileContent = fs.readFileSync(filePath)
|
||||
if (isSvg(fileContent)) {
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
"**/request": "^2.88.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "12.x || 14.x || 16.x"
|
||||
"node": "^12.20.0 || ^14.13.1 || 16.x"
|
||||
},
|
||||
"bugs": "https://github.com/hedgedoc/hedgedoc/issues",
|
||||
"keywords": [
|
||||
|
|
Loading…
Reference in a new issue