module Sprockets::AssetURI
def self.build(path, params = {})
params - Hash of optional parameters
path - String file path
# => "file:///tmp/js/application.coffee?type=application/javascript"
build("/tmp/js/application.coffee", type: "application/javascript")
Examples
Internal: Build Asset URI.
def self.build(path, params = {}) query = [] params.each do |key, value| case value when String query << "#{key}=#{value}" when TrueClass query << "#{key}" when FalseClass, NilClass else raise TypeError, "unexpected type: #{value.class}" end end uri = "file://#{URI::Generic::DEFAULT_PARSER.escape(path)}" uri << "?#{query.join('&')}" if query.any? uri end