1
0
mirror of https://github.com/thomiceli/opengist synced 2024-11-12 07:05:50 +01:00

Trim gitea url

This commit is contained in:
Thomas Miceli 2023-04-17 21:31:40 +02:00
parent 6a0fd92516
commit 884195aed4
No known key found for this signature in database
GPG Key ID: D86C6F6390AF050F

@ -179,7 +179,7 @@ func oauthCallback(ctx echo.Context) error {
case "github": case "github":
resp, err = http.Get("https://github.com/" + user.NickName + ".keys") resp, err = http.Get("https://github.com/" + user.NickName + ".keys")
case "gitea": case "gitea":
resp, err = http.Get("https://gitea.com/" + user.NickName + ".keys") resp, err = http.Get(trimGiteaUrl() + "/" + user.NickName + ".keys")
} }
if err == nil { if err == nil {
@ -226,12 +226,8 @@ func oauth(ctx echo.Context) error {
httpProtocol = "https" httpProtocol = "https"
} }
giteaUrl := trimGiteaUrl()
httpDomain := httpProtocol + "://" + ctx.Request().Host httpDomain := httpProtocol + "://" + ctx.Request().Host
giteaUrl := config.C.GiteaUrl
// remove trailing slash
if giteaUrl[len(giteaUrl)-1] == '/' {
giteaUrl = giteaUrl[:len(giteaUrl)-1]
}
switch provider { switch provider {
case "github": case "github":
@ -296,3 +292,13 @@ func logout(ctx echo.Context) error {
deleteCsrfCookie(ctx) deleteCsrfCookie(ctx)
return redirect(ctx, "/all") return redirect(ctx, "/all")
} }
func trimGiteaUrl() string {
giteaUrl := config.C.GiteaUrl
// remove trailing slash
if giteaUrl[len(giteaUrl)-1] == '/' {
giteaUrl = giteaUrl[:len(giteaUrl)-1]
}
return giteaUrl
}