MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / ValidateSlackWebhookURL

Function ValidateSlackWebhookURL

lib/httputils/slack_webhook.go:32–45  ·  view source on GitHub ↗

ValidateSlackWebhookURL validates the URL matches the expected Slack webhook URL format as defined by https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks/ Ex. "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"

(webhookURL string)

Source from the content-addressed store, hash-verified

30// https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks/
31// Ex. "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
32func ValidateSlackWebhookURL(webhookURL string) error {
33 u, err := url.Parse(webhookURL)
34 if err != nil {
35 return err
36 }
37
38 if u.Scheme != "https" ||
39 u.Host != "hooks.slack.com" ||
40 !strings.HasPrefix(u.Path, "/services/") {
41 return ErrInvalidSlackWebhookURL
42 }
43
44 return nil
45}

Callers 1

Calls 1

ParseMethod · 0.65

Tested by 1