@@ -44,8 +44,8 @@ class ResourceMapper {
4444 // Maps the request for a given resource and representation format to a server file
4545 // When searchIndex is true and the URL ends with a '/', and contentType includes 'text/html' indexFilename will be matched.
4646 async mapUrlToFile ( { url, contentType, createIfNotExists, searchIndex = true } ) {
47- let fullPath = this . getFullPath ( url )
48- let isIndex = searchIndex && fullPath . endsWith ( '/' )
47+ let fullFilePath = this . getFilePath ( url )
48+ let isIndex = searchIndex && fullFilePath . endsWith ( '/' )
4949 let path
5050
5151 // Append index filename if the URL ends with a '/'
@@ -54,21 +54,21 @@ class ResourceMapper {
5454 throw new Error ( `Index file needs to have ${ this . _indexContentType } as content type` )
5555 }
5656 if ( contentType && contentType . includes ( this . _indexContentType ) ) {
57- fullPath += this . _indexFilename
57+ fullFilePath += this . _indexFilename
5858 }
5959 }
6060 // Create the path for a new file
6161 if ( createIfNotExists ) {
62- path = fullPath
62+ path = fullFilePath
6363 // If the extension is not correct for the content type, append the correct extension
6464 if ( searchIndex && this . _getContentTypeByExtension ( path ) !== contentType ) {
6565 path += `$${ contentType in extensions ? `.${ extensions [ contentType ] [ 0 ] } ` : '.unknown' } `
6666 }
6767 // Determine the path of an existing file
6868 } else {
6969 // Read all files in the corresponding folder
70- const filename = fullPath . substr ( fullPath . lastIndexOf ( '/' ) + 1 )
71- const folder = fullPath . substr ( 0 , fullPath . length - filename . length )
70+ const filename = fullFilePath . substr ( fullFilePath . lastIndexOf ( '/' ) + 1 )
71+ const folder = fullFilePath . substr ( 0 , fullFilePath . length - filename . length )
7272
7373 // Find a file with the same name (minus the dollar extension)
7474 let match = searchIndex ? await this . _getMatchingFile ( folder , filename , isIndex , contentType ) : ''
@@ -79,7 +79,7 @@ class ResourceMapper {
7979 if ( isIndex ) {
8080 match = ''
8181 } else {
82- throw new HTTPError ( 404 , `File not found: ${ fullPath } ` )
82+ throw new HTTPError ( 404 , `File not found: ${ fullFilePath } ` )
8383 }
8484 }
8585 path = `${ folder } ${ match } `
@@ -101,17 +101,17 @@ class ResourceMapper {
101101 }
102102
103103 async getRepresentationUrlForResource ( resourceUrl ) {
104- let fullPath = this . getFullPath ( resourceUrl )
105- let isIndex = fullPath . endsWith ( '/' )
104+ let fullFilePath = this . getFilePath ( resourceUrl )
105+ let isIndex = fullFilePath . endsWith ( '/' )
106106
107107 // Append index filename if the URL ends with a '/'
108108 if ( isIndex ) {
109- fullPath += this . _indexFilename
109+ fullFilePath += this . _indexFilename
110110 }
111111
112112 // Read all files in the corresponding folder
113- const filename = fullPath . substr ( fullPath . lastIndexOf ( '/' ) + 1 )
114- const folder = fullPath . substr ( 0 , fullPath . length - filename . length )
113+ const filename = fullFilePath . substr ( fullFilePath . lastIndexOf ( '/' ) + 1 )
114+ const folder = fullFilePath . substr ( 0 , fullFilePath . length - filename . length )
115115 const files = await this . _readdir ( folder )
116116
117117 // Find a file with the same name (minus the dollar extension)
@@ -141,13 +141,13 @@ class ResourceMapper {
141141 }
142142
143143 // Determine the full file path corresponding to a URL
144- getFullPath ( url ) {
144+ getFilePath ( url ) {
145145 const { pathname, hostname } = this . _parseUrl ( url )
146- const fullPath = decodeURIComponent ( `${ this . getBasePath ( hostname ) } ${ pathname } ` )
147- if ( fullPath . indexOf ( '/..' ) >= 0 ) {
146+ const fullFilePath = decodeURIComponent ( `${ this . getBasePath ( hostname ) } ${ pathname } ` )
147+ if ( fullFilePath . indexOf ( '/..' ) >= 0 ) {
148148 throw new Error ( 'Disallowed /.. segment in URL' )
149149 }
150- return fullPath
150+ return fullFilePath
151151 }
152152
153153 // Parses a URL into a hostname and pathname
0 commit comments