From 45cc742a576fa5f939dbaa94634a0a785d9aab71 Mon Sep 17 00:00:00 2001 From: Kian Kasad Date: Wed, 25 Dec 2024 22:53:22 -0800 Subject: [PATCH] Fix handling of validation log request path --- main.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 4f8f940..4af7203 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "log/slog" "net/http" "os" + "path/filepath" "strings" "time" @@ -53,13 +54,6 @@ func main() { mux := http.NewServeMux() - // Ensure log file for member validation is in the current working - // directory, - if strings.HasPrefix(*flagValidationLog, "/") || strings.HasPrefix(*flagValidationLog, "..") { - slog.Error("Validation log file must be in the current working directory") - os.Exit(1) - } - // Ensure log file exists and if not, create it if _, err := os.Stat(*flagValidationLog); os.IsNotExist(err) { slog.Info("Validation log file does not exist; creating it") @@ -88,7 +82,7 @@ func main() { mux.HandleFunc("/next", m.next) mux.HandleFunc("/previous", m.previous) mux.HandleFunc("/random", m.random) - mux.HandleFunc("/"+*flagValidationLog, m.validationLog) + mux.HandleFunc("/" + filepath.Base(*flagValidationLog), m.validationLog) fileHandler := http.StripPrefix("/static/", http.FileServer(http.Dir("static"))) mux.Handle("/static/", fileHandler)