From ce97d5c7cc591b58cbea5aa4ae8b21bd2be99aac Mon Sep 17 00:00:00 2001 From: moiph Date: Sun, 24 May 2020 17:09:01 -0700 Subject: [PATCH] Updating webhook regex for discord.com Updates webhook URL regex matching for discordapp.com and discord.com --- src/Discord.Net.Webhook/DiscordWebhookClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Webhook/DiscordWebhookClient.cs b/src/Discord.Net.Webhook/DiscordWebhookClient.cs index 9c90df565..da03698e7 100644 --- a/src/Discord.Net.Webhook/DiscordWebhookClient.cs +++ b/src/Discord.Net.Webhook/DiscordWebhookClient.cs @@ -33,7 +33,7 @@ namespace Discord.Webhook : this(webhookUrl, new DiscordRestConfig()) { } // regex pattern to match webhook urls - private static Regex WebhookUrlRegex = new Regex(@"^.*discordapp\.com\/api\/webhooks\/([\d]+)\/([a-z0-9_-]+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static Regex WebhookUrlRegex = new Regex(@"^.*(discord|discordapp)\.com\/api\/webhooks\/([\d]+)\/([a-z0-9_-]+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); /// Creates a new Webhook Discord client. public DiscordWebhookClient(ulong webhookId, string webhookToken, DiscordRestConfig config) @@ -133,12 +133,12 @@ namespace Discord.Webhook { // ensure that the first group is a ulong, set the _webhookId // 0th group is always the entire match, so start at index 1 - if (!(match.Groups[1].Success && ulong.TryParse(match.Groups[1].Value, NumberStyles.None, CultureInfo.InvariantCulture, out webhookId))) + if (!(match.Groups[2].Success && ulong.TryParse(match.Groups[2].Value, NumberStyles.None, CultureInfo.InvariantCulture, out webhookId))) throw ex("The webhook Id could not be parsed."); - if (!match.Groups[2].Success) + if (!match.Groups[3].Success) throw ex("The webhook token could not be parsed."); - webhookToken = match.Groups[2].Value; + webhookToken = match.Groups[3].Value; } else throw ex();