FIX: add noindex header to user profile pages.

This commit is contained in:
Vinoth Kannan 2020-01-08 11:26:20 +05:30
parent bdff4561d4
commit 13f229808a
2 changed files with 4 additions and 0 deletions

View File

@ -73,6 +73,8 @@ class UsersController < ApplicationController
track_visit_to_user_profile track_visit_to_user_profile
end end
response.headers['X-Robots-Tag'] = 'noindex'
# This is a hack to get around a Rails issue where values with periods aren't handled correctly # This is a hack to get around a Rails issue where values with periods aren't handled correctly
# when used as part of a route. # when used as part of a route.
if params[:external_id] && params[:external_id].ends_with?('.json') if params[:external_id] && params[:external_id].ends_with?('.json')

View File

@ -2904,6 +2904,8 @@ describe UsersController do
it 'returns success' do it 'returns success' do
get "/u/#{user.username}.json" get "/u/#{user.username}.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(response.headers['X-Robots-Tag']).to eq('noindex')
json = JSON.parse(response.body) json = JSON.parse(response.body)
expect(json["user"]["has_title_badges"]).to eq(false) expect(json["user"]["has_title_badges"]).to eq(false)