From f51b50031bc82477f2ad4efbbf82dd85cc5f699c Mon Sep 17 00:00:00 2001 From: rocksload Date: Sat, 11 Oct 2025 21:00:53 +0800 Subject: [PATCH] refactor: use slices.Contains to simplify code Signed-off-by: rocksload --- auth/hook.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/auth/hook.go b/auth/hook.go index 3cb5b8b9..2ecb12f3 100644 --- a/auth/hook.go +++ b/auth/hook.go @@ -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