From cf269c55401f52d7caae07416da167acbd2d83d6 Mon Sep 17 00:00:00 2001 From: "oppili.bsky.social" Date: Thu, 17 Apr 2025 07:27:19 +0000 Subject: [PATCH] appview: state/repo: do not switch to dids in links fixes a a few links in blob and tree views that caused the link to switch from handle to did. --- appview/state/repo.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/appview/state/repo.go b/appview/state/repo.go index 22bafee3..256a8783 100644 --- a/appview/state/repo.go +++ b/appview/state/repo.go @@ -319,15 +319,15 @@ func (s *State) RepoTree(w http.ResponseWriter, r *http.Request) { user := s.auth.GetUser(r) var breadcrumbs [][]string - breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)}) + breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)}) if treePath != "" { for idx, elem := range strings.Split(treePath, "/") { breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)}) } } - baseTreeLink := path.Join(f.OwnerDid(), f.RepoName, "tree", ref, treePath) - baseBlobLink := path.Join(f.OwnerDid(), f.RepoName, "blob", ref, treePath) + baseTreeLink := path.Join(f.OwnerSlashRepo(), "tree", ref, treePath) + baseBlobLink := path.Join(f.OwnerSlashRepo(), "blob", ref, treePath) s.pages.RepoTree(w, pages.RepoTreeParams{ LoggedInUser: user, @@ -454,7 +454,7 @@ func (s *State) RepoBlob(w http.ResponseWriter, r *http.Request) { } var breadcrumbs [][]string - breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)}) + breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)}) if filePath != "" { for idx, elem := range strings.Split(filePath, "/") { breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)}) @@ -861,7 +861,15 @@ func (f *FullyResolvedRepo) OwnerHandle() string { } func (f *FullyResolvedRepo) OwnerSlashRepo() string { - p, _ := securejoin.SecureJoin(f.OwnerDid(), f.RepoName) + handle := f.OwnerId.Handle + + var p string + if handle != "" && !handle.IsInvalidHandle() { + p, _ = securejoin.SecureJoin(fmt.Sprintf("@%s", handle), f.RepoName) + } else { + p, _ = securejoin.SecureJoin(f.OwnerDid(), f.RepoName) + } + return p } -- 2.54.0