MCPcopy Index your code
hub / github.com/bytebase/bytebase / validateGoogleChatURL

Function validateGoogleChatURL

backend/plugin/webhook/validator.go:108–127  ·  view source on GitHub ↗
(u *url.URL)

Source from the content-addressed store, hash-verified

106}
107
108func validateGoogleChatURL(u *url.URL) error {
109 if u.Scheme != "https" {
110 return errors.Errorf("invalid Google Chat URL scheme: %s (only https is allowed)", u.Scheme)
111 }
112
113 parts := strings.Split(u.Path, "/")
114 if len(parts) != 5 || parts[1] != "v1" || parts[2] != "spaces" || parts[3] == "" || parts[4] != "messages" {
115 return errors.Errorf("invalid Google Chat webhook path: %s", u.Path)
116 }
117
118 query := u.Query()
119 if query.Get("key") == "" {
120 return errors.Errorf("missing Google Chat webhook key")
121 }
122 if query.Get("token") == "" {
123 return errors.Errorf("missing Google Chat webhook token")
124 }
125
126 return nil
127}

Callers 1

ValidateWebhookURLFunction · 0.85

Calls 3

ErrorfMethod · 0.80
GetMethod · 0.80
QueryMethod · 0.65

Tested by

no test coverage detected