about summary refs log tree commit diff
path: root/lib/sanitize_ext/sanitize_config.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-04-09 11:25:30 +0200
committerGitHub <noreply@github.com>2023-04-09 11:25:30 +0200
commitff168ef2024626f37fa776fde5739dcd58ecb9f2 (patch)
tree5b638b2e5a43445a75133a9b510bff00d44ea986 /lib/sanitize_ext/sanitize_config.rb
parent29a91b871eb4fb375baa3701e29cfb35f884bb98 (diff)
Fix most rubocop issues (#2165)
* Run rubocop --autocorrect on app/, config/ and lib/, also manually fix some remaining style issues

* Run rubocop --autocorrect-all on db/

* Run rubocop --autocorrect-all on `spec/` and fix remaining issues
Diffstat (limited to 'lib/sanitize_ext/sanitize_config.rb')
-rw-r--r--lib/sanitize_ext/sanitize_config.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb
index dfc586561..4c0e9b858 100644
--- a/lib/sanitize_ext/sanitize_config.rb
+++ b/lib/sanitize_ext/sanitize_config.rb
@@ -48,9 +48,9 @@ class Sanitize
         node.content = "[🖼  #{node['alt']}]"
       else
         url = node['href']
-        prefix = url.match(/\Ahttps?:\/\/(www\.)?/).to_s
+        prefix = url.match(%r{\Ahttps?://(www\.)?}).to_s
         text   = url[prefix.length, 30]
-        text   = text + "…" if url[prefix.length..-1].length > 30
+        text += '…' if url.length - prefix.length > 30
         node.content = "[🖼  #{text}]"
       end
     end
@@ -88,7 +88,7 @@ class Sanitize
       },
 
       protocols: {
-        'a'          => { 'href' => LINK_PROTOCOLS },
+        'a' => { 'href' => LINK_PROTOCOLS },
         'blockquote' => { 'cite' => LINK_PROTOCOLS },
       },
 
@@ -126,7 +126,7 @@ class Sanitize
 
       node = env[:node]
 
-      rel = (node['rel'] || '').split(' ') & ['tag']
+      rel = (node['rel'] || '').split & ['tag']
       rel += ['nofollow', 'noopener', 'noreferrer'] unless TagManager.instance.local_url?(node['href'])
 
       if rel.empty?