mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
DEV: update base url links to respect subfolder installs (#27740)
This change eliminates a couple of instances where subfolder urls are badly formatted, in most cases we can use Discourse.base_url_no_prefix to prevent adding the subfolder to the base url.
This commit is contained in:
parent
e58cf24fcc
commit
f44ec18fd2
|
@ -24,7 +24,7 @@ module EmailHelper
|
||||||
|
|
||||||
def email_topic_link(topic)
|
def email_topic_link(topic)
|
||||||
url, title = extract_details(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>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_html_template
|
def email_html_template
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<li>
|
<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>
|
<span><%= post_count %></span>
|
||||||
<%= category_badge(topic.category, inline_style: true, absolute_url: true) %>
|
<%= category_badge(topic.category, inline_style: true, absolute_url: true) %>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -171,7 +171,9 @@ module Email
|
||||||
|
|
||||||
if topic
|
if topic
|
||||||
if SiteSetting.private_email?
|
if 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
|
else
|
||||||
@message.header["List-Archive"] = topic.url
|
@message.header["List-Archive"] = topic.url
|
||||||
end
|
end
|
||||||
|
|
11
spec/helpers/email_helper_spec.rb
Normal file
11
spec/helpers/email_helper_spec.rb
Normal file
|
@ -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
|
||||||
|
end
|
|
@ -2238,6 +2238,17 @@ RSpec.describe Post do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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" do
|
describe "public_posts_count_per_day" do
|
||||||
before do
|
before do
|
||||||
freeze_time_safe
|
freeze_time_safe
|
||||||
|
|
Loading…
Reference in New Issue
Block a user