mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Volo.Abp.VirtualFileSystem
|
|
{
|
|
internal static class VirtualFilePathHelper
|
|
{
|
|
//TODO: Optimize this class!
|
|
|
|
public static string NormalizePath(string fullPath)
|
|
{
|
|
var fileName = fullPath;
|
|
var extension = "";
|
|
|
|
if (fileName.Contains("."))
|
|
{
|
|
extension = fullPath.Substring(fileName.LastIndexOf(".", StringComparison.Ordinal));
|
|
if (extension.Contains("/"))
|
|
{
|
|
//That means the file does not have extension, but a directory has "." char. So, clear extension.
|
|
extension = "";
|
|
}
|
|
else
|
|
{
|
|
fileName = fullPath.Substring(0, fullPath.Length - extension.Length);
|
|
}
|
|
}
|
|
|
|
return NormalizeChars(fileName) + extension;
|
|
}
|
|
|
|
private static string NormalizeChars(string fileName)
|
|
{
|
|
var folderParts = fileName.Replace(".", "/").Split("/");
|
|
|
|
if (folderParts.Length == 1)
|
|
{
|
|
return folderParts[0];
|
|
}
|
|
|
|
return folderParts.Take(folderParts.Length - 1).Select(s => s.Replace("-", "_")).JoinAsString("/") + "/" + folderParts.Last();
|
|
}
|
|
}
|
|
}
|