class Sprockets::URITar

Internal: used to “expand” and “compress” values for storage

def compress

Returns String

uri will be returned.
If a uri is outside of the environment's root the original

be shortened to be a relative path.
If a uri is inside of an environment's root it will

Internal: Converts full uri to a "compressed" uri
def compress
  scheme + compressed_path
end

def compressed_path

Returns String

Only path information is returned, and not scheme.

Otherwise an absolute path will be returned.
it will return a path relative to the environment root.
If the input uri is relative to the environment root

Internal: Returns "compressed" path
def compressed_path
  if compressed_path = @env.split_subpath(root, path)
    compressed_path
  else
    path
  end
end

def expand

Returns String

file:///This/is/an/absolute/path

If a uri is outside the root, it will start with a slash:

file://this/is/a/relative/path

start with a slash for example:
If a uri is inside of the environment's root it will not

Internal: Convert a "compressed" uri to an absolute path
def expand
  if path.start_with?("/".freeze)
    # Stored path was absolute, don't add root
    scheme + path
  else
    # Stored path was relative, add root
    scheme + File.join(root, path)
  end
end

def initialize(uri, env)

env - The current "environment" that assets are being loaded into.
uri - A String containing URI that may or may not contain the scheme

Internal: Initialize object for compression or expansion
def initialize(uri, env)
  @root = env.root
  @env  = env
  if uri.include?("://".freeze)
    uri_array = uri.split("://".freeze)
    @scheme   = uri_array.shift
    @scheme   << "://".freeze
    @path     = uri_array.join("".freeze)
  else
    @scheme = "".freeze
    @path   = uri
  end
end