Skip to content

Commit

Permalink
fix: newFromTransport check scheme failure (#2076)
Browse files Browse the repository at this point in the history
Signed-off-by: 张启航 <[email protected]>
  • Loading branch information
ZhangSetSail authored Nov 21, 2024
1 parent 93dd431 commit f7469f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion builder/sources/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ func WrapTransport(transport http.RoundTripper, url, username, password string)

func newFromTransport(registryURL, username, password string, transport http.RoundTripper, logf LogfCallback) (*Registry, error) {
url := strings.TrimSuffix(registryURL, "/")
containsScheme := strings.HasPrefix(url, "https")
containsScheme := strings.HasPrefix(url, "http")
if !containsScheme {
// use https by default
url = fmt.Sprintf("https://%s", registryURL)
}
containsScheme = strings.HasPrefix(url, "http://")
if containsScheme {
url = strings.Replace(url, "http", "https", 1)
}

if username != "" {
transport = WrapTransport(transport, url, username, password)
Expand Down

0 comments on commit f7469f7

Please sign in to comment.