@@ -68,11 +68,9 @@ class ResourceMapper {
6868 // Read all files in the corresponding folder
6969 const filename = fullPath . substr ( fullPath . lastIndexOf ( '/' ) + 1 )
7070 const folder = fullPath . substr ( 0 , fullPath . length - filename . length )
71- const files = await this . _readdir ( folder )
7271
7372 // Find a file with the same name (minus the dollar extension)
74- let match = ! searchIndex ? '' : ( files . find ( f => this . _removeDollarExtension ( f ) === filename ||
75- ( isIndex && f . startsWith ( this . _indexFilename + '.' ) ) ) )
73+ let match = searchIndex ? await this . _getMatchingFile ( folder , filename , isIndex ) : ''
7674 if ( match === undefined ) {
7775 // Error if no match was found,
7876 // unless the URL ends with a '/',
@@ -90,6 +88,14 @@ class ResourceMapper {
9088 return { path, contentType : contentType || this . _defaultContentType }
9189 }
9290
91+ async _getMatchingFile ( folder , filename , isIndex ) {
92+ const files = await this . _readdir ( folder )
93+
94+ // Find a file with the same name (minus the dollar extension)
95+ return ( files . find ( f => this . _removeDollarExtension ( f ) === filename ||
96+ ( isIndex && f . startsWith ( this . _indexFilename + '.' ) && ! f . endsWith ( '.acl' ) ) ) )
97+ }
98+
9399 async getRepresentationUrlForResource ( resourceUrl ) {
94100 let fullPath = this . getFullPath ( resourceUrl )
95101 let isIndex = fullPath . endsWith ( '/' )
0 commit comments