Skip to content

Commit 0621d7a

Browse files
committed
Fix usage of new URL API
Due to the deprecation of the old `url`-API provided by NodeJS we replaced `url.resolve` with `url.URL.resolve`, which doesn't exist. This patch fixes the local filesystem upload of CodiMD by using the new API correctly. Creating an URL object and using its href. Some more background: https://nodejs.org/api/url.html#url_url_href https://nodejs.org/api/url.html#url_url_resolve_from_to Fixes #1102 Signed-off-by: Sheogorath <[email protected]>
1 parent b40f14f commit 0621d7a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/web/imageRouter/filesystem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
const url = require('url')
2+
const URL = require('url').URL
33
const path = require('path')
44

55
const config = require('../../config')
@@ -16,5 +16,5 @@ exports.uploadImage = function (imagePath, callback) {
1616
return
1717
}
1818

19-
callback(null, url.URL.resolve(config.serverURL + '/uploads/', path.basename(imagePath)))
19+
callback(null, (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href)
2020
}

0 commit comments

Comments
 (0)