mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-10 15:57:53 +00:00
Handle null avatar URLs
This commit is contained in:
parent
1290594211
commit
eb142a81fa
1 changed files with 4 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue