Skip to content

Commit eff6e04

Browse files
authored
Fix avoiding crash if URL is invalid
Signed-off-by: toshi0123 <7948737+toshi0123@users.noreply.github.com>
1 parent 4e596d7 commit eff6e04

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/web/imageRouter/filesystem.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@ exports.uploadImage = function (imagePath, callback) {
1616
return
1717
}
1818

19-
callback(null, (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href)
19+
let url
20+
try {
21+
url = (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href
22+
} catch (e) {
23+
url = config.serverURL + '/uploads/' + path.basename(imagePath)
24+
}
25+
26+
callback(null, url)
2027
}

0 commit comments

Comments
 (0)