Skip to content
Snippets Groups Projects
Commit 23c44a22 authored by Ken Brooks's avatar Ken Brooks
Browse files

updating to pull back in the fileuri code and dependency

parent b018d7f3
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ go 1.12 ...@@ -5,6 +5,7 @@ go 1.12
require ( require (
github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-homedir v1.1.0
github.com/xeipuuv/gojsonschema v1.2.0 github.com/xeipuuv/gojsonschema v1.2.0
neilpa.me/go-x v0.1.0
sigs.k8s.io/yaml v1.2.0 sigs.k8s.io/yaml v1.2.0
) )
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
"github.com/xeipuuv/gojsonschema" "github.com/xeipuuv/gojsonschema"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
//"neilpa.me/go-x/fileuri" "neilpa.me/go-x/fileuri"
) )
const ( const (
...@@ -271,25 +271,10 @@ func usageError(msg string) int { ...@@ -271,25 +271,10 @@ func usageError(msg string) int {
} }
func fileUri(path string) string { func fileUri(path string) string {
abs, err := filepath.Abs(path) uri, err := fileuri.FromPath(path)
if err != nil { if err != nil {
log.Fatalf("%s: %s", path, err) log.Fatalf("%s: %s", path, err)
} }
uri := "file://"
if runtime.GOOS == "windows" {
// This is not formally correct for all corner cases in windows
// file handling but should work for all standard cases. See:
// https://docs.microsoft.com/en-us/archive/blogs/ie/file-uris-in-windows
uri = uri + "/" + strings.ReplaceAll(
strings.ReplaceAll(abs, "\\", "/"),
" ", "%20",
)
} else {
uri = uri + abs
}
return uri return uri
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment