Browse Source

Merge pull request #23794 from abpframework/AbpEmbeddedFileProvider

Improve virtual file provider path resolution
pull/23800/head
Engincan VESKE 4 months ago
committed by GitHub
parent
commit
f314bb4b4e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DictionaryBasedFileProvider.cs
  2. 32
      framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/AbpEmbeddedFileProvider.cs

2
framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DictionaryBasedFileProvider.cs

@ -16,7 +16,7 @@ public abstract class DictionaryBasedFileProvider : IFileProvider
return new NotFoundFileInfo(subpath!); return new NotFoundFileInfo(subpath!);
} }
var file = Files.GetOrDefault(NormalizePath(subpath)); var file = Files.GetOrDefault(NormalizePath(subpath)) ?? Files.GetOrDefault(subpath);
if (file == null) if (file == null)
{ {

32
framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/AbpEmbeddedFileProvider.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions;
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders;
@ -129,10 +130,35 @@ public class AbpEmbeddedFileProvider : DictionaryBasedFileProvider
return resourceName; return resourceName;
} }
var folder = pathParts.Take(pathParts.Length - 2).JoinAsString("/"); if (pathParts.Length >= 4 && (pathParts[pathParts.Length - 2] == "min" || pathParts[pathParts.Length - 2] == "rtl"))
var fileName = pathParts[pathParts.Length - 2] + "." + pathParts[pathParts.Length - 1]; {
// Fix NET 10 RC 1 Microsoft.Extensions.FileProviders.Embedded issue temporarily
//https://github.com/dotnet/aspnetcore/issues/63719
pathParts = pathParts[pathParts.Length - 3] == "bundle"
? pathParts.Take(pathParts.Length - 4).Concat([pathParts.Skip(pathParts.Length - 4).JoinAsString(".")]).ToArray()
: pathParts.Take(pathParts.Length - 3).Concat([pathParts.Skip(pathParts.Length - 3).JoinAsString(".")]).ToArray();
if (pathParts.Length <= 2)
{
return resourceName;
}
var folder = pathParts.Take(pathParts.Length - 1).JoinAsString("/").Replace("_", "-");
var fileName = pathParts[pathParts.Length - 1].Replace("_", "-");
return folder + "/" + fileName;
}
else
{
if (pathParts.Length <= 2)
{
return resourceName;
}
var folder = pathParts.Take(pathParts.Length - 2).JoinAsString("/");
var fileName = pathParts[pathParts.Length - 2] + "." + pathParts[pathParts.Length - 1];
return folder + "/" + fileName; return folder + "/" + fileName;
}
} }
private static string CalculateFileName(string filePath) private static string CalculateFileName(string filePath)

Loading…
Cancel
Save