mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 11:11:35 +00:00
Fix issues found by staticcheck. NFC
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
src/pages.go
20
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 {
|
||||
|
||||
Reference in New Issue
Block a user