Skip to content

Commit

Permalink
Fix handling of validation log request path
Browse files Browse the repository at this point in the history
  • Loading branch information
kdkasad committed Dec 26, 2024
1 parent 3a0ed3b commit 45cc742
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log/slog"
"net/http"
"os"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 45cc742

Please sign in to comment.