Skip to content

Commit b7984a7

Browse files
committed
fix: accept the Discord webhook URLs Discord issues, and anchor the pattern
Three separate problems with the pattern this replaces: 1. `discordapp.com` was rejected. That host is still served and still handed out, and the unescaped dot did not rescue it - "discord" plus any single character plus "com" does not match "discordapp.com". The workaround reporters found was to delete "app" from their own webhook URL. 2. The pattern was unanchored, and both ends check it with `RegExp.test`, which matches anywhere in the string. Any URL at all that merely contained a webhook-shaped substring was accepted - and the stored value is where the speedtest results are then posted. 3. The leading `.*` accepted any host ending in the pattern, so `notdiscord.com` passed. The replacement also allows the `/api/v10/webhooks/...` form and Discord's own `?thread_id=` parameter, both of which the old pattern rejected. This fixes the half of #1297 about the URL not saving. Several reporters also say the webhook saves and then never delivers; that is not addressed here. Refs #1297
1 parent 1a2045b commit b7984a7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

server/integrations/discord.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default (registerEvent) => {
2626
return {
2727
icon: "fa-brands fa-discord",
2828
fields: [
29-
{name: "url", type: "text", required: true, regex: /https:\/\/.*discord.com\/api\/webhooks\/\d+\/.+/},
29+
{name: "url", type: "text", required: true,
30+
regex: /^https:\/\/(?:ptb\.|canary\.)?discord(?:app)?\.com\/api(?:\/v\d+)?\/webhooks\/\d+\/[\w-]+(?:\?\S*)?$/},
3031
{name: "display_name", type: "text", required: false},
3132
{name: "send_finished", type: "boolean", required: false},
3233
{name: "finished_message", type: "textarea", required: false},

0 commit comments

Comments
 (0)