Skip to content

Commit

Permalink
fix: stacked pings
Browse files Browse the repository at this point in the history
  • Loading branch information
sqyyy-jar committed Oct 15, 2024
1 parent 07579c6 commit a85e95f
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 a85e95f

Please sign in to comment.