@@ -50,15 +50,16 @@ class ResourceMapper {
5050 return this . resolveUrl ( hostname , pathname )
5151 }
5252
53- // Returns the URL for the relative path on the pod
53+ // Returns the URL corresponding to the relative path on the pod
5454 resolveUrl ( hostname , pathname = '' ) {
5555 return ! this . _includeHost ? `${ this . _rootUrl } ${ pathname } `
5656 : `${ this . _protocol } //${ hostname } ${ this . _port } ${ this . _rootUrl } ${ pathname } `
5757 }
5858
59- // Gets the base file path for the given host name
60- getBaseFilePath ( hostname ) {
61- return ! this . _includeHost ? this . _rootPath : `${ this . _rootPath } /${ hostname } `
59+ // Returns the file path corresponding to the relative file path on the pod
60+ resolveFilePath ( hostname , filePath = '' ) {
61+ return ! this . _includeHost ? `${ this . _rootPath } ${ filePath } `
62+ : `${ this . _rootPath } /${ hostname } ${ filePath } `
6263 }
6364
6465 // Maps a given server file to a URL
@@ -79,7 +80,7 @@ class ResourceMapper {
7980 async mapUrlToFile ( { url, contentType, createIfNotExists, searchIndex = true } ) {
8081 // Parse the URL and find the base file path
8182 const { pathname, hostname } = this . _parseUrl ( url )
82- let filePath = ` ${ this . getBaseFilePath ( hostname ) } ${ decodeURIComponent ( pathname ) } `
83+ const filePath = this . resolveFilePath ( hostname , decodeURIComponent ( pathname ) )
8384 if ( filePath . indexOf ( '/..' ) >= 0 ) {
8485 throw new Error ( 'Disallowed /.. segment in URL' )
8586 }
0 commit comments