diff --git a/CHANGELOG.md b/CHANGELOG.md index f3f78cf..9c75442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [0.0.12] + +- [#18](https://github.com/playwright-community/playwright-msteams-reporter/issues/18): Fix issue in MS Teams webhook URL validation + ## [0.0.11] - [#15](https://github.com/playwright-community/playwright-msteams-reporter/pull/15): New option `shouldRun` to control when to report based on suite values diff --git a/src/utils/validateWebhookUrl.test.ts b/src/utils/validateWebhookUrl.test.ts index 15419b0..cb3a784 100644 --- a/src/utils/validateWebhookUrl.test.ts +++ b/src/utils/validateWebhookUrl.test.ts @@ -53,6 +53,25 @@ describe("validateWebhookUrl", () => { ) ).toBe(true); }); + + it("Valid MS Teams webhook URL with a number 1", () => { + expect( + validateWebhookUrl( + "https://tenant9.webhook.office.com/webhookb2/0daed572-448a-4d0a-8ea8-b6a49e4625b3@b32d3268-2794-435f-865f-ab4779cae11e/IncomingWebhook/3814d9fc895847eb92cba3be342f1ce9/0ed480cd-fb54-4931-90da-1df7a1181c66/V2oHGgdElj-mUr4VOwzCnl8lvZhVHqSyqAkJRaCMi9QOI1", + "msteams" + ) + ).toBe(true); + }); + + it("Valid MS Teams webhook URL with a number 2", () => { + expect( + validateWebhookUrl( + "https://tenant2share.webhook.office.com/webhookb2/0daed572-448a-4d0a-8ea8-b6a49e4625b3@b32d3268-2794-435f-865f-ab4779cae11e/IncomingWebhook/3814d9fc895847eb92cba3be342f1ce9/0ed480cd-fb54-4931-90da-1df7a1181c66/V2oHGgdElj-mUr4VOwzCnl8lvZhVHqSyqAkJRaCMi9QOI1", + "msteams" + ) + ).toBe(true); + }); + it("Invalid if MS Teams webhook URL is passed as Power Automate webhook URL", () => { expect( validateWebhookUrl( diff --git a/src/utils/validateWebhookUrl.ts b/src/utils/validateWebhookUrl.ts index 5ee16cf..df41f40 100644 --- a/src/utils/validateWebhookUrl.ts +++ b/src/utils/validateWebhookUrl.ts @@ -23,7 +23,7 @@ export const validateWebhookUrl = ( } else if (type === "msteams") { // https://tenant.webhook.office.com/webhookb2/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid} const webhook_pattern = - /^https:\/\/[a-zA-Z]+.webhook.office.com\/webhookb2\/[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?\S+\/IncomingWebhook\/[a-zA-Z0-9]+\/[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?/; + /^https:\/\/[a-zA-Z0-9]+.webhook.office.com\/webhookb2\/[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?\S+\/IncomingWebhook\/[a-zA-Z0-9]+\/[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?/; return webhook_pattern.test(webhookUrl); } else {