File tree Expand file tree Collapse file tree 2 files changed +9
-22
lines changed Expand file tree Collapse file tree 2 files changed +9
-22
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,15 @@ function allow (mode, checkPermissionsForDirectory) {
56
56
if ( mode === 'Read' && ( resourcePath === '' || resourcePath === '/' ) ) {
57
57
// This is a hack to make NSS check the ACL for representation that is served for root (if any)
58
58
// See https://github.com/solid/node-solid-server/issues/1063 for more info
59
- const representationUrl = await ldp . resourceMapper . getRepresentationUrlForResource ( resourceUrl )
60
- if ( representationUrl . endsWith ( 'index.html' ) ) {
61
- // We ONLY want to do this when the representation we return is a HTML file
59
+ const representationUrl = `${ rootUrl } /index.html`
60
+ let representationPath
61
+ try {
62
+ representationPath = await ldp . resourceMapper . mapUrlToFile ( { url : representationUrl } )
63
+ } catch ( err ) {
64
+ }
65
+
66
+ // We ONLY want to do this when the HTML representation exists
67
+ if ( representationPath ) {
62
68
req . acl = ACL . createFromLDPAndRequest ( representationUrl , ldp , req )
63
69
const representationIsAllowed = await req . acl . can ( userId , mode )
64
70
if ( representationIsAllowed ) {
Original file line number Diff line number Diff line change @@ -100,25 +100,6 @@ class ResourceMapper {
100
100
}
101
101
}
102
102
103
- async getRepresentationUrlForResource ( resourceUrl ) {
104
- let fullFilePath = this . _getFilePath ( resourceUrl )
105
- let isIndex = fullFilePath . endsWith ( '/' )
106
-
107
- // Append index filename if the URL ends with a '/'
108
- if ( isIndex ) {
109
- fullFilePath += this . _indexFilename
110
- }
111
-
112
- // Read all files in the corresponding folder
113
- const filename = fullFilePath . substr ( fullFilePath . lastIndexOf ( '/' ) + 1 )
114
- const folder = fullFilePath . substr ( 0 , fullFilePath . length - filename . length )
115
- const files = await this . _readdir ( folder )
116
-
117
- // Find a file with the same name (minus the dollar extension)
118
- let match = ( files . find ( f => this . _removeDollarExtension ( f ) === filename || ( isIndex && f . startsWith ( this . _indexFilename + '.' ) ) ) )
119
- return `${ resourceUrl } ${ match || '' } `
120
- }
121
-
122
103
// Maps a given server file to a URL
123
104
async mapFileToUrl ( { path, hostname } ) {
124
105
// Determine the URL by chopping off everything after the dollar sign
You can’t perform that action at this time.
0 commit comments