make virtual file system return the root directory

pull/3801/head
liangshiwei 5 years ago
parent 4a30772f99
commit f48466ed72

@ -11,7 +11,7 @@ namespace Volo.Abp.VirtualFileSystem
public virtual IFileInfo GetFileInfo(string subpath)
{
if (string.IsNullOrEmpty(subpath))
if (subpath == null)
{
return new NotFoundFileInfo(subpath);
}
@ -67,4 +67,4 @@ namespace Volo.Abp.VirtualFileSystem
return subpath;
}
}
}
}

@ -10,6 +10,11 @@ namespace Volo.Abp.VirtualFileSystem
public static string NormalizePath(string fullPath)
{
if (fullPath == "/")
{
return string.Empty;
}
var fileName = fullPath;
var extension = "";
@ -29,7 +34,7 @@ namespace Volo.Abp.VirtualFileSystem
return NormalizeChars(fileName) + extension;
}
private static string NormalizeChars(string fileName)
{
var folderParts = fileName.Replace(".", "/").Split("/");
@ -42,4 +47,4 @@ namespace Volo.Abp.VirtualFileSystem
return folderParts.Take(folderParts.Length - 1).Select(s => s.Replace("-", "_")).JoinAsString("/") + "/" + folderParts.Last();
}
}
}
}

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
@ -47,6 +48,21 @@ namespace Volo.Abp.VirtualFileSystem
contentList.ShouldContain(x => x.Name == "jquery-3-1-1-min.js");
}
[Theory]
[InlineData("/")]
[InlineData("")]
public void Should_Define_And_Get_Embedded_Root_Directory_Contents(string path)
{
//Act
var contents = _virtualFileProvider.GetDirectoryContents(path);
//Assert
contents.Exists.ShouldNotBeNull();
var contentList = contents.ToList();
contentList.ShouldContain(x => x.Name == "js");
}
[DependsOn(typeof(AbpVirtualFileSystemModule))]
public class TestModule : AbpModule
{

Loading…
Cancel
Save