Skip to content

Commit e92a812

Browse files
committed
Workaround for Windows paths in URI
1 parent 88d3207 commit e92a812

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: commands/instances.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"net/url"
2222
"path/filepath"
23+
"runtime"
2324
"strings"
2425
"time"
2526

@@ -472,7 +473,7 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
472473
failed := false
473474
result := &rpc.UpdateIndexResponse_Result{}
474475
for _, u := range urls {
475-
URL, err := utils.URLParse(u)
476+
URL, err := url.Parse(u)
476477
if err != nil {
477478
logrus.Warnf("unable to parse additional URL: %s", u)
478479
msg := fmt.Sprintf("%s: %v", tr("Unable to parse URL"), err)
@@ -487,6 +488,11 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
487488

488489
if URL.Scheme == "file" {
489490
path := paths.New(URL.Path)
491+
if URL.Scheme == "file" && runtime.GOOS == "windows" && len(URL.Path) > 1 {
492+
// https://github.com/golang/go/issues/32456
493+
// Parsed local file URLs on Windows are returned with a leading / so we remove it
494+
path = paths.New(URL.Path[1:])
495+
}
490496
if _, err := packageindex.LoadIndexNoSign(path); err != nil {
491497
msg := fmt.Sprintf("%s: %v", tr("Invalid package index in %s", path), err)
492498
downloadCB.Start(u, tr("Downloading index: %s", filepath.Base(URL.Path)))

0 commit comments

Comments
 (0)