diff --git a/internal/transport/transport.go b/internal/transport/transport.go index c7f66afb8..e1f386a26 100644 --- a/internal/transport/transport.go +++ b/internal/transport/transport.go @@ -5,6 +5,9 @@ import ( "fmt" "io" "net/url" + "os" + "path" + "strings" "time" ) @@ -19,7 +22,18 @@ func ReadJSON(uri string, timeout time.Duration, target interface{}) error { case "http", "https": reader, err = newHTTPReader(u.String(), timeout) case "file": - reader, err = newFileReader(u.Path) + // if we have a file URI with relative path we need to expand it into an + // absolute path, url.Parse doesn't support relative file paths + if strings.HasPrefix(uri, "file:///") { + reader, err = newFileReader(u.Path) + } else { + wd, e := os.Getwd() + if e != nil { + return e + } + absolutePath := path.Join(wd, strings.TrimPrefix(uri, "file://")) + reader, err = newFileReader(absolutePath) + } default: return fmt.Errorf("Unsupported URI scheme '%s' in '%s'", u.Scheme, u) }