(u *url.URL)
| 106 | } |
| 107 | |
| 108 | func 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 | } |
no test coverage detected