Skip to content

Commit 22de319

Browse files
committed
Make logic for testing delete permissions less confusing
1 parent 84dbff3 commit 22de319

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/handlers/allow.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const fs = require('fs')
88
const { promisify } = require('util')
99
const HTTPError = require('../http-error')
1010

11-
function allow (mode, relativePath = '') {
11+
function allow (mode, testDirectory) {
1212
return async function allowHandler (req, res, next) {
1313
const ldp = req.app.locals.ldp || {}
1414
if (!ldp.webid) {
@@ -25,8 +25,8 @@ function allow (mode, relativePath = '') {
2525
: req.path
2626

2727
// If a relativePath has been provided, check permissions based on that
28-
if (relativePath) {
29-
reqPath = path.join(reqPath, relativePath)
28+
if (testDirectory) {
29+
reqPath = path.dirname(reqPath)
3030
}
3131

3232
// Check whether the resource exists

lib/ldp-middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function LdpMiddleware (corsSettings) {
2626
router.post('/*', allow('Append'), post)
2727
router.patch('/*', allow('Append'), patch)
2828
router.put('/*', allow('Write'), put)
29-
router.delete('/*', allow('Write', '..'), del)
29+
router.delete('/*', allow('Write', true), del)
3030

3131
return router
3232
}

0 commit comments

Comments
 (0)