FIX: detect local assets for subfolder installs
This commit is contained in:
parent
95ada3f190
commit
2863abefdd
|
@ -18,7 +18,7 @@ class UrlHelper
|
|||
def self.is_local(url)
|
||||
url.present? && (
|
||||
Discourse.store.has_been_uploaded?(url) ||
|
||||
!!(url =~ /^\/(assets|plugins|images)\//) ||
|
||||
!!(url =~ Regexp.new("^#{Discourse.base_uri}/(assets|plugins|images)/")) ||
|
||||
url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
|
||||
)
|
||||
end
|
||||
|
|
|
@ -28,6 +28,14 @@ describe UrlHelper do
|
|||
expect(UrlHelper.is_local("/assets/javascripts/all.js")).to eq(true)
|
||||
end
|
||||
|
||||
it "is true for relative assets for subfolders" do
|
||||
store = stub
|
||||
store.expects(:has_been_uploaded?).returns(false)
|
||||
Discourse.stubs(:store).returns(store)
|
||||
Discourse.stubs(:base_uri).returns("/subpath")
|
||||
expect(UrlHelper.is_local("/subpath/assets/javascripts/all.js")).to eq(true)
|
||||
end
|
||||
|
||||
it "is true for plugin assets" do
|
||||
store = stub
|
||||
store.expects(:has_been_uploaded?).returns(false)
|
||||
|
|
Loading…
Reference in New Issue