summaryrefslogtreecommitdiffstats
path: root/bridge/slack/slack.go
diff options
context:
space:
mode:
authorJerry Heiselman <jheiselman@users.noreply.github.com>2018-03-22 16:28:27 -0500
committerWim <wim@42.be>2018-03-22 22:28:27 +0100
commit76360f89c1b98b8f3926f12c25d11e3c1efd8925 (patch)
tree6863a4a5f9632f35742369a6bb66385d5d9c15c4 /bridge/slack/slack.go
parentd525230abd850cdfb5972f2a271f1ca86cd105c9 (diff)
downloadmatterbridge-msglm-76360f89c1b98b8f3926f12c25d11e3c1efd8925.tar.gz
matterbridge-msglm-76360f89c1b98b8f3926f12c25d11e3c1efd8925.tar.bz2
matterbridge-msglm-76360f89c1b98b8f3926f12c25d11e3c1efd8925.zip
Strip markdown URLs with blank text (slack) (#392)
Diffstat (limited to 'bridge/slack/slack.go')
-rw-r--r--bridge/slack/slack.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 1e1a1b7f..7706f2bf 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -4,16 +4,17 @@ 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 {
@@ -387,7 +388,11 @@ 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
}