Module: Solargraph::LanguageServer::UriHelpers

Overview

Methods to handle conversions between file URIs and paths.

Class Method Summary collapse

Class Method Details

.file_to_uri(file) ⇒ String

Convert a file path to a URI.


20
21
22
# File 'lib/solargraph/language_server/uri_helpers.rb', line 20

def file_to_uri file
  "file://#{URI.encode(file.gsub(/^([a-z]\:)/i, '/\1'))}"
end

.uri_to_file(uri) ⇒ String

Convert a file URI to a path.


12
13
14
# File 'lib/solargraph/language_server/uri_helpers.rb', line 12

def uri_to_file uri
  URI.decode(uri).sub(/^file\:\/\//, '').sub(/^\/([a-z]\:)/i, '\1')
end