refactor: use slices.Contains to simplify code (#5483)

pull/5470/head^2
rocksload 2025-10-17 22:45:47 +08:00 committed by GitHub
parent a397e7305d
commit 97b8911ba8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import (
"net/http"
"os"
"os/exec"
"slices"
"strings"
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
@ -266,13 +267,7 @@ var validHookFields = []string{
// IsValid checks if the provided field is on the valid fields list
func (hf *hookFields) IsValid(field string) bool {
for _, val := range validHookFields {
if field == val {
return true
}
}
return false
return slices.Contains(validHookFields, field)
}
// GetString returns the string value or provided default