A platform for community discussion. Free, open, simple.
DEV: update base url links to respect subfolder installs (#27740)
David Battersbyf44ec18fd239
diff --git a/app/helpers/email_helper.rb b/app/helpers/email_helper.rbindex 64cb028c535..a542c3b66d3 100644--- a/app/helpers/email_helper.rb+++ b/app/helpers/email_helper.rb@@ -24,7 +24,7 @@ module EmailHelperdef email_topic_link(topic)url, title = extract_details(topic)- raw "<a href='#{Discourse.base_url}#{url}' style='color: ##{@anchor_color}'>#{title}</a>"+ raw "<a href='#{Discourse.base_url_no_prefix}#{url}' style='color: ##{@anchor_color}'>#{title}</a>"enddef email_html_templatediff --git a/app/views/email/_mailing_list_post.html.erb b/app/views/email/_mailing_list_post.html.erbindex 43d09820e2e..a16e0d525af 100644--- a/app/views/email/_mailing_list_post.html.erb+++ b/app/views/email/_mailing_list_post.html.erb@@ -1,5 +1,5 @@<li>- <a href='<%= Discourse.base_url + topic.relative_url %>' style='color: #<%= @anchor_color %>'><%= raw format_topic_title(topic.title) %></a>+ <a href='<%= Discourse.base_url_no_prefix + topic.relative_url %>' style='color: #<%= @anchor_color %>'><%= raw format_topic_title(topic.title) %></a><span><%= post_count %></span><%= category_badge(topic.category, inline_style: true, absolute_url: true) %></li>diff --git a/lib/email/sender.rb b/lib/email/sender.rbindex 5ec4acd8dac..59286747a5f 100644--- a/lib/email/sender.rb+++ b/lib/email/sender.rb@@ -171,7 +171,9 @@ module Emailif topicif SiteSetting.private_email?- @message.header["List-Archive"] = "#{Discourse.base_url}#{topic.slugless_url}"+ @message.header[+ "List-Archive"+ ] = "#{Discourse.base_url_no_prefix}#{topic.slugless_url}"else@message.header["List-Archive"] = topic.urlenddiff --git a/spec/helpers/email_helper_spec.rb b/spec/helpers/email_helper_spec.rbnew file mode 100644index 00000000000..5b4b318cc05--- /dev/null+++ b/spec/helpers/email_helper_spec.rb@@ -0,0 +1,11 @@+# frozen_string_literal: true++RSpec.describe EmailHelper do+ describe "#email_topic_link" do+ it "respects subfolder" do+ set_subfolder "/forum"+ topic = Fabricate(:topic)+ expect(helper.email_topic_link(topic)).to include("#{Discourse.base_url_no_prefix}/forum/t")+ end+ end+enddiff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rbindex 2ca17c1e4ec..1f78830c302 100644--- a/spec/models/post_spec.rb+++ b/spec/models/post_spec.rb@@ -2238,6 +2238,17 @@ RSpec.describe Post doendend+ describe "full_url" do+ it "returns the correct post url with subfolder install" do+ set_subfolder "/forum"+ post = Fabricate(:post)++ expect(post.full_url).to eq(+ "#{Discourse.base_url_no_prefix}/forum/t/#{post.topic.slug}/#{post.topic.id}/#{post.post_number}",+ )+ end+ end+describe "public_posts_count_per_day" dobefore dofreeze_time_safe