diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index 935e1f4f61..946543868a 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -133,7 +133,7 @@ class Sanitize rel += ['nofollow', 'noopener', 'noreferrer'] unless TagManager.instance.local_url?(node['href']) if rel.empty? - node['rel']&.delete + node.remove_attribute('rel') else node['rel'] = rel.join(' ') end @@ -144,7 +144,7 @@ class Sanitize node = env[:node] if node['target'] != '_blank' && TagManager.instance.local_url?(node['href']) - node['target']&.delete + node.remove_attribute('target') else node['target'] = '_blank' end diff --git a/spec/lib/advanced_text_formatter_spec.rb b/spec/lib/advanced_text_formatter_spec.rb index 4e859c93c3..ea1a9570d0 100644 --- a/spec/lib/advanced_text_formatter_spec.rb +++ b/spec/lib/advanced_text_formatter_spec.rb @@ -50,6 +50,14 @@ RSpec.describe AdvancedTextFormatter do end end + context 'given text with a local-domain mention' do + let(:text) { 'foo https://cb6e6126.ngrok.io/about/more' } + + it 'creates a link' do + is_expected.to include '