diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-12-11 17:20:06 +0100 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-12-11 17:20:06 +0100 |
commit | 08bfec57c3e17225a93a33e464a898a14741d5c4 (patch) | |
tree | c8172e38fc725cda80bb1d57665778651fc4d6f3 /spec | |
parent | 18a48e348b83f66a1d108a2d6e38ac12c47dcef3 (diff) | |
download | gitlab-ce-08bfec57c3e17225a93a33e464a898a14741d5c4.tar.gz |
Set URL rel attribute for broken URLs
It's possible that URI fails to parse a link, but browsers
still recognize given URL as a link, we should make sure
that 'rel' attribute is set also in this case.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/banzai/filter/external_link_filter_spec.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/spec/lib/banzai/filter/external_link_filter_spec.rb b/spec/lib/banzai/filter/external_link_filter_spec.rb index 2a3c0cd78b8..e6dae8d5382 100644 --- a/spec/lib/banzai/filter/external_link_filter_spec.rb +++ b/spec/lib/banzai/filter/external_link_filter_spec.rb @@ -49,16 +49,16 @@ describe Banzai::Filter::ExternalLinkFilter do end context 'for invalid urls' do - it 'skips broken hrefs' do + it 'adds rel and target attributes to broken hrefs' do doc = filter %q(<p><a href="don't crash on broken urls">Google</a></p>) - expected = %q(<p><a href="don't%20crash%20on%20broken%20urls">Google</a></p>) + expected = %q(<p><a href="don't%20crash%20on%20broken%20urls" rel="nofollow noreferrer noopener" target="_blank">Google</a></p>) expect(doc.to_html).to eq(expected) end - it 'skips improperly formatted mailtos' do + it 'adds rel and target to improperly formatted mailtos' do doc = filter %q(<p><a href="mailto://jblogs@example.com">Email</a></p>) - expected = %q(<p><a href="mailto://jblogs@example.com">Email</a></p>) + expected = %q(<p><a href="mailto://jblogs@example.com" rel="nofollow noreferrer noopener" target="_blank">Email</a></p>) expect(doc.to_html).to eq(expected) end |