2013-11-20 20:10:08 +08:00
|
|
|
module UrlHelper
|
|
|
|
|
|
|
|
def is_local(url)
|
2013-12-06 18:16:13 +08:00
|
|
|
Discourse.store.has_been_uploaded?(url) ||
|
|
|
|
url =~ /^\/assets\// ||
|
2014-01-15 06:51:36 +08:00
|
|
|
url =~ /^\/plugins\// ||
|
2013-12-06 18:16:13 +08:00
|
|
|
url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
|
2013-11-20 20:10:08 +08:00
|
|
|
end
|
|
|
|
|
2013-12-17 07:35:34 +08:00
|
|
|
def absolute(url, cdn = Discourse.asset_host)
|
|
|
|
url =~ /^\/[^\/]/ ? (cdn || Discourse.base_url_no_prefix) + url : url
|
|
|
|
end
|
|
|
|
|
|
|
|
def absolute_without_cdn(url)
|
|
|
|
absolute(url, nil)
|
2013-11-20 20:10:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def schemaless(url)
|
|
|
|
url.gsub(/^https?:/, "")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|