From dd0a7107a8e1346645977d576e9af6f66430c190 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 1 Oct 2015 12:24:07 -0400 Subject: [PATCH] FIX: canonical urls for category and topic pages was wrong when deployed to subfolder --- app/controllers/list_controller.rb | 4 ++-- app/controllers/topics_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index bea88a69e..844bc6ba6 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -84,7 +84,7 @@ class ListController < ApplicationController end define_method("category_#{filter}") do - canonical_url "#{Discourse.base_url}#{@category.url}" + canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}" self.send(filter, category: @category.id) end @@ -93,7 +93,7 @@ class ListController < ApplicationController end define_method("parent_category_category_#{filter}") do - canonical_url "#{Discourse.base_url}#{@category.url}" + canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}" self.send(filter, category: @category.id) end diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index d139479de..d1eacdc89 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -83,7 +83,7 @@ class TopicsController < ApplicationController response.headers['X-Robots-Tag'] = 'noindex' end - canonical_url UrlHelper.absolute_without_cdn("#{Discourse.base_uri}#{@topic_view.canonical_path}") + canonical_url UrlHelper.absolute_without_cdn(@topic_view.canonical_path) perform_show_response diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2dadd8db4..074310835 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -121,7 +121,7 @@ module ApplicationHelper opts ||= {} opts[:image] ||= "#{Discourse.base_url}#{SiteSetting.logo_small_url}" - opts[:url] ||= "#{Discourse.base_url}#{request.fullpath}" + opts[:url] ||= "#{Discourse.base_url_no_prefix}#{request.fullpath}" # Use the correct scheme for open graph if opts[:image].present? && opts[:image].start_with?("//")