Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Block indexing the embed topic list (#16495)

Rafael dos Santos Silva9d5241d347fb
diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb
index 6ff0de5cfdd..3951761c73f 100644
--- a/app/controllers/embed_controller.rb
+++ b/app/controllers/embed_controller.rb
@@ -35,6 +35,8 @@ class EmbedController < ApplicationController
raise Discourse::InvalidParameters.new(:embed_class) unless @embed_class =~ /^[a-zA-Z0-9\-_]+$/
end
+ response.headers['X-Robots-Tag'] = 'noindex, indexifembedded'
+
if params.has_key?(:template) && params[:template] == "complete"
@template = "complete"
else
diff --git a/spec/requests/embed_controller_spec.rb b/spec/requests/embed_controller_spec.rb
index faed26ac4bb..637124071d4 100644
--- a/spec/requests/embed_controller_spec.rb
+++ b/spec/requests/embed_controller_spec.rb
@@ -156,6 +156,14 @@ describe EmbedController do
expect(response.body).to match("data-referer=\"\\*\"")
end
+ it "disallows indexing the embed topic list" do
+ topic = Fabricate(:topic)
+ get '/embed/topics?discourse_embed_id=de-1234', headers: {
+ 'REFERER' => 'https://example.com/evil-trout'
+ }
+ expect(response.status).to eq(200)
+ expect(response.headers['X-Robots-Tag']).to match(/noindex/)
+ end
end
end