lib/contrast/agent/assess/policy/propagator/trim.rb in contrast-agent-3.12.2 vs lib/contrast/agent/assess/policy/propagator/trim.rb in contrast-agent-3.13.0
- old
+ new
@@ -26,26 +26,22 @@
if replace_string == Contrast::Utils::ObjectShare::EMPTY_STRING
Contrast::Agent::Assess::Policy::Propagator::Remove.handle_removal(source_chars, ret)
else
remove_ranges = []
ret_chars = ret.chars
- curr_span = nil
+ start = nil
source_chars.each_with_index do |char, idx|
if ret_chars[idx] == char
- next unless curr_span
+ next unless start
- curr_span.stop = idx
- remove_ranges << curr_span
- curr_span = nil
+ remove_ranges << (start...idx)
+ start = nil
else
- curr_span ||= Contrast::Agent::Assess::AdjustedSpan.new(idx)
+ start ||= idx
end
end
# account for the last char being different
- if curr_span
- curr_span.stop = source_chars.length
- remove_ranges << curr_span
- end
+ remove_ranges << (start...source_chars.length) if start
ret.cs__properties.delete_tags_at_ranges(remove_ranges, false)
end
ret.cs__properties.build_event(
patcher,