-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit fixes building file paths on platforms that use leading slashes. Before the `file://` uri had too many slashes with a path that starts with a backslash. This fix checks the string to see if it starts with a slash and adds the appropriate amount of slashes.
- Loading branch information
Showing
4 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module PuppetLanguageServer | ||
module UriHelper | ||
def self.build_file_uri(path) | ||
path.start_with?('/') ? 'file://' + path : 'file:///' + path | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
spec/languageserver/unit/puppet-languageserver/uri_helper_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'spec_helper' | ||
|
||
describe 'uri_helper' do | ||
describe '#build_file_uri' do | ||
it 'should return /// without leading slash' do | ||
test = PuppetLanguageServer::UriHelper.build_file_uri('C:\foo.pp') | ||
expect(test).to eq('file:///C:\foo.pp') | ||
end | ||
it 'should return // with a leading slash' do | ||
test = PuppetLanguageServer::UriHelper.build_file_uri('/opt/foo/foo.pp') | ||
expect(test).to eq('file:///opt/foo/foo.pp') | ||
end | ||
end | ||
end |