Handle null avatar URLs (the other place too)

This commit is contained in:
Ske 2021-08-02 12:22:28 +02:00
parent eb142a81fa
commit 7681978435

View File

@ -25,8 +25,9 @@ namespace PluralKit.Core
// discord mediaproxy URLs used to be stored directly in the database, so now we cleanup image urls before using them outside of proxying // discord mediaproxy URLs used to be stored directly in the database, so now we cleanup image urls before using them outside of proxying
private static readonly Regex MediaProxyUrl = new Regex(@"^https?://media.discordapp.net/attachments/(\d{17,19})/(\d{17,19})/([^/\\&\?]+)\.(png|jpg|jpeg|webp)(\?.*)?$"); private static readonly Regex MediaProxyUrl = new Regex(@"^https?://media.discordapp.net/attachments/(\d{17,19})/(\d{17,19})/([^/\\&\?]+)\.(png|jpg|jpeg|webp)(\?.*)?$");
private static readonly string DiscordCdnReplacement = "https://cdn.discordapp.com/attachments/$1/$2/$3.$4"; private static readonly string DiscordCdnReplacement = "https://cdn.discordapp.com/attachments/$1/$2/$3.$4";
public static string TryGetCleanCdnUrl(this string url) => public static string? TryGetCleanCdnUrl(this string? url)
MediaProxyUrl.Replace(url, DiscordCdnReplacement); {
return url == null ? null : MediaProxyUrl.Replace(url, DiscordCdnReplacement);
}
} }
} }