diff --git a/PluralKit.Core/Utils/MiscUtils.cs b/PluralKit.Core/Utils/MiscUtils.cs index e242b2ea..e0352c70 100644 --- a/PluralKit.Core/Utils/MiscUtils.cs +++ b/PluralKit.Core/Utils/MiscUtils.cs @@ -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 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"; - public static string TryGetCleanCdnUrl(this string url) => - MediaProxyUrl.Replace(url, DiscordCdnReplacement); - + public static string? TryGetCleanCdnUrl(this string? url) + { + return url == null ? null : MediaProxyUrl.Replace(url, DiscordCdnReplacement); + } } } \ No newline at end of file