| 1 |
package teams |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"regexp" |
| 6 |
) |
| 7 |
|
| 8 |
var workflowURLValidator = regexp.MustCompile( |
| 9 |
`^https://[a-zA-Z0-9][a-zA-Z0-9.-]*\.logic\.azure(?:\.[a-z]{2,})?(:\d+)?/(?:powerautomate/automations/direct/)?workflows/|` + |
| 10 |
`^https://[a-zA-Z0-9][a-zA-Z0-9.-]*\.environment\.api\.powerplatform\.com(:\d+)?/powerautomate/automations/direct/workflows/`, |
| 11 |
) |
| 12 |
|
| 13 |
// ValidateWebhookURL ensures the webhook URL matches the Power Automate workflow pattern. |
| 14 |
func ValidateWebhookURL(url string) error { |
| 15 |
if !workflowURLValidator.MatchString(url) { |
| 16 |
return fmt.Errorf("%w", ErrInvalidWebhookURL) |
| 17 |
} |
| 18 |
|
| 19 |
return nil |
| 20 |
} |