Skip to content

Commit f4d43c7

Browse files
committed
Refactored two other handlers that used similar functionality
1 parent 7dfb378 commit f4d43c7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/handlers/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async function globHandler (req, res, next) {
135135
// TODO: This is a hack, that does not check if the target file exists, as this is quite complex with globbing.
136136
// TODO: Proper support for this is not implemented, as globbing support might be removed in the future.
137137
const filename = ldp.resourceMapper._getFullPath(req)
138-
const requestUri = (await ldp.resourceMapper.mapFileToUrl({ path: filename, hostname: req.hostname })).url
138+
const requestUri = await ldp.getRequestUri(filename, req.hostname)
139139

140140
const globOptions = {
141141
noext: true,

lib/handlers/post.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ async function handler (req, res, next) {
5656
const busboy = new Busboy({ headers: req.headers })
5757
busboy.on('file', async function (fieldname, file, filename, encoding, mimetype) {
5858
debug('One file received via multipart: ' + filename)
59-
const { url: putUrl } = await ldp.resourceMapper.mapFileToUrl(
60-
{ path: ldp.resourceMapper._rootPath + path.join(containerPath, filename), hostname: req.hostname })
59+
const filePath = ldp.resourceMapper._rootPath + path.join(containerPath, filename)
60+
const url = await ldp.getRequestUri(filePath, req.hostname)
6161
try {
62-
await ldp.put(putUrl, file, mimetype)
62+
await ldp.put(url, file, mimetype)
6363
} catch (err) {
6464
busboy.emit('error', err)
6565
}

0 commit comments

Comments
 (0)