FIX: canonical url should not use the CDN
This commit is contained in:
parent
7fb985a02e
commit
2ce75a8523
|
@ -59,7 +59,7 @@ class TopicsController < ApplicationController
|
|||
|
||||
perform_show_response
|
||||
|
||||
canonical_url absolute(@topic_view.canonical_path)
|
||||
canonical_url absolute_without_cdn(@topic_view.canonical_path)
|
||||
end
|
||||
|
||||
def wordpress
|
||||
|
|
|
@ -6,8 +6,12 @@ module UrlHelper
|
|||
url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
|
||||
end
|
||||
|
||||
def absolute(url)
|
||||
url =~ /^\/[^\/]/ ? (Discourse.asset_host || Discourse.base_url_no_prefix) + url : url
|
||||
def absolute(url, cdn = Discourse.asset_host)
|
||||
url =~ /^\/[^\/]/ ? (cdn || Discourse.base_url_no_prefix) + url : url
|
||||
end
|
||||
|
||||
def absolute_without_cdn(url)
|
||||
absolute(url, nil)
|
||||
end
|
||||
|
||||
def schemaless(url)
|
||||
|
|
|
@ -33,10 +33,24 @@ describe UrlHelper do
|
|||
helper.absolute("http://www.discourse.org").should == "http://www.discourse.org"
|
||||
end
|
||||
|
||||
it "changes a relative url to an absolute one" do
|
||||
it "changes a relative url to an absolute one using base url by default" do
|
||||
helper.absolute("/path/to/file").should == "http://test.localhost/path/to/file"
|
||||
end
|
||||
|
||||
it "changes a relative url to an absolute one using the cdn when enabled" do
|
||||
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
|
||||
helper.absolute("/path/to/file").should == "http://my.cdn.com/path/to/file"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#absolute_without_cdn" do
|
||||
|
||||
it "changes a relative url to an absolute one using base url even when cdn is enabled" do
|
||||
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
|
||||
helper.absolute_without_cdn("/path/to/file").should == "http://test.localhost/path/to/file"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#schemaless" do
|
||||
|
|
Loading…
Reference in New Issue