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) {
5656 if ( mode === 'Read' && ( resourcePath === '' || resourcePath === '/' ) ) {
5757 // This is a hack to make NSS check the ACL for representation that is served for root (if any)
5858 // 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 ) {
6268 req . acl = ACL . createFromLDPAndRequest ( representationUrl , ldp , req )
6369 const representationIsAllowed = await req . acl . can ( userId , mode )
6470 if ( representationIsAllowed ) {
Original file line number Diff line number Diff line change @@ -100,25 +100,6 @@ class ResourceMapper {
100100 }
101101 }
102102
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-
122103 // Maps a given server file to a URL
123104 async mapFileToUrl ( { path, hostname } ) {
124105 // Determine the URL by chopping off everything after the dollar sign
You can’t perform that action at this time.
0 commit comments