2013-11-20 07:10:08 -05:00
|
|
|
module UrlHelper
|
|
|
|
|
|
|
|
def is_local(url)
|
2013-12-06 05:16:13 -05:00
|
|
|
Discourse.store.has_been_uploaded?(url) ||
|
|
|
|
url =~ /^\/assets\// ||
|
2014-01-14 17:51:36 -05:00
|
|
|
url =~ /^\/plugins\// ||
|
2013-12-06 05:16:13 -05:00
|
|
|
url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
|
2013-11-20 07:10:08 -05:00
|
|
|
end
|
|
|
|
|
2013-12-16 18:35:34 -05: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 07:10:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def schemaless(url)
|
|
|
|
url.gsub(/^https?:/, "")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|