diff --git a/transform/links.go b/transform/links.go index 23495836c..99d1c482c 100644 --- a/transform/links.go +++ b/transform/links.go @@ -1,6 +1,13 @@ package transform -import "github.com/asaskevich/govalidator" +import "net/url" + +// list of URI schema which we turn into links in the UI +var schemes = []string{ + "ftp", + "http", + "https", +} // DetectLinks takes alert annotation dict and returns two dicts: // first with regular annotations @@ -10,7 +17,10 @@ func DetectLinks(sourceAnnotations map[string]string) (map[string]string, map[st annotations := make(map[string]string) for k, v := range sourceAnnotations { - if govalidator.IsURL(v) { + u, err := url.Parse(v) + if err != nil { + annotations[k] = v + } else if stringInSlice(schemes, u.Scheme) { links[k] = v } else { annotations[k] = v