mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 21:27:16 -05:00
FIX: emails with embedded posts should always use absolute URLs
This commit is contained in:
@@ -177,4 +177,33 @@ describe PrettyText do
|
||||
end
|
||||
end
|
||||
|
||||
describe "make_all_links_absolute" do
|
||||
let(:base_url) { "http://baseurl.net" }
|
||||
|
||||
before do
|
||||
Discourse.stubs(:base_url).returns(base_url)
|
||||
end
|
||||
|
||||
it "adds base url to relative links" do
|
||||
html = "<p><a class=\"mention\" href=\"/users/wiseguy\">@wiseguy</a>, <a class=\"mention\" href=\"/users/trollol\">@trollol</a> what do you guys think? </p>"
|
||||
output = described_class.make_all_links_absolute(html)
|
||||
output.should == "<p><a class=\"mention\" href=\"#{base_url}/users/wiseguy\">@wiseguy</a>, <a class=\"mention\" href=\"#{base_url}/users/trollol\">@trollol</a> what do you guys think? </p>"
|
||||
end
|
||||
|
||||
it "doesn't change external absolute links" do
|
||||
html = "<p>Check out <a href=\"http://mywebsite.com/users/boss\">this guy</a>.</p>"
|
||||
described_class.make_all_links_absolute(html).should == html
|
||||
end
|
||||
|
||||
it "doesn't change internal absolute links" do
|
||||
html = "<p>Check out <a href=\"#{base_url}/users/boss\">this guy</a>.</p>"
|
||||
described_class.make_all_links_absolute(html).should == html
|
||||
end
|
||||
|
||||
it "can tolerate invalid URLs" do
|
||||
html = "<p>Check out <a href=\"not a real url\">this guy</a>.</p>"
|
||||
expect { described_class.make_all_links_absolute(html) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user