Fix URL building for default repo branch API
Using the base URL in path.Join caused it to remove the two slashes (because /////tmp == /tmp): `https:/tildegit.org/api/v1/repos/owner/name` Then, using that in URL.Parse causes it to see a `https:` scheme, and the / right afterwards means "start a path here", not a hostname, because hostnames begin with two slashes. That's a valid URL, with no hostname. Then it gets turned back into a string: `https:///tildegit.org/api/v1/repos/owner/name` That's another way of expressing the same URL with no hostname: //<empty hostname>/<path>. curl, Firefox and Chromium all fix the triple slash automatically, but fasthttp doesn't, and it tries to look up the empty string as a DNS host!
This commit is contained in:
parent
1955acce05
commit
d84955e6cd
@ -64,7 +64,7 @@ func giteaGetRepoDefaultBranch(giteaRoot, repoOwner, repoName, giteaAPIToken str
|
||||
|
||||
req := fasthttp.AcquireRequest()
|
||||
baseUrl, _ := url.Parse(giteaRoot)
|
||||
apiPath, _ := baseUrl.Parse(path.Join(giteaRoot, giteaAPIRepos, repoOwner, repoName))
|
||||
apiPath, _ := baseUrl.Parse(path.Join(giteaAPIRepos, repoOwner, repoName))
|
||||
|
||||
log.Debug().Msgf("giteaGetRepoDefaultBranch: trying path %s", apiPath)
|
||||
req.SetRequestURI(apiPath.String())
|
||||
|
Loading…
Reference in New Issue
Block a user