[mirror] Scalable static site server for Git forges (like GitHub Pages)

Use `path.Join` where applicable. NFC

Changed files
+5 -4
src
+3 -2
src/audit.go
··· 8 8 "net/http" 9 9 "os" 10 10 "os/exec" 11 + "path" 11 12 "path/filepath" 12 13 "strconv" 13 14 "strings" ··· 115 116 func (record *AuditRecord) DescribeResource() string { 116 117 desc := "<unknown>" 117 118 if record.Domain != nil && record.Project != nil { 118 - desc = fmt.Sprintf("%s/%s", *record.Domain, *record.Project) 119 + desc = path.Join(*record.Domain, *record.Project) 119 120 } else if record.Domain != nil { 120 121 desc = *record.Domain 121 122 } ··· 292 293 if record.Project == nil { 293 294 subject = *record.Domain 294 295 } else { 295 - subject = fmt.Sprintf("%s/%s", *record.Domain, *record.Project) 296 + subject = path.Join(*record.Domain, *record.Project) 296 297 } 297 298 logc.Printf(ctx, "audit %s ok: %s %s\n", subject, id, record.Event.String()) 298 299
+2 -2
src/pages.go
··· 67 67 } 68 68 69 69 func makeWebRoot(host string, projectName string) string { 70 - return fmt.Sprintf("%s/%s", strings.ToLower(host), projectName) 70 + return path.Join(strings.ToLower(host), projectName) 71 71 } 72 72 73 73 func getWebRoot(r *http.Request) (string, error) { ··· 705 705 return err 706 706 } 707 707 708 - if event.Ref != fmt.Sprintf("refs/heads/%s", auth.branch) { 708 + if event.Ref != path.Join("refs", "heads", auth.branch) { 709 709 code := http.StatusUnauthorized 710 710 if strings.Contains(r.Header.Get("User-Agent"), "GitHub-Hookshot") { 711 711 // GitHub has no way to restrict branches for a webhook, and responding with 401