From 7e42b1e3e91652d62604f5b00702da20aa50cea4 Mon Sep 17 00:00:00 2001 From: Grzegorz Dlugoszewski Date: Sat, 30 May 2020 12:45:07 +0200 Subject: [PATCH] Use the configured default host when host is empty after parsing the URL --- pkg/url.go | 9 ++++++--- pkg/url_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/url.go b/pkg/url.go index 16b0c19..1f27680 100644 --- a/pkg/url.go +++ b/pkg/url.go @@ -43,13 +43,16 @@ func ParseURL(rawURL string) (url *urlpkg.URL, err error) { url.User = urlpkg.User("git") } - // Default to https + // Default to configured defaultHost when host is empty + if url.Host == "" { + url.Host = Cfg.DefaultHost() + } + + // Default to https when scheme is empty if url.Scheme == "" { url.Scheme = "https" } - // TODO: Default to github host - return url, nil } diff --git a/pkg/url_test.go b/pkg/url_test.go index 85cf2f2..e6ea5bf 100644 --- a/pkg/url_test.go +++ b/pkg/url_test.go @@ -44,7 +44,7 @@ func TestURLParse(t *testing.T) { {"ftp://github.com/grdl/git-get.git", "github.com/grdl/git-get"}, {"ftps://github.com/grdl/git-get.git", "github.com/grdl/git-get"}, {"rsync://github.com/grdl/git-get.git", "github.com/grdl/git-get"}, - {"local/grdl/git-get/", "local/grdl/git-get"}, + {"local/grdl/git-get/", "github.com/local/grdl/git-get"}, {"file://local/grdl/git-get", "local/grdl/git-get"}, }