6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 22:39:41 +00:00

Use the configured default host when host is empty after parsing the URL

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-30 12:45:07 +02:00
parent 1798816b6a
commit 7e42b1e3e9
2 changed files with 7 additions and 4 deletions

View File

@@ -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
}

View File

@@ -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"},
}