Don't open auto links in a new tab

Just like we aren't opening any external links in a new tab, only, in
this case, we don't even know whether these links are internal or
external.
This commit is contained in:
Javi Martín
2023-10-16 00:03:31 +02:00
parent 5aa56c054f
commit aeff8a0f31
9 changed files with 10 additions and 10 deletions

View File

@@ -10,7 +10,7 @@ module TextWithLinksHelper
return if html.nil? return if html.nil?
raise "Could not add links because the content is not safe" unless html.html_safe? raise "Could not add links because the content is not safe" unless html.html_safe?
raw Rinku.auto_link(html, :all, 'target="_blank" rel="nofollow"') raw Rinku.auto_link(html, :all, 'rel="nofollow"')
end end
def simple_format_no_tags_no_sanitize(html) def simple_format_no_tags_no_sanitize(html)

View File

@@ -167,7 +167,7 @@ describe "Commenting Budget::Investments" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end

View File

@@ -125,7 +125,7 @@ describe "Internal valuation comments on Budget::Investments" do
expect(page).to have_content("Check http://rubyonrails.org/") expect(page).to have_content("Check http://rubyonrails.org/")
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end

View File

@@ -170,7 +170,7 @@ describe "Commenting debates" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end

View File

@@ -164,7 +164,7 @@ describe "Commenting legislation questions" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end

View File

@@ -159,7 +159,7 @@ describe "Commenting legislation questions" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end

View File

@@ -148,7 +148,7 @@ describe "Commenting polls" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end

View File

@@ -153,7 +153,7 @@ describe "Commenting proposals" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end

View File

@@ -161,7 +161,7 @@ describe "Commenting topics from proposals" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end
@@ -710,7 +710,7 @@ describe "Commenting topics from budget investments" do
expect(page).to have_content "Built with http://rubyonrails.org/" expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/") expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow") expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank") expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end end
end end