@@ -50,15 +50,16 @@ class ResourceMapper {
50
50
return this . resolveUrl ( hostname , pathname )
51
51
}
52
52
53
- // Returns the URL for the relative path on the pod
53
+ // Returns the URL corresponding to the relative path on the pod
54
54
resolveUrl ( hostname , pathname = '' ) {
55
55
return ! this . _includeHost ? `${ this . _rootUrl } ${ pathname } `
56
56
: `${ this . _protocol } //${ hostname } ${ this . _port } ${ this . _rootUrl } ${ pathname } `
57
57
}
58
58
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 } `
62
63
}
63
64
64
65
// Maps a given server file to a URL
@@ -79,7 +80,7 @@ class ResourceMapper {
79
80
async mapUrlToFile ( { url, contentType, createIfNotExists, searchIndex = true } ) {
80
81
// Parse the URL and find the base file path
81
82
const { pathname, hostname } = this . _parseUrl ( url )
82
- let filePath = ` ${ this . getBaseFilePath ( hostname ) } ${ decodeURIComponent ( pathname ) } `
83
+ const filePath = this . resolveFilePath ( hostname , decodeURIComponent ( pathname ) )
83
84
if ( filePath . indexOf ( '/..' ) >= 0 ) {
84
85
throw new Error ( 'Disallowed /.. segment in URL' )
85
86
}
0 commit comments