From eff6e04e2bf9bab1aee2e29666819277b6f9effc Mon Sep 17 00:00:00 2001 From: toshi0123 <7948737+toshi0123@users.noreply.github.com> Date: Thu, 18 Apr 2019 19:10:46 +0900 Subject: [PATCH] Fix avoiding crash if URL is invalid Signed-off-by: toshi0123 <7948737+toshi0123@users.noreply.github.com> --- lib/web/imageRouter/filesystem.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/web/imageRouter/filesystem.js b/lib/web/imageRouter/filesystem.js index 7c876d66..a43a2782 100644 --- a/lib/web/imageRouter/filesystem.js +++ b/lib/web/imageRouter/filesystem.js @@ -16,5 +16,12 @@ exports.uploadImage = function (imagePath, callback) { return } - callback(null, (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href) + let url + try { + url = (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href + } catch (e) { + url = config.serverURL + '/uploads/' + path.basename(imagePath) + } + + callback(null, url) }