-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is in response to issue at: #50 A panic would be raised on Windows computers, where removing the file:// scheme would still have an invalid leading slash (e.g. '/C:/Users/...'). Fixes #50
- Loading branch information
1 parent
8a4b03e
commit ef4774b
Showing
7 changed files
with
65 additions
and
5 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
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,9 @@ | ||
package langserver | ||
|
||
import ( | ||
"github.com/go-language-server/uri" | ||
) | ||
|
||
func absolutePath(in string) (uri.URI, error) { | ||
return uri.Parse(string(in)) | ||
} |
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,33 @@ | ||
package langserver | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAbsolutePath(t *testing.T) { | ||
tests := []struct { | ||
path string | ||
expected string | ||
}{ | ||
{ | ||
path: "file:///C:/Users/acmeuser/git/tf-test/main.tf", | ||
expected: "C:/Users/acmeuser/git/tf-test/main.tf", | ||
}, | ||
{ | ||
path: "file:///etc/fstab", | ||
expected: "/etc/fstab", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
uri, err := absolutePath(test.path) | ||
if err != nil { | ||
t.Errorf("Parsing path '%s' resulted in error: %s", test.path, err) | ||
} | ||
res := uri.Filename() | ||
|
||
if res != test.expected { | ||
t.Errorf("Unexpected result. Got '%s', Expected '%s'", res, test.expected) | ||
} | ||
} | ||
} |