From f3eb58092d25a47a187d4aaa500fce71dbcaa298 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 5 Oct 2016 15:14:51 -0400 Subject: [PATCH] FIX: twitter card meta tags use wrong urls on subfolder installs --- app/helpers/application_helper.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d0e70b6b0df..9504f22a04a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -150,11 +150,15 @@ module ApplicationHelper end # Use the correct scheme for open graph image - if opts[:image].present? && opts[:image].start_with?("//") - uri = URI(Discourse.base_url) - opts[:image] = "#{uri.scheme}:#{opts[:image]}" - elsif opts[:image].present? && opts[:image].start_with?("/uploads/") - opts[:image] = "#{Discourse.base_url}#{opts[:image]}" + if opts[:image].present? + if opts[:image].start_with?("//") + uri = URI(Discourse.base_url) + opts[:image] = "#{uri.scheme}:#{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 # Add opengraph & twitter tags