mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 05:00:01 +02:00
Use project's redirect url instead of composing url (#33058)
Fix #32992 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit 20c7fba60157067252af49da41b6f8929a5ae31a) Conflicts: routers/web/repo/issue_new.go the function is at routers/web/repo/issue.go in Forgejo
This commit is contained in:
parent
15ff226a5b
commit
81f30218cf
4 changed files with 26 additions and 11 deletions
|
@ -126,6 +126,14 @@ func (p *Project) LoadRepo(ctx context.Context) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
func ProjectLinkForOrg(org *user_model.User, projectID int64) string { //nolint
|
||||
return fmt.Sprintf("%s/-/projects/%d", org.HomeLink(), projectID)
|
||||
}
|
||||
|
||||
func ProjectLinkForRepo(repo *repo_model.Repository, projectID int64) string { //nolint
|
||||
return fmt.Sprintf("%s/projects/%d", repo.Link(), projectID)
|
||||
}
|
||||
|
||||
// Link returns the project's relative URL.
|
||||
func (p *Project) Link(ctx context.Context) string {
|
||||
if p.OwnerID > 0 {
|
||||
|
@ -134,7 +142,7 @@ func (p *Project) Link(ctx context.Context) string {
|
|||
log.Error("LoadOwner: %v", err)
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%s/-/projects/%d", p.Owner.HomeLink(), p.ID)
|
||||
return ProjectLinkForOrg(p.Owner, p.ID)
|
||||
}
|
||||
if p.RepoID > 0 {
|
||||
err := p.LoadRepo(ctx)
|
||||
|
@ -142,7 +150,7 @@ func (p *Project) Link(ctx context.Context) string {
|
|||
log.Error("LoadRepo: %v", err)
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%s/projects/%d", p.Repo.Link(), p.ID)
|
||||
return ProjectLinkForRepo(p.Repo, p.ID)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue