Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 7be4c2d

Browse files
author
noah
committed
Fix the link
1 parent 69970aa commit 7be4c2d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

internal/pkg/github/link.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package github
22

33
import (
44
"context"
5+
"fmt"
56
"net/http"
6-
"path"
77

88
"github.com/gitploy-io/gitploy/model/ent"
99
"github.com/gitploy-io/gitploy/pkg/e"
@@ -23,7 +23,7 @@ func (g *Github) GetConfigRedirectURL(ctx context.Context, u *ent.User, r *ent.R
2323

2424
// The latest version file on the main branch.
2525
// https://docs.github.com/en/repositories/working-with-files/using-files/getting-permanent-links-to-files
26-
url := path.Join(*remote.HTMLURL, "blob", *remote.DefaultBranch, r.ConfigPath)
26+
url := fmt.Sprintf("%s/blob/%s/%s", *remote.HTMLURL, *remote.DefaultBranch, r.ConfigPath)
2727
return url, nil
2828
}
2929

@@ -41,6 +41,6 @@ func (g *Github) GetNewFileRedirectURL(ctx context.Context, u *ent.User, r *ent.
4141

4242
// Redirect to the URL to create a configuration file.
4343
// https://docs.github.com/en/enterprise-server@3.0/repositories/working-with-files/managing-files/creating-new-files
44-
url := path.Join(*remote.HTMLURL, "new", *remote.DefaultBranch, r.ConfigPath)
44+
url := fmt.Sprintf("%s/new/%s/%s", *remote.HTMLURL, *remote.DefaultBranch, r.ConfigPath)
4545
return url, nil
4646
}

internal/server/web/link.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func (w *Web) RedirectToConfig(c *gin.Context) {
3636
return
3737
}
3838

39+
w.log.Debug("Redirect to the URL.", zap.String("URL", url))
3940
c.Redirect(http.StatusMovedPermanently, url)
4041
}
4142

@@ -65,5 +66,6 @@ func (w *Web) RedirectToNewConfig(c *gin.Context) {
6566
return
6667
}
6768

68-
c.Redirect(http.StatusMovedPermanently, url)
69+
w.log.Debug("Redirect to the URL.", zap.String("URL", url))
70+
c.Redirect(http.StatusFound, url)
6971
}

0 commit comments

Comments
 (0)