Skip to content

Commit

Permalink
fix: stacked pings (#78)
Browse files Browse the repository at this point in the history
Fixes GH-72
  • Loading branch information
sqyyy-jar authored Oct 16, 2024
1 parent 07579c6 commit 1b9b753
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/kotlin/io/zachbr/dis4irc/util/StringUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ fun replaceTarget(base: CharSequence, target: String, replacement: CharSequence,
return i == -1 || i == out.length || !requireSeparation || out[i].isWhitespace()
}

fun isTarget(i: Int): Boolean {
return i > 0 && out[i - 1] == '<'
}

var start = out.indexOf(target, 0)
while (start > -1) {
val end = start + target.length
val nextSearchStart = start + replacement.length

if (isWhiteSpace(start - 1) && isWhiteSpace(end)) {
if (isWhiteSpace(start - 1) && isWhiteSpace(end) && !isTarget(start)) {
out = out.replaceRange(start, start + target.length, replacement)
}

Expand Down

0 comments on commit 1b9b753

Please sign in to comment.