Fix view engine path resolution

This commit is contained in:
Garrett Mills 2020-09-05 10:26:03 -05:00
parent dd38b2cda7
commit 642319ef1f
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -95,7 +95,15 @@ export default class ViewEngine extends LifecycleUnit {
*/ */
public template_path(...parts: string[]): string { public template_path(...parts: string[]): string {
if ( !this.template_dir ) throw new MissingTemplateDirectoryError() if ( !this.template_dir ) throw new MissingTemplateDirectoryError()
return path.resolve(this.template_dir, ...parts) let template_dir = this.template_dir
if ( template_dir.startsWith('file://') ) template_dir = template_dir.slice(7)
const resolved_path = path.resolve(template_dir, ...parts)
if ( resolved_path.startsWith('/') ) {
return `file://${resolved_path}`
} else {
return resolved_path
}
} }
/** /**