FIX: twitter card meta tags use wrong urls on subfolder installs

This commit is contained in:
Neil Lalonde 2016-10-05 15:14:51 -04:00
parent c70f52c4dd
commit f3eb58092d
1 changed files with 9 additions and 5 deletions

View File

@ -150,11 +150,15 @@ module ApplicationHelper
end end
# Use the correct scheme for open graph image # Use the correct scheme for open graph image
if opts[:image].present? && opts[:image].start_with?("//") if opts[:image].present?
uri = URI(Discourse.base_url) if opts[:image].start_with?("//")
opts[:image] = "#{uri.scheme}:#{opts[:image]}" uri = URI(Discourse.base_url)
elsif opts[:image].present? && opts[:image].start_with?("/uploads/") opts[:image] = "#{uri.scheme}:#{opts[:image]}"
opts[:image] = "#{Discourse.base_url}#{opts[:image]}" elsif opts[:image].start_with?("/uploads/")
opts[:image] = "#{Discourse.base_url}#{opts[:image]}"
elsif GlobalSetting.relative_url_root && opts[:image].start_with?(GlobalSetting.relative_url_root)
opts[:image] = "#{Discourse.base_url_no_prefix}#{opts[:image]}"
end
end end
# Add opengraph & twitter tags # Add opengraph & twitter tags