You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use URL.Parse() on a domain which does not create an error but returns an empty string when calling Hostname() afterwards.
I would suggest to either rename the parameter GitlabHostname to GitlabURL and use a URL from now on or jsut before calling the URL parse, format the string to contain the scheme so that we can parse it correctly.
I would also add a unit test to verify that this continue to work in the future.
@lkysow I would gladly submit a PR for this issue once we have worked out what's the best solution if that's ok with you.
P.S.: Here is an example code to reproduce the issue:
package main
import (
"fmt"
"log"
"net/url"
)
func main() {
u, err := url.Parse("https://example.org")
if err != nil {
log.Fatal(err)
}
fmt.Println(u.Hostname())
u, err = url.Parse("example.org")
if err != nil {
log.Fatal(err)
}
fmt.Println(u.Hostname())
}
Output:
example.org
The text was updated successfully, but these errors were encountered:
// If not using gitlab.com we need to set the URL to the API.ifhostname!="gitlab.com" {
if!strings.HasPrefix(hostname, "http://") &&!strings.HasPrefix(hostname, "https://") {
hostname="https://"+hostname
}
// Warn if this hostname isn't resolvable. The GitLab client// doesn't give good error messages in this case.u, err:=url.Parse(hostname)
iferr!=nil {
returnnil, errors.Wrapf(err, "parsing hostname %q", hostname)
}
ips, err:=net.LookupIP(u.Hostname())
iferr!=nil {
logger.Warn("unable to resolve %q: %s", u.Hostname(), err)
} elseiflen(ips) ==0 {
logger.Warn("found no IPs while resolving %q", u.Hostname())
}
// Now we're ready to construct the client.hostname=strings.TrimSuffix(hostname, "/")
apiURL:=fmt.Sprintf("%s/api/v4/", hostname)
iferr:=client.Client.SetBaseURL(apiURL); err!=nil {
returnnil, errors.Wrapf(err, "setting GitLab API URL: %s", apiURL)
}
}
Hey,
While upgrading to the 0.4.12 version, I noticed that the feature introduced in #366 specifically in commit ba04564
The problem appears at this line: ba04564#diff-4431759fdf270c83e7713adcd0cf7d5aR52
We use
URL.Parse()
on a domain which does not create an error but returns an empty string when callingHostname()
afterwards.I would suggest to either rename the parameter GitlabHostname to GitlabURL and use a URL from now on or jsut before calling the URL parse, format the string to contain the scheme so that we can parse it correctly.
I would also add a unit test to verify that this continue to work in the future.
@lkysow I would gladly submit a PR for this issue once we have worked out what's the best solution if that's ok with you.
P.S.: Here is an example code to reproduce the issue:
Output:
The text was updated successfully, but these errors were encountered: