start destructuring ZeroVue class

This commit is contained in:
2021-12-03 15:49:34 +01:00
parent b0c958ffb3
commit 3ad9714618
15 changed files with 264 additions and 84 deletions
+16 -1
View File
@@ -14,6 +14,20 @@ public class PhysicalFileSystem : IFileSystem
}
/// <inheritdoc />
public virtual string Map(string path)
{
return ResolvePath(path);
}
/// <inheritdoc />
public virtual string MapToPublicPath(string path)
{
return path.EnsureStartsWith('/');
}
/// <inheritdoc />
public virtual Task<bool> Exists(string path, CancellationToken cancellationToken = default)
{
@@ -268,10 +282,11 @@ public class PhysicalFileSystem : IFileSystem
path = path.Replace('\\', '/').FullTrim().Trim('/');
string physicalPath = Path.Combine(_root, path);
string rootPath = Path.GetFullPath(_root);
// do not allow paths which are outside this file system
// the boundaries are set be the basePath which is assigned in the file system constructor
if (!Path.GetFullPath(physicalPath).StartsWith(_root, StringComparison.InvariantCultureIgnoreCase))
if (!Path.GetFullPath(physicalPath).StartsWith(rootPath, StringComparison.InvariantCultureIgnoreCase))
{
throw new FileSystemException($"The path '{path}' is outside the file system");
}