Handle null avatar URLs
This commit is contained in:
parent
1290594211
commit
eb142a81fa
@ -55,7 +55,9 @@ namespace PluralKit.Bot {
|
|||||||
// which in turn makes it more likely to be underneath the size limit!
|
// which in turn makes it more likely to be underneath the size limit!
|
||||||
private static readonly Regex DiscordCdnUrl = new Regex(@"^https?://(?:cdn\.discordapp\.com|media\.discordapp\.net)/attachments/(\d{17,19})/(\d{17,19})/([^/\\&\?]+)\.(png|jpg|jpeg|webp)(\?.*)?$");
|
private static readonly Regex DiscordCdnUrl = new Regex(@"^https?://(?:cdn\.discordapp\.com|media\.discordapp\.net)/attachments/(\d{17,19})/(\d{17,19})/([^/\\&\?]+)\.(png|jpg|jpeg|webp)(\?.*)?$");
|
||||||
private static readonly string DiscordMediaUrlReplacement = "https://media.discordapp.net/attachments/$1/$2/$3.$4?width=256&height=256";
|
private static readonly string DiscordMediaUrlReplacement = "https://media.discordapp.net/attachments/$1/$2/$3.$4?width=256&height=256";
|
||||||
public static string TryRewriteCdnUrl(string url) =>
|
public static string? TryRewriteCdnUrl(string? url)
|
||||||
DiscordCdnUrl.Replace(url, DiscordMediaUrlReplacement);
|
{
|
||||||
|
return url == null ? null : DiscordCdnUrl.Replace(url, DiscordMediaUrlReplacement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user