Use PowerKit's Uri.TryGetFilaName()

This commit is contained in:
tyrrrz
2026-04-20 22:22:11 +03:00
parent 34b5ccc75b
commit da4f5ea74a
2 changed files with 2 additions and 3 deletions

View File

@@ -34,7 +34,7 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" /> <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageVersion Include="Onova" Version="2.6.13" /> <PackageVersion Include="Onova" Version="2.6.13" />
<PackageVersion Include="Polly" Version="8.6.6" /> <PackageVersion Include="Polly" Version="8.6.6" />
<PackageVersion Include="PowerKit" Version="1.1.0" /> <PackageVersion Include="PowerKit" Version="1.1.1" />
<PackageVersion Include="RazorBlade" Version="0.11.0" /> <PackageVersion Include="RazorBlade" Version="0.11.0" />
<PackageVersion Include="Spectre.Console" Version="0.54.0" /> <PackageVersion Include="Spectre.Console" Version="0.54.0" />
<PackageVersion Include="Superpower" Version="3.1.0" /> <PackageVersion Include="Superpower" Version="3.1.0" />

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
@@ -96,7 +95,7 @@ internal partial class ExportAssetDownloader
private static string GetFileNameFromUrl(string url, string urlHash) private static string GetFileNameFromUrl(string url, string urlHash)
{ {
// Try to extract the file name from URL // Try to extract the file name from URL
var fileName = Regex.Match(url, @".+/([^?]*)").Groups[1].Value; var fileName = new Uri(url, UriKind.RelativeOrAbsolute).TryGetFileName();
// If it's not there, just use the URL hash as the file name // If it's not there, just use the URL hash as the file name
if (string.IsNullOrWhiteSpace(fileName)) if (string.IsNullOrWhiteSpace(fileName))