Fix image proxy URL extensions

Media proxy doesn't support format conversion by changing extension, needs a separate query parameter instead
This commit is contained in:
Ske 2020-09-16 22:47:40 +02:00
parent 509c0bf73f
commit 6f8e15178f

View File

@ -15,7 +15,7 @@ namespace PluralKit.Bot
// This lets us add resizing parameters to "borrow" their media proxy server to downsize the image
// 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 string DiscordMediaUrlReplacement = "https://media.discordapp.net/attachments/$1/$2/$3.jpg?width=256&height=256";
private static readonly string DiscordMediaUrlReplacement = "https://media.discordapp.net/attachments/$1/$2/$3.$4?width=256&height=256&format=jpeg";
public static async Task<ParsedImage?> MatchImage(this Context ctx)
{