Skip to content

Commit

Permalink
Surround IRC messages with ZWS for leading/trailing spaces too
Browse files Browse the repository at this point in the history
  • Loading branch information
yutotakano authored and siniStar7 committed Sep 7, 2022
1 parent dc33bb1 commit fa6a042
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,12 @@ func (b *Bridge) loop() {

content := msg.Message

// If the message contains content or only whitespace, surround that with
// zero width spaces so that Discord displays them as intended. E.g. 3
// space characters sent from IRC should render on Discord as 3 space
// characters too.
if strings.TrimSpace(content) == "" {
// If the message has leading or trailing spaces, or if the message consists
// entirely of whitespace, we want Discord to display them as intended,
// rather than ignoring it. We surround the content with zero-width spaces
// to achieve this. For example, 3 space characters sent from IRC should
// render on Discord as 3 space characters too.
if strings.TrimSpace(content) != content {
content = "\u200B" + content + "\u200B"
}

Expand Down

0 comments on commit fa6a042

Please sign in to comment.