mirror of https://github.com/status-im/codimd.git
Fix avoiding crash if URL is invalid
Signed-off-by: toshi0123 <7948737+toshi0123@users.noreply.github.com>
This commit is contained in:
parent
4e596d724d
commit
eff6e04e2b
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue