Skip to content

Commit 7dfb378

Browse files
committed
Trying to reuse a method for creating URIs in get handler
1 parent 75c0e11 commit 7dfb378

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/handlers/put.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ async function putStream (req, res, next, stream = req) {
3636
async function putAcl (req, res, next) {
3737
const ldp = req.app.locals.ldp
3838
const contentType = req.get('content-type')
39-
const requestUri = `${req.protocol}//${req.get('host')}${req.originalUrl}`
39+
const path = ldp.getFullPath(req)
40+
const requestUri = await ldp.getRequestUri(path, req.hostname)
4041
if (ldp.isValidRdf(req.body, requestUri, contentType)) {
4142
const stream = stringToStream(req.body)
4243
return putStream(req, res, next, stream)

lib/ldp.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,14 @@ class LDP {
463463
return ensureNotExists(this, path.join(containerURI, filename))
464464
}
465465

466+
getFullPath (req) {
467+
return this.resourceMapper._getFullPath(req)
468+
}
469+
470+
async getRequestUri (path, hostname) {
471+
return (await this.resourceMapper.mapFileToUrl({ path, hostname })).url
472+
}
473+
466474
static mimeTypeIsRdf (mimeType) {
467475
return RDF_MIME_TYPES.has(mimeType)
468476
}

0 commit comments

Comments
 (0)