0
0
Fork 0

Fix Style/SlicingWithRange cop (#25923)

This commit is contained in:
Matt Jankowski 2023-07-12 04:03:06 -04:00 committed by GitHub
parent 658742b3cd
commit b8b2470cf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 13 additions and 28 deletions

View file

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