diff --git a/internal/glance/widget-custom-api.go b/internal/glance/widget-custom-api.go index c9db2df..e092fc3 100644 --- a/internal/glance/widget-custom-api.go +++ b/internal/glance/widget-custom-api.go @@ -468,8 +468,16 @@ var customAPITemplateFuncs = func() template.FuncMap { return strings.TrimSuffix(s, suffix) }, "trimSpace": strings.TrimSpace, - "replaceAll": func(old, new, s string) string { - return strings.ReplaceAll(s, old, new) + "replaceAll": func(oldOrPattern, new, s string) string { + if s == "" { + return "" + } + + regex := getCachedRegexp(oldOrPattern) + if regex == nil { + return strings.ReplaceAll(s, oldOrPattern, new) + } + return regex.ReplaceAllString(s, new) }, "findMatch": func(pattern, s string) string { if s == "" {