Module: Solargraph::LanguageServer::UriHelpers
- Included in:
- Host, Message::TextDocument::Base, Message::TextDocument::DocumentSymbol, Message::Workspace::DidChangeWatchedFiles, Message::Workspace::WorkspaceSymbol
- Defined in:
- lib/solargraph/language_server/uri_helpers.rb
Overview
Methods to handle conversions between file URIs and paths.
Class Method Summary collapse
-
.file_to_uri(file) ⇒ String
Convert a file path to a URI.
-
.uri_to_file(uri) ⇒ String
Convert a file URI to a path.
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 |