From 97b8911ba8a65456091cbec0202f6b5209fcf363 Mon Sep 17 00:00:00 2001 From: rocksload Date: Fri, 17 Oct 2025 22:45:47 +0800 Subject: [PATCH] refactor: use slices.Contains to simplify code (#5483) --- 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