-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing LSP URIs containing spaces (#38)
- Loading branch information
1 parent
83b14ca
commit 3664734
Showing
2 changed files
with
43 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package lsp | ||
|
||
import ( | ||
"net/url" | ||
"github.com/mickael-menu/zk/internal/util/errors" | ||
) | ||
|
||
func pathToURI(path string) string { | ||
u := &url.URL{ | ||
Scheme: "file", | ||
Path: path, | ||
} | ||
return u.String() | ||
} | ||
|
||
|
||
func uriToPath(uri string) (string, error) { | ||
parsed, err := url.Parse(uri) | ||
if err != nil { | ||
return "", err | ||
} | ||
if parsed.Scheme != "file" { | ||
return "", errors.New("URI was not a file:// URI") | ||
} | ||
return parsed.Path, nil | ||
} | ||
|