module Sprockets::DigestUtils
def integrity_uri(digest, content_type = nil)
will block the loading of the asset.
be accurate if provided. Otherwise, subresource integrity
content_type - The content-type the asset will be served with. This *must*
digest - The String byte digest of the asset content.
attribute of an asset tag as per the subresource integrity specification.
Internal: Generate a "named information" URI for use in the `integrity`
def integrity_uri(digest, content_type = nil) 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 = NI_HASH_ALGORITHMS[digest_class] uri = "ni:///#{hash_name};#{pack_urlsafe_base64digest(digest)}" uri << "?ct=#{content_type}" if content_type uri end end