Avoid duplicate entries in replacements list

This commit is contained in:
Denis Bilenko 2025-01-24 18:19:27 +01:00
parent 5e48f9107c
commit 2ab6c0a77c
1 changed files with 5 additions and 1 deletions

View File

@ -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)
}
}
}