module ActionView::Helpers::AssetUrlHelper

def asset_path(source, options = {})

asset_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
asset_path "application", type: :stylesheet # => /assets/application.css
asset_path "application", type: :javascript # => /assets/application.js
asset_path "application.js" # => /assets/application.js

All other asset *_path helpers delegate through this method.

to the corresponding public directory.
options is set, a file extension will be appended and scoped
Computes the path to asset in public directory. If :type
def asset_path(source, options = {})
  raise ArgumentError, "nil is not a valid asset source" if source.nil?
  source = source.to_s
  return "" unless source.present?
  return source if source =~ URI_REGEXP
  tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, ''.freeze)
  if extname = compute_asset_extname(source, options)
    source = "#{source}#{extname}"
  end
  if source[0] != ?/
    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