@@ -8,7 +8,7 @@ const fs = require('fs')
88const { promisify } = require ( 'util' )
99const HTTPError = require ( '../http-error' )
1010
11- function allow ( mode , testDirectory ) {
11+ function allow ( mode , checkPermissionsForDirectory ) {
1212 return async function allowHandler ( req , res , next ) {
1313 const ldp = req . app . locals . ldp || { }
1414 if ( ! ldp . webid ) {
@@ -20,31 +20,31 @@ function allow (mode, testDirectory) {
2020
2121 // Determine the actual path of the request
2222 // (This is used as an ugly hack to check the ACL status of other resources.)
23- let reqPath = res && res . locals && res . locals . path
23+ let resourcePath = res && res . locals && res . locals . path
2424 ? res . locals . path
2525 : req . path
2626
27- // If a relativePath has been provided, check permissions based on that
28- if ( testDirectory ) {
29- reqPath = path . dirname ( reqPath )
27+ // Check permissions of the directory instead of the file itself.
28+ if ( checkPermissionsForDirectory ) {
29+ resourcePath = path . dirname ( resourcePath )
3030 }
3131
3232 // Check whether the resource exists
3333 let stat
3434 try {
35- const ret = await ldp . exists ( req . hostname , reqPath )
35+ const ret = await ldp . exists ( req . hostname , resourcePath )
3636 stat = ret . stream
3737 } catch ( err ) {
3838 stat = null
3939 }
4040
4141 // Ensure directories always end in a slash
42- if ( ! reqPath . endsWith ( '/' ) && stat && stat . isDirectory ( ) ) {
43- reqPath += '/'
42+ if ( ! resourcePath . endsWith ( '/' ) && stat && stat . isDirectory ( ) ) {
43+ resourcePath += '/'
4444 }
4545
4646 // Obtain and store the ACL of the requested resource
47- req . acl = new ACL ( rootUrl + reqPath , {
47+ req . acl = new ACL ( rootUrl + resourcePath , {
4848 agentOrigin : req . get ( 'origin' ) ,
4949 // host: req.get('host'),
5050 fetch : fetchFromLdp ( ldp . resourceMapper ) ,
0 commit comments