2013-11-20 06:10:08 -06:00
|
|
|
module UrlHelper
|
|
|
|
|
|
|
|
def is_local(url)
|
2014-07-18 10:54:18 -05:00
|
|
|
url.present? && (
|
|
|
|
Discourse.store.has_been_uploaded?(url) ||
|
2014-09-25 10:44:48 -05:00
|
|
|
!!(url =~ /^\/assets\//) ||
|
|
|
|
!!(url =~ /^\/plugins\//) ||
|
2014-07-18 10:54:18 -05:00
|
|
|
url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
|
|
|
|
)
|
2013-11-20 06:10:08 -06:00
|
|
|
end
|
|
|
|
|
2013-12-16 17:35:34 -06: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 06:10:08 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def schemaless(url)
|
2015-02-22 13:47:18 -06:00
|
|
|
url.sub(/^https?:/, "")
|
2013-11-20 06:10:08 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|