Module: SassC::Util

Defined in:
lib/sassc/embedded.rb

Class Method Summary collapse

Class Method Details

.file_url_to_path(url) ⇒ Object



392
393
394
395
396
397
398
# File 'lib/sassc/embedded.rb', line 392

def file_url_to_path(url)
  return if url.nil?

  path = URI::DEFAULT_PARSER.unescape(URI.parse(url).path)
  path = path[1..] if Gem.win_platform? && path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
  path
end

.path_to_file_url(path) ⇒ Object



400
401
402
403
404
405
406
# File 'lib/sassc/embedded.rb', line 400

def path_to_file_url(path)
  return if path.nil?

  path = File.absolute_path(path)
  path = "/#{path}" unless path.start_with? '/'
  URI::File.build([nil, URI::DEFAULT_PARSER.escape(path)]).to_s
end