diff --git a/src/lib/operationalWebhook/channelAdapters.ts b/src/lib/operationalWebhook/channelAdapters.ts index ef2533c..f8cbc2a 100644 --- a/src/lib/operationalWebhook/channelAdapters.ts +++ b/src/lib/operationalWebhook/channelAdapters.ts @@ -26,14 +26,17 @@ export function operationalWebhookEventTitle(eventType: string): string { export function detectNotificationChannel(targetUrl: string): NotificationChannel { try { const hostname = new URL(targetUrl).hostname.toLowerCase(); - const matchesDomain = (domain: string) => - hostname === domain || hostname.endsWith(`.${domain}`); + const matchesAllowedHost = (allowedHost: string): boolean => + hostname === allowedHost || hostname.endsWith(`.${allowedHost}`); + + if (matchesAllowedHost("hooks.slack.com") || matchesAllowedHost("slack.com")) { + return "slack"; + } - if (matchesDomain("hooks.slack.com") || matchesDomain("slack.com")) return "slack"; if ( - matchesDomain("webhook.office.com") || - matchesDomain("outlook.office.com") || - matchesDomain("office365.com") + matchesAllowedHost("webhook.office.com") || + matchesAllowedHost("outlook.office.com") || + matchesAllowedHost("office365.com") ) { return "teams"; }