module Hanko::AssetUrlHelper
Constants
- URI_REGEXP
Public Instance Methods
asset_path(source, options = {})
click to toggle source
# File lib/hanko/asset_url_helper.rb, line 5 def asset_path(source, options = {}) source = source.to_s return "" if source.empty? return source if URI_REGEXP === source if index = source.index(/[?#]/) source, tail = source[0, index], source[index..-1] end if extname = compute_asset_extname(source, options) source = "#{source}#{extname}" end if source[0] != ?/ options[:fingerprint] = !tail source = compute_asset_path(source, options) end relative_url_root = defined?(config.relative_url_root) && config.relative_url_root if relative_url_root source = File.join(relative_url_root, source) unless source.starts_with?("#{relative_url_root}/") end if host = compute_asset_host(source, options) source = File.join(host, source) end "#{source}#{tail}" end
Also aliased as: path_to_asset
compute_asset_path(source, options = {})
click to toggle source
Calls superclass method
# File lib/hanko/asset_url_helper.rb, line 36 def compute_asset_path(source, options = {}) fingerprint = options.delete(:fingerprint) source = super return source unless fingerprint asset_id = Hanko::Fingerprint.pon(config.assets_dir, source) if asset_id.empty? source else "#{source}?#{asset_id}" end end