Fix webp image errors
This commit is contained in:
parent
a1da3e1386
commit
e79e7278ab
@ -1,4 +1,4 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -14,8 +14,8 @@ namespace PluralKit.Bot
|
|||||||
// Rewrite cdn.discordapp.com URLs to media.discordapp.net for jpg/png files
|
// Rewrite cdn.discordapp.com URLs to media.discordapp.net for jpg/png files
|
||||||
// This lets us add resizing parameters to "borrow" their media proxy server to downsize the image
|
// 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!
|
// 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)(\?.*)?$");
|
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.jpg?width=256&height=256";
|
||||||
|
|
||||||
public static async Task<ParsedImage?> MatchImage(this Context ctx)
|
public static async Task<ParsedImage?> MatchImage(this Context ctx)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user