account for file:// when resolving app paths

This commit is contained in:
Garrett Mills 2020-09-05 10:33:44 -05:00
parent a7d0f92da2
commit f97a68b129
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -132,7 +132,17 @@ export default class Application {
* @return string
*/
path(...parts: string[]) {
return path.resolve(this.root, ...parts)
let root = this.root
if ( root.startsWith('file://') ) {
root = root.slice(7)
}
const resolved = path.resolve(root, ...parts)
if ( resolved.startsWith('/') ) {
return `file://${resolved}`
} else {
return resolved
}
}
/**
@ -141,6 +151,16 @@ export default class Application {
* @return string
*/
app_path(...parts: string[]) {
return path.resolve(this.app_root, ...parts)
let app_root = this.app_root
if ( app_root.startsWith('file://') ) {
app_root = app_root.slice(7)
}
const resolved = path.resolve(app_root, ...parts)
if ( resolved.startsWith('/') ) {
return `file://${resolved}`
} else {
return resolved
}
}
}