diff --git a/ghost/admin/app/templates/settings/apps/slack.hbs b/ghost/admin/app/templates/settings/apps/slack.hbs index be44e6bcf2..729e4bdc93 100644 --- a/ghost/admin/app/templates/settings/apps/slack.hbs +++ b/ghost/admin/app/templates/settings/apps/slack.hbs @@ -34,7 +34,7 @@
Webhook URL
-
Automatically send newly published posts to a channel in Slack
+
Automatically send newly published posts to a channel in Slack or any Slack-compatible service like Discord or Mattermost.
{{#gh-form-group errors=model.errors hasValidated=model.hasValidated property="url"}} {{gh-input model.url name="slack[url]" update=(action "updateURL") onenter=(action "save") focusOut=(action "triggerDirtyState") placeholder="https://hooks.slack.com/services/..." data-test-slack-url-input=true}} diff --git a/ghost/admin/app/validators/slack-integration.js b/ghost/admin/app/validators/slack-integration.js index 272cf035d2..b4af707916 100644 --- a/ghost/admin/app/validators/slack-integration.js +++ b/ghost/admin/app/validators/slack-integration.js @@ -1,4 +1,5 @@ import BaseValidator from './base'; +import {isBlank} from '@ember/utils'; export default BaseValidator.create({ properties: ['url'], @@ -7,9 +8,8 @@ export default BaseValidator.create({ let url = model.get('url'); let hasValidated = model.get('hasValidated'); - let urlRegex = new RegExp(/(^https:\/\/hooks\.slack\.com\/services\/)(\S+)/); - - if (!validator.empty(url) && !url.match(urlRegex)) { + // eslint-disable-next-line camelcase + if (!isBlank(url) && !validator.isURL(url, {require_protocol: true})) { model.get('errors').add( 'url', 'The URL must be in a format like https://hooks.slack.com/services/' diff --git a/ghost/admin/tests/unit/validators/slack-integration-test.js b/ghost/admin/tests/unit/validators/slack-integration-test.js index 3e813483d4..99018d5a77 100644 --- a/ghost/admin/tests/unit/validators/slack-integration-test.js +++ b/ghost/admin/tests/unit/validators/slack-integration-test.js @@ -47,7 +47,8 @@ describe('Unit: Validator: slack-integration', function () { let validUrls = [ 'https://hooks.slack.com/services/;alskdjf', 'https://hooks.slack.com/services/123445678', - 'https://hooks.slack.com/services/some_webhook' + 'https://hooks.slack.com/services/some_webhook', + 'https://discordapp.com/api/webhooks/380692408364433418/mGLHSRyEoUaTvY91Te16WOT8Obn-BrJoiTNoxeUqhb6klKERb9xaZkUBYC5AeduwYCCy/slack' ]; validUrls.forEach(function (url) {