mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-25 23:43:33 +00:00
More cleanup
This commit is contained in:
@@ -102,8 +102,10 @@ internal partial class ExportAssetDownloader
|
||||
|
||||
internal partial class ExportAssetDownloader
|
||||
{
|
||||
private static string GetUrlHash(string url)
|
||||
{
|
||||
// Remove signature parameters from Discord CDN URLs to normalize them
|
||||
private static string StripUrlSignatureParameters(string url)
|
||||
static string NormalizeUrl(string url)
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
if (!string.Equals(uri.Host, "cdn.discordapp.com", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -117,12 +119,8 @@ internal partial class ExportAssetDownloader
|
||||
return uri.GetLeftPart(UriPartial.Path) + query;
|
||||
}
|
||||
|
||||
private static string GetUrlHash(string url)
|
||||
{
|
||||
var normalizedUrl = StripUrlSignatureParameters(url);
|
||||
|
||||
return SHA256
|
||||
.HashData(Encoding.UTF8.GetBytes(normalizedUrl))
|
||||
.HashData(Encoding.UTF8.GetBytes(NormalizeUrl(url)))
|
||||
.ToHex()
|
||||
// 5 chars ought to be enough for anybody
|
||||
.Truncate(5);
|
||||
|
||||
Reference in New Issue
Block a user