Skip to content

Commit db7abc5

Browse files
committed
Use *net.URL as parameter for DownloadIndex
This will turn out useful on next commits
1 parent 8c204d0 commit db7abc5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

common/net_functions.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,21 @@ import (
3535
"io"
3636
"io/ioutil"
3737
"net/http"
38+
"net/url"
3839
"os"
3940
"time"
4041

4142
"github.com/bcmi-labs/arduino-cli/pathutils"
4243
)
4344

4445
// DownloadIndex is a function to download a generic index.
45-
func DownloadIndex(indexPath pathutils.Path, URL string) error {
46+
func DownloadIndex(indexPath pathutils.Path, URL *url.URL) error {
4647
file, err := indexPath.Get()
4748
if err != nil {
4849
return err
4950
}
5051

51-
req, err := http.NewRequest("GET", URL, nil)
52+
req, err := http.NewRequest("GET", URL.String(), nil)
5253
if err != nil {
5354
return err
5455
}

cores/packageindex/index.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package packageindex
3232
import (
3333
"encoding/json"
3434
"io/ioutil"
35+
"net/url"
3536

3637
"github.com/bcmi-labs/arduino-cli/common/releases"
3738

@@ -41,7 +42,7 @@ import (
4142
)
4243

4344
// packageIndexURL contains the index URL for core packages.
44-
const packageIndexURL = "https://downloads.arduino.cc/packages/package_index.json"
45+
var packageIndexURL, _ = url.Parse("https://downloads.arduino.cc/packages/package_index.json")
4546

4647
// coreIndexPath returns the path of the index file for libraries.
4748
var coreIndexPath = configs.IndexPath("package_index.json")

libraries/download.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
package libraries
3131

3232
import (
33+
"net/url"
34+
3335
"github.com/bcmi-labs/arduino-cli/common"
3436
)
3537

36-
const (
37-
// libraryIndexURL is the URL where to get library index.
38-
libraryIndexURL string = "http://downloads.arduino.cc/libraries/library_index.json"
39-
)
38+
// libraryIndexURL is the URL where to get library index.
39+
var libraryIndexURL, _ = url.Parse("http://downloads.arduino.cc/libraries/library_index.json")
4040

4141
// DownloadLibrariesFile downloads the lib file from arduino repository.
4242
func DownloadLibrariesFile() error {

0 commit comments

Comments
 (0)