alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

Add safeURL and urldecode template functions

Open CommitToday opened this issue 1 month ago • 0 comments

This PR addresses issue #4710 by adding two new template functions to improve URL handling in Alertmanager notifications:

  1. safeURL function: An alias for the existing safeUrl function to provide consistency with common naming conventions. Both functions now work identically.

  2. urldecode function: 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.

CommitToday avatar Nov 07 '25 21:11 CommitToday