Merge branch 'master' into payment

This commit is contained in:
biss committed 2026-08-23 09:04:31 +08:00
commit fc7293714c
4 files changed
+27 -14

No files matched your search

@@ -5,6 +5,11 @@ namespace Jiaowu.Api.Infrastructure.Files;
/// </summary>
public static class DownloadFileName
{
// Do not use Path.GetInvalidFileNameChars(): its result is platform-specific,
// while downloaded names must remain usable on Windows regardless of where
// the API is built or hosted.
private static readonly char[] WindowsInvalidFileNameChars = ['<', '>', ':', '"', '/', '\\', '|', '?', '*'];
public static string Export(string title, string extension, params string?[] parts) =>
Build(title, extension, includeTimestamp: true, parts);
@@ -33,9 +38,8 @@ public static class DownloadFileName
private static string Clean(string? value)
{
if (string.IsNullOrWhiteSpace(value)) return string.Empty;
var invalid = Path.GetInvalidFileNameChars();
var cleaned = new string(value.Trim().Select(character =>
invalid.Contains(character) ? '-' : character).ToArray());
WindowsInvalidFileNameChars.Contains(character) || char.IsControl(character) ? '-' : character).ToArray());
return cleaned.Trim('.', ' ');
}