mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
FIX: don't add diff classes more than once
This commit is contained in:
parent
a4a0b8e922
commit
001b0710c7
@ -184,9 +184,14 @@ class DiscourseDiff
|
||||
# add it right before the ">"
|
||||
html_or_text.insert(index_of_next_chevron, " class=\"diff-#{klass}\"")
|
||||
else
|
||||
# we have a class, insert it at the beginning
|
||||
# we have a class, insert it at the beginning if not already present
|
||||
classes = html_or_text[/class=(["'])([^\1]*)\1/, 2]
|
||||
if classes.include?("diff-#{klass}")
|
||||
html_or_text
|
||||
else
|
||||
html_or_text.insert(index_of_class + "class=".length + 1, "diff-#{klass} ")
|
||||
end
|
||||
end
|
||||
else
|
||||
"<#{klass}>#{html_or_text}</#{klass}>"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user