Skip to content

Commit

Permalink
Avoid duplicate entries in replacements list
Browse files Browse the repository at this point in the history
  • Loading branch information
denik committed Jan 24, 2025
1 parent 5e48f91 commit 2ab6c0a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libs/testdiff/replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ func (r *ReplacementsContext) Set(old, new string) {
if err == nil {
encodedOld, err := json.Marshal(old)
if err == nil {
r.appendLiteral(trimQuotes(string(encodedOld)), trimQuotes(string(encodedNew)))
encodedStrNew := trimQuotes(string(encodedNew))
encodedStrOld := trimQuotes(string(encodedOld))
if encodedStrNew != new || encodedStrOld != old {
r.appendLiteral(encodedStrOld, encodedStrNew)
}
}
}

Expand Down

0 comments on commit 2ab6c0a

Please sign in to comment.