From 412c2c2e3ad15573f3f8f0cc83fb7402802664de Mon Sep 17 00:00:00 2001 From: Catherine Date: Sat, 20 Sep 2025 03:55:58 +0000 Subject: [PATCH] Fix issues found by staticcheck. NFC --- src/manifest.go | 6 +++--- src/pages.go | 20 -------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/manifest.go b/src/manifest.go index 2edc612..5cdf3b5 100644 --- a/src/manifest.go +++ b/src/manifest.go @@ -40,7 +40,7 @@ func CompareManifest(left *Manifest, right *Manifest) bool { if leftEntry.GetType() != rightEntry.GetType() { return false } - if bytes.Compare(leftEntry.Data, rightEntry.Data) != 0 { + if !bytes.Equal(leftEntry.Data, rightEntry.Data) { return false } } @@ -74,7 +74,7 @@ func ManifestDebugJSON(manifest *Manifest) []byte { const maxSymlinkLevels int = 128 -var symlinkLoop = errors.New("symbolic link loop") +var errSymlinkLoop = errors.New("symbolic link loop") func ExpandSymlinks(manifest *Manifest, inPath string) (string, error) { var levels int @@ -98,7 +98,7 @@ again: if levels < maxSymlinkLevels { return inPath, nil } else { - return "", symlinkLoop + return "", errSymlinkLoop } } diff --git a/src/pages.go b/src/pages.go index 6aac20a..99e6cda 100644 --- a/src/pages.go +++ b/src/pages.go @@ -160,26 +160,6 @@ func getPage(w http.ResponseWriter, r *http.Request) error { return nil } -func getProjectName(w http.ResponseWriter, r *http.Request) (string, error) { - // path must be either `/` or `/foo/` (`/foo` is accepted as an alias) - path, _ := strings.CutPrefix(r.URL.Path, "/") - path, _ = strings.CutSuffix(path, "/") - if strings.HasPrefix(path, ".") { - http.Error(w, "this directory name is reserved for system use", http.StatusBadRequest) - return "", fmt.Errorf("reserved name") - } else if strings.Contains(path, "/") { - http.Error(w, "only one level of nesting is allowed", http.StatusBadRequest) - return "", fmt.Errorf("nesting too deep") - } - - if path == "" { - // path `/` corresponds to pseudo-project `.index` - return ".index", nil - } else { - return path, nil - } -} - func putPage(w http.ResponseWriter, r *http.Request) error { auth, err := AuthorizeUpdate(r) if err != nil {