use absolute url for assets too
This commit is contained in:
parent
e5202b19c0
commit
4863c4517a
|
@ -197,20 +197,20 @@ class CookedPostProcessor
|
|||
def optimize_urls
|
||||
@doc.search("a").each do |a|
|
||||
href = a["href"].to_s
|
||||
if Discourse.store.has_been_uploaded?(href)
|
||||
a["href"] = schemaless relative_to_absolute(href)
|
||||
end
|
||||
a["href"] = schemaless absolute(href) if is_local(href)
|
||||
end
|
||||
|
||||
@doc.search("img").each do |img|
|
||||
src = img["src"].to_s
|
||||
if Discourse.store.has_been_uploaded?(src)
|
||||
img["src"] = schemaless relative_to_absolute(src)
|
||||
end
|
||||
img["src"] = schemaless absolute(src) if is_local(src)
|
||||
end
|
||||
end
|
||||
|
||||
def relative_to_absolute(url)
|
||||
def is_local(url)
|
||||
Discourse.store.has_been_uploaded?(url) || url =~ /^\/assets\//
|
||||
end
|
||||
|
||||
def absolute(url)
|
||||
url =~ /^\/[^\/]/ ? (Discourse.asset_host || Discourse.base_url_no_prefix) + url : url
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue