alertmanager
alertmanager copied to clipboard
Add safeURL and urldecode template functions
This PR addresses issue #4710 by adding two new template functions to improve URL handling in Alertmanager notifications:
-
safeURLfunction: An alias for the existingsafeUrlfunction to provide consistency with common naming conventions. Both functions now work identically. -
urldecodefunction: A new function that URL-decodes strings. This is particularly useful for decoding query parameters or other URL-encoded data in notification templates. The function returns the original string if decoding fails, ensuring template rendering doesn't break on invalid encoding.
The changes include:
- Implementation of both functions in
template/template.go - Documentation updates in
docs/notifications.md - Comprehensive tests covering normal usage, complex encoding, and error cases
These additions enhance the flexibility of notification templates when working with URL-encoded data.