@@ -23,7 +23,6 @@ import (
23
23
"net/url"
24
24
"os"
25
25
"path"
26
- "runtime"
27
26
28
27
"github.com/arduino/arduino-cli/arduino/builder"
29
28
"github.com/arduino/arduino-cli/arduino/cores"
@@ -33,6 +32,7 @@ import (
33
32
"github.com/arduino/arduino-cli/arduino/libraries/librariesindex"
34
33
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
35
34
"github.com/arduino/arduino-cli/arduino/security"
35
+ "github.com/arduino/arduino-cli/arduino/utils"
36
36
"github.com/arduino/arduino-cli/cli/globals"
37
37
"github.com/arduino/arduino-cli/configuration"
38
38
rpc "github.com/arduino/arduino-cli/rpc/commands"
@@ -207,7 +207,7 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
207
207
urls = append (urls , configuration .Settings .GetStringSlice ("board_manager.additional_urls" )... )
208
208
for _ , u := range urls {
209
209
logrus .Info ("URL: " , u )
210
- URL , err := url . Parse (u )
210
+ URL , err := utils . URLParse (u )
211
211
if err != nil {
212
212
logrus .Warnf ("unable to parse additional URL: %s" , u )
213
213
continue
@@ -217,23 +217,13 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
217
217
218
218
if URL .Scheme == "file" {
219
219
path := paths .New (URL .Path )
220
- if runtime .GOOS == "windows" {
221
- // Parsed local file URLs on Windows are returned with a leading /
222
- // so we remove it
223
- path = paths .New (URL .Path [1 :])
224
- }
225
- pathJSON , err := path .Abs ()
226
- if err != nil {
227
- return nil , fmt .Errorf ("can't get absolute path of %v: %w" , path , err )
228
- }
229
-
230
- if _ , err := packageindex .LoadIndexNoSign (pathJSON ); err != nil {
231
- return nil , fmt .Errorf ("invalid package index in %s: %s" , pathJSON , err )
220
+ if _ , err := packageindex .LoadIndexNoSign (path ); err != nil {
221
+ return nil , fmt .Errorf ("invalid package index in %s: %s" , path , err )
232
222
}
233
223
234
224
fi , _ := os .Stat (path .String ())
235
225
downloadCB (& rpc.DownloadProgress {
236
- File : "Updating index: " + pathJSON .Base (),
226
+ File : "Updating index: " + path .Base (),
237
227
TotalSize : fi .Size (),
238
228
})
239
229
downloadCB (& rpc.DownloadProgress {Completed : true })
@@ -667,25 +657,19 @@ func createInstance(ctx context.Context, getLibOnly bool) (*createInstanceResult
667
657
urls := []string {globals .DefaultIndexURL }
668
658
urls = append (urls , configuration .Settings .GetStringSlice ("board_manager.additional_urls" )... )
669
659
for _ , u := range urls {
670
- URL , err := url . Parse (u )
660
+ URL , err := utils . URLParse (u )
671
661
if err != nil {
672
662
logrus .Warnf ("Unable to parse index URL: %s, skip..." , u )
673
663
continue
674
664
}
675
665
676
666
if URL .Scheme == "file" {
677
667
path := paths .New (URL .Path )
678
- if runtime .GOOS == "windows" {
679
- // Parsed local file URLs on Windows are returned with a leading /
680
- // so we remove it
681
- path = paths .New (URL .Path [1 :])
682
- }
683
- pathJSON , err := path .Abs ()
684
668
if err != nil {
685
669
return nil , fmt .Errorf ("can't get absolute path of %v: %w" , path , err )
686
670
}
687
671
688
- _ , err = res .Pm .LoadPackageIndexFromFile (pathJSON )
672
+ _ , err = res .Pm .LoadPackageIndexFromFile (path )
689
673
if err != nil {
690
674
res .PlatformIndexErrors = append (res .PlatformIndexErrors , err .Error ())
691
675
}
0 commit comments