lib/hanko/asset_url_helper.rb in hanko-0.2.2 vs lib/hanko/asset_url_helper.rb in hanko-0.2.3
- old
+ new
@@ -1,44 +1,17 @@
module Hanko
module AssetUrlHelper
URI_REGEXP = %r{^(?:[-a-z]+://|cid:|data:|//)}i
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}"
+ @_hanko_has_tail = source.match?(/[\?#]/)
+ super
end
alias_method :path_to_asset, :asset_path
def compute_asset_path(source, options = {})
- fingerprint = options.delete(:fingerprint)
-
source = super
- return source unless fingerprint
+ return source if @_hanko_has_tail
asset_id = Hanko::Fingerprint.pon(config.assets_dir, source)
if asset_id.empty?
source
else