Skip to content

Commit d9f662d

Browse files
committed
Removed ldp.getRequestUri, reusing ldp.resourceMapper.resolveUrl instead
1 parent f4d43c7 commit d9f662d

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

lib/handlers/get.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ async function globHandler (req, res, next) {
134134
const ldp = req.app.locals.ldp
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.
137-
const filename = ldp.resourceMapper._getFullPath(req)
138-
const requestUri = await ldp.getRequestUri(filename, req.hostname)
137+
const requestUri = await ldp.resourceMapper.resolveUrl(req.hostname, req.path)
139138

140139
const globOptions = {
141140
noext: true,
142141
nobrace: true,
143142
nodir: true
144143
}
145144

145+
const filename = ldp.getFullPath(req)
146146
glob(filename, globOptions, function (err, matches) {
147147
if (err || matches.length === 0) {
148148
debugGlob('No files matching the pattern')

lib/handlers/post.js

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

lib/handlers/put.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function putAcl (req, res, next) {
3737
const ldp = req.app.locals.ldp
3838
const contentType = req.get('content-type')
3939
const path = ldp.getFullPath(req)
40-
const requestUri = await ldp.getRequestUri(path, req.hostname)
40+
const requestUri = await ldp.resourceMapper.resolveUrl(req.hostname, path)
4141
if (ldp.isValidRdf(req.body, requestUri, contentType)) {
4242
const stream = stringToStream(req.body)
4343
return putStream(req, res, next, stream)

lib/ldp.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,6 @@ class LDP {
467467
return this.resourceMapper._getFullPath(req)
468468
}
469469

470-
async getRequestUri (path, hostname) {
471-
return (await this.resourceMapper.mapFileToUrl({ path, hostname })).url
472-
}
473-
474470
static mimeTypeIsRdf (mimeType) {
475471
return RDF_MIME_TYPES.has(mimeType)
476472
}

0 commit comments

Comments
 (0)