use more path.Join()

This commit is contained in:
6543 2021-12-15 06:20:36 +01:00
parent 06b6875f95
commit 2ee530394e
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE

View file

@ -82,7 +82,7 @@ func (o *Options) Upstream(ctx *fasthttp.RequestCtx, giteaRoot, giteaAPIToken st
log.Debug().Msg("preparations")
// Make a GET request to the upstream URL
uri := o.TargetOwner + "/" + o.TargetRepo + "/raw/" + o.TargetBranch + "/" + o.TargetPath
uri := path.Join(o.TargetOwner, o.TargetRepo, "raw", o.TargetBranch, o.TargetPath)
var req *fasthttp.Request
var res *fasthttp.Response
var cachedResponse fileResponse
@ -91,7 +91,7 @@ func (o *Options) Upstream(ctx *fasthttp.RequestCtx, giteaRoot, giteaAPIToken st
cachedResponse = cachedValue.(fileResponse)
} else {
req = fasthttp.AcquireRequest()
req.SetRequestURI(giteaRoot + giteaApiRepos + uri)
req.SetRequestURI(path.Join(giteaRoot, giteaApiRepos, uri))
req.Header.Set(fasthttp.HeaderAuthorization, giteaAPIToken)
res = fasthttp.AcquireResponse()
res.SetBodyStream(&strings.Reader{}, -1)