Skip to content

Commit 06dfc6c

Browse files
author
rubyist
committed
Fix object link generation when not using a /user/repo based URL
1 parent 9f30095 commit 06dfc6c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

server.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ type ObjectError struct {
5252

5353
// ObjectLink builds a URL linking to the object.
5454
func (v *RequestVars) ObjectLink() string {
55-
path := fmt.Sprintf("/%s/%s/objects/%s", v.User, v.Repo, v.Oid)
55+
path := ""
56+
57+
if len(v.User) > 0 {
58+
path += fmt.Sprintf("/%s", v.User)
59+
}
60+
61+
if len(v.Repo) > 0 {
62+
path += fmt.Sprintf("/%s", v.Repo)
63+
}
64+
65+
path += fmt.Sprintf("/objects/%s", v.Oid)
5666

5767
if Config.IsHTTPS() {
5868
return fmt.Sprintf("%s://%s%s", Config.Scheme, Config.Host, path)

0 commit comments

Comments
 (0)