mirror of https://github.com/status-im/codimd.git
Merge pull request #1196 from toshi0123/fix_avoiding_crash
Fix avoiding crash if URL is invalid
This commit is contained in:
commit
440661f1ce
|
@ -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