Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit adfe844dc68c2aeb198369bf4d410f67260be6da Author: Jerry Heiselman <jheiselman@users.noreply.github.com> Date: Thu Mar 22 16:28:27 2018 +0000 Strip markdown URLs with blank text (slack) (#392) diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 1e1a1b7..7706f2b 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -416 +417 @@ import (   "bytes"   "errors"   "fmt" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" - "github.com/42wim/matterbridge/matterhook" - "github.com/nlopes/slack"   "html"   "regexp"   "strings"   "sync"   "time" + + "github.com/42wim/matterbridge/bridge" + "github.com/42wim/matterbridge/bridge/config" + "github.com/42wim/matterbridge/bridge/helper" + "github.com/42wim/matterbridge/matterhook" + "github.com/nlopes/slack"  )    type Bslack struct { @@ -3877 +38811 @@ func (b *Bslack) replaceVariable(text string) string {  func (b *Bslack) replaceURL(text string) string {   results := regexp.MustCompile(`<(.*?)(\|.*?)?>`).FindAllStringSubmatch(text, -1)   for _, r := range results { - text = strings.Replace(text, r[0], r[1], -1) + if len(strings.TrimSpace(r[2])) == 1 { // A display text separator was found, but the text was blank + text = strings.Replace(text, r[0], "", -1) + } else { + text = strings.Replace(text, r[0], r[1], -1) + }   }   return text  }