From c7a0b2207618339d6c183a3827acd603bc1462af Mon Sep 17 00:00:00 2001 From: lesion Date: Tue, 19 Mar 2019 23:55:44 +0100 Subject: [PATCH] fix #32 --- app/controller/user.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controller/user.js b/app/controller/user.js index a74015d9..ff7f1662 100644 --- a/app/controller/user.js +++ b/app/controller/user.js @@ -112,6 +112,14 @@ const userController = { return res.sendStatus(403) } + if (req.file) { + if (event.image_path) { + const old_path = path.resolve(__dirname, '..', '..', event.image_path) + await fs.unlink(old_path, e => console.error(e)) + } + body.image_path = req.file.path + } + body.description = body.description .replace(/(<([^>]+)>)/ig, '') // remove all tags from description .replace(/(https?:\/\/[^\s]+)/g, '$1') // add links