module Sprockets::DigestUtils
def integrity_uri(digest)
digest - The String byte digest of the asset content.
as per the subresource integrity specification.
Public: Generate hash for use in the `integrity` attribute of an asset tag
def integrity_uri(digest) case digest when Digest::Base digest_class = digest.class digest = digest.digest when String digest_class = DIGEST_SIZES[digest.bytesize] else raise TypeError, "unknown digest: #{digest.inspect}" end if hash_name = HASH_ALGORITHMS[digest_class] "#{hash_name}-#{pack_base64digest(digest)}" end end