mirror of
https://github.com/status-im/codimd.git
synced 2025-01-11 23:14:24 +00:00
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…
x
Reference in New Issue
Block a user