Fix Style/SlicingWithRange
cop (#25923)
This commit is contained in:
@ -57,8 +57,8 @@ class TextFormatter
|
||||
|
||||
prefix = url.match(URL_PREFIX_REGEX).to_s
|
||||
display_url = url[prefix.length, 30]
|
||||
suffix = url[prefix.length + 30..-1]
|
||||
cutoff = url[prefix.length..-1].length > 30
|
||||
suffix = url[prefix.length + 30..]
|
||||
cutoff = url[prefix.length..].length > 30
|
||||
|
||||
<<~HTML.squish.html_safe # rubocop:disable Rails/OutputSafety
|
||||
<a href="#{h(url)}" target="_blank" rel="#{rel.join(' ')}" translate="no"><span class="invisible">#{h(prefix)}</span><span class="#{cutoff ? 'ellipsis' : ''}">#{h(display_url)}</span><span class="invisible">#{h(suffix)}</span></a>
|
||||
@ -84,7 +84,7 @@ class TextFormatter
|
||||
indices.last
|
||||
end
|
||||
|
||||
result << h(text[last_index..-1])
|
||||
result << h(text[last_index..])
|
||||
|
||||
result
|
||||
end
|
||||
|
Reference in New Issue
Block a user