From 7681978435c7362826cb9ef8eb6f6734490777f8 Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 2 Aug 2021 12:22:28 +0200 Subject: [PATCH] Handle null avatar URLs (the other place too) --- PluralKit.Core/Utils/MiscUtils.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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